|
You last visited: Today at 04:54
Advertisement
A question about reading packet data in mod
Discussion on A question about reading packet data in mod within the Mabinogi forum part of the MMORPGs category.
04/03/2014, 07:53
|
#1
|
elite*gold: 0
Join Date: Apr 2014
Posts: 19
Received Thanks: 0
|
A question about reading packet data in mod
Hi guys, I've been reading some source code of mods and found packets to be quite interesting. However, I can't seem to find a way to read and manipulate the T_BIN packet data using functions in the MabiPacket.cpp/.h files which are publicly available (Can only read the content in AlissaAnalyzer). Could anyone give me some hint on how this could be done?
Besides, can anyone give me the source code of mod_potato if it's ever made available? As it has very likely achieved the aforementioned functionality.
Thanks.
|
|
|
04/03/2014, 09:32
|
#2
|
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
|
to extract:
00 T_BIN : BLAHBLAHBLAH
char* s=p.GetElement(0)->str; // your bin string
to pack:
PacketData d;
CMabiPacket p;
char bin[32]="BLAHBLAHBLAH\0"; // your bin string
d.type=7; d.str=bin; d.len=strlen(bin); p.AddElement(&d);
|
|
|
04/03/2014, 22:19
|
#3
|
elite*gold: 0
Join Date: Apr 2014
Posts: 19
Received Thanks: 0
|
Quote:
Originally Posted by Caesarw
to extract:
00 T_BIN : BLAHBLAHBLAH
char* s=p.GetElement(0)->str; // your bin string
to pack:
PacketData d;
CMabiPacket p;
char bin[32]="BLAHBLAHBLAH\0"; // your bin string
d.type=7; d.str=bin; d.len=strlen(bin); p.AddElement(&d);
|
Thanks for your code. I tried using it to get the T_BIN in the 5211 packet and write it out in the log file but somehow failed, here's my code:
pdata = recvPacket.GetElement( 2 );
LPSTR iINFO = pdata->str;
WriteLog(iINFO);
No content about the T_BIN is written in the log file. The only result is as following:
"[04/03/14 16:00:00] - "
Did I misunderstand anything?
Anyways, thanks for letting me know that type=7 stands for T_BIN.
And by the way, could you tell me how to make functions execute asynchronously in the mod? Normally we use SendHook and RecvHook to monitor the packets and perform immediate action after identifying specific ones, but in some cases a delayed response is needed.
For example, if I want to make the mod capable of AFK training bard skills, what I would try to do is to send an activate skill packet and wait for a certain amount of time before sending the next one. However, the simplest implementation which is delay(Nms) delays (actually freezes) the entire client. I've also tried using a separate thread that waits for signal to perform operation but it crashes the client every time the Send function is called. Any hint on this one?
|
|
|
04/04/2014, 02:08
|
#4
|
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
|
WriteLog writes nothing because the BIN string starts with an 0, which is the termination of a string to printf. Try iterating the str array for the data you want, e.g.
for (int i=0; i<p.GetElement(2)->len; i++)
printf("%d ", p.GetElement(2)->str[i];
You'd better use RecvHook on this scene, making it a packet-driven script.
It crashes the client because the SIGNAL handler resides in different context from the client.exe process, so the Send pointer could be anything to the handler, try calling this pointer would normally cause a segment fault.
|
|
|
04/04/2014, 04:49
|
#5
|
elite*gold: 0
Join Date: Apr 2014
Posts: 19
Received Thanks: 0
|
Quote:
Originally Posted by Caesarw
WriteLog writes nothing because the BIN string starts with an 0, which is the termination of a string to printf. Try iterating the str array for the data you want, e.g.
for (int i=0; i<p.GetElement(2)->len; i++)
printf("%d ", p.GetElement(2)->str[i];
You'd better use RecvHook on this scene, making it a packet-driven script.
It crashes the client because the SIGNAL handler resides in different context from the client.exe process, so the Send pointer could be anything to the handler, try calling this pointer would normally cause a segment fault.
|
Thanks a lot for that information. I didn't realize that the 0s I see in AlissaAnalyzer could actually be '\0'.
For my followed question, is there a way to achieve it with some sort of delay?
I could think of a workaround like calculating the desired time for the packet to be sent and save it to some variable. Then checks it in every Recvhook and send it when current time is beyond the scheduled time. However this delay may not be very accurate because it is not guaranteed that packets are being received frequently... or is it?
|
|
|
04/04/2014, 07:19
|
#6
|
elite*gold: 0
Join Date: May 2009
Posts: 166
Received Thanks: 518
|
Quote:
Originally Posted by anonentity
And by the way, could you tell me how to make functions execute asynchronously in the mod? Normally we use SendHook and RecvHook to monitor the packets and perform immediate action after identifying specific ones, but in some cases a delayed response is needed.
For example, if I want to make the mod capable of AFK training bard skills, what I would try to do is to send an activate skill packet and wait for a certain amount of time before sending the next one. However, the simplest implementation which is delay(Nms) delays (actually freezes) the entire client. I've also tried using a separate thread that waits for signal to perform operation but it crashes the client every time the Send function is called. Any hint on this one?

|
I think a pake based bot that I wrote long time ago had something like this. Setting a fixed delay would not be a good idea. What I did was simply using WaitForSingleObject to wait for certain event to happen (a recv packet) in my bot thread. The worker thread calls WaitRecv to enter wait. And whenever recvhook gets a packet it compares it with the expected opcode. If it is the expected OP then it will trigger the wait signal to resume the bot worker thread.
I think it was something like that if i remeber correctly. Probably not the most elegant solution. But it was simple and it worked.
Code:
void WaitRecv(DWORD OP){
expectedOP = OP;
if (expectedOP != 0xdeadc0de)
SetEvent(hRecvHookSignal);
#ifdef _DEBUG
WCHAR err[128] = L"debug: Waiting Recv [";
wcscat(err, DwordToWSTR(OP));
wcscat(err, L"]\n");
ConsoleOutput(err, cyan);
#endif // _DEBUG
if (WaitForSingleObject(hWorkerSignal, 20000) == WAIT_TIMEOUT){
WCHAR err[128] = L"Lileas: Wait Recv [";
wcscat(err, DwordToWSTR(OP));
wcscat(err, L"] timed out. Worker thread terminated...\n");
ConsoleOutput(err, lred);
ExitThread(0xdeadc0de);
}
}
|
|
|
04/04/2014, 07:31
|
#7
|
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
|
Quote:
Originally Posted by tliu0c
I think a pake based bot that I wrote long time ago had something like this. Setting a fixed delay would not be a good idea. What I did was simply using WaitForSingleObject to wait for certain event to happen (a recv packet) in my bot thread. The worker thread calls WaitRecv to enter wait. And whenever recvhook gets a packet it compares it with the expected opcode. If it is the expected OP then it will trigger the wait signal to resume the bot worker thread.
I think it was something like that if i remeber correctly. Probably not the most elegant solution. But it was simple and it worked.
Code:
void WaitRecv(DWORD OP){
expectedOP = OP;
if (expectedOP != 0xdeadc0de)
SetEvent(hRecvHookSignal);
#ifdef _DEBUG
WCHAR err[128] = L"debug: Waiting Recv [";
wcscat(err, DwordToWSTR(OP));
wcscat(err, L"]\n");
ConsoleOutput(err, cyan);
#endif // _DEBUG
if (WaitForSingleObject(hWorkerSignal, 20000) == WAIT_TIMEOUT){
WCHAR err[128] = L"Lileas: Wait Recv [";
wcscat(err, DwordToWSTR(OP));
wcscat(err, L"] timed out. Worker thread terminated...\n");
ConsoleOutput(err, lred);
ExitThread(0xdeadc0de);
}
}
|
Wow, 0x64, being so boring these days, any new mods?
|
|
|
04/04/2014, 07:58
|
#8
|
elite*gold: 0
Join Date: May 2009
Posts: 166
Received Thanks: 518
|
Quote:
Originally Posted by Caesarw
Wow, 0x64, being so boring these days, any new mods?
|
No. I'm done with mabi long time ago. I don't even have an account at NA mabi anymore  . Tho many chinese ppl give me their accounts in CN server and wants me to find exploit.
No good game to mess with  All the new game these days have heavy western style...They just don't turn me on.
Waiting for a good game like BnS to come to NA. I'll probably be the first one to write a "pake" for it.
|
|
|
04/04/2014, 08:13
|
#9
|
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
|
Quote:
Originally Posted by tliu0c
No. I'm done with mabi long time ago. I don't even have an account at NA mabi anymore  . Tho many chinese ppl give me their accounts in CN server and wants me to find exploit.
No good game to mess with  All the new game these days have heavy western style...They just don't turn me on.
Waiting for a good game like BnS to come to NA. I'll probably be the first one to write a "pake" for it.
|
Count me in for the ``pake'', hah
|
|
|
 |
Similar Threads
|
Can you guide me to the best Packet writing\reading classes around here
12/05/2012 - SRO Coding Corner - 1 Replies
as the title indicates i want the best way\classes to Read\Write packets in C#
|
Lost connection to MySQL server at 'reading initial communication packet'
08/02/2011 - Metin2 Private Server - 3 Replies
Hallo Leute.
Ich bekomme die oben beschriebene Meldung sehr oft beim Aufrufen meiner Webseite.
Es ist auch recht egal, welche Scripts ich benutze. Der Fehler kommt sporadisch, aber oft.
Mal kommt er 5 Minuten lang garnicht, dann mal alle 2 bis 3 Minuten.
Aber länger als 10 Minuten hält die Webseite nicht, ohne diesen Fehler zu produzieren.
Warning: mysql_connect() : Lost connection to MySQL server at 'reading initial communication packet', system error: 113
Ist die volle...
|
[Poll] Reading data from text file or database?
04/01/2011 - SRO Coding Corner - 11 Replies
Hi,
I'm currently facing a little choice about how I should read the data of silkroad. So I hope that I can get a clear answer with this thread/poll.
Well as you might know I'm using C++ and currently I'm reading the data into the memory which is just a big list of for example npc position objects.
So yesterday I created a little test and I inserted all the npc positions into an MySQL database (version 5.1) and I used 10 different id's of npcs to get the positions. I runned this test...
|
[Question] Packet data , packet editing ??
10/13/2009 - 9Dragons - 2 Replies
I would like to know :
What is packet data?
How do i get the address for hacking a item in game?
How to use it ??
|
Decryrting or reading Data.dat
07/17/2009 - Archlord - 9 Replies
Hello guys i need the texture from the Archlord Data.dat the normal Data.dat have i break but the animation texture i think is packed or cryptet like Skill Data.dat. Any one a idear how to read the data?
|
All times are GMT +1. The time now is 04:55.
|
|