[Guide] Handling Client Networking @ Any State Process

11/30/2019 10:20 #HB#1
Hey there,

I've been hella busy lately, some guy asked me about handling messages in client-side like a week ago, I told 'em I'll make a guide and I totally got busy & forgot.

Anyways, lets get into this.

[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

Note: Structures don't really have to be 100% correct, that's just analyzing & guesses.

How To Hook State Process: Since OnPacketRecv is a virtual function, its a different function with a different address per state process.

The main place where OnPacketRecv is called should be at:
Code:
00BA8FB1 | FF D0                  | call eax                                         | OnPacketRecv
So basically, you can set a breakpoint there in different state processes & get the address of the function.

For example, I want the address of CPSTitle::OnPacketRecv, so I set a breakpoint on that address above during login section, when the breakpoint hits, get the value of EAX, thats your function address.

I made an example as for CPSMission, which handles msgs after selecting your character.

[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

Code:
replaceAddr(0x00DD440C, addr_from_this(&CPSMission::OnPacketRecv));
And that's all.

Note: If you're planning to use ReadStringA or ReadStringW functions, you need to ensure you're using VC80 compiler, AKA Visual Studio 2005.

Special thanks to: florian0 :rolleyes:
11/30/2019 10:48 hoangphan7#2
Thank's #HB.
florian everywhere :v super thank's :D
11/30/2019 17:30 Frukio92#3
Quote:
Originally Posted by #HB View Post
Sure, I'll check my old projects & release it as soon as I have some free time.
we also expect this :D
01/06/2020 09:16 concucu#4
Please add an example
01/07/2020 12:51 #HB#5
Quote:
Originally Posted by concucu View Post
Please add an example
mmm

Quote:
Originally Posted by #HB View Post
I made an example as for CPSMission, which handles msgs after selecting your character.

[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]
01/25/2020 22:48 Empire1453#6
Cannot access pastebin extensions
01/30/2020 03:56 #HB#7
Quote:
Originally Posted by hoangphan7 View Post
But how can i send / receiver custom packet like 0x8888 ?
Everything is explained in example's comments.
Code:
Returning 1 means packet is accepted & read, 0 means fail & afair client may crash if
you do return 0.

Also, if you're planning to read original packets, set TotalReadBytes to 0 after you
finish reading, because sro_client will re-read this stuff and if any byte were read before,
it'll crash because it attempts to read over max bytes limit.
06/12/2020 12:16 WolfgangNeverDie#8
Hi Brother!
I want to read packet C->S (Client to Server. like 0x7074 7045 ...). How can i do it?
Your CPSMission only have read packet receiver from Server (S->C)
Thank's you ^^
06/12/2020 13:38 #HB#9
Quote:
Originally Posted by WolfgangNeverDie View Post
Hi Brother!
I want to read packet C->S (Client to Server. like 0x7074 7045 ...). How can i do it?
Your CPSMission only have read packet receiver from Server (S->C)
Thank's you ^^
Hey,

Well, actually client only receives server messages and server can only receive client messages, otherwise it won't make any sense.

If you really wanna handle client messages sent from client, you can hook SendMsg(CMsgStreamBuffer*) and do so. But I don't recommend doing such a thing as its not safe at all, and you'll need more things to do than just hooking that function.

If you wanna modify the structure of some message, I suggest you to go to the place where it gets written and sent in the client and modify it, that'd be much cleaner, safer and less processing.
06/12/2020 14:07 WolfgangNeverDie#10
Quote:
Originally Posted by #HB View Post
Hey,

Well, actually client only receives server messages and server can only receive client messages, otherwise it won't make any sense.

If you really wanna handle client messages sent from client, you can hook SendMsg(CMsgStreamBuffer*) and do so. But I don't recommend doing such a thing as its not safe at all, and you'll need more things to do than just hooking that function.

If you wanna modify the structure of some message, I suggest you to go to the place where it gets written and sent in the client and modify it, that'd be much cleaner, safer and less processing.

Yeah. Thank's you :D
06/15/2020 23:24 sarkoplata#11
Quote:
Originally Posted by WolfgangNeverDie View Post
Hi Brother!
I want to read packet C->S (Client to Server. like 0x7074 7045 ...). How can i do it?
Your CPSMission only have read packet receiver from Server (S->C)
Thank's you ^^
you can hook: 0x008418D0
the first arg pushed into the stack is a CMsgStreamBuffer*.
06/16/2020 15:13 Hercules*#12
Quote:
Originally Posted by sarkoplata View Post
you can hook: 0x008418D0
the first arg pushed into the stack is a CMsgStreamBuffer*.
btw we can prevent a c->s packet ?
06/16/2020 15:18 sarkoplata#13
yes you can.
06/16/2020 18:44 WolfgangNeverDie#14
Quote:
Originally Posted by sarkoplata View Post
you can hook: 0x008418D0
the first arg pushed into the stack is a CMsgStreamBuffer*.
No. :D i want to handle packet send from client. (like cancel some function ..)
07/01/2020 16:23 sarkoplata#15
Quote:
Originally Posted by WolfgangNeverDie View Post
No. :D i want to handle packet send from client. (like cancel some function ..)
yes you can with the addr I gave above.