Getting CHAT message from RPC and related.

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
Hi, I'm trying to read the messages which are being sent to me by the server, I want to modify the message/do anything I want, but the problem is, I can't find out which RPC receives messages and what is the read pointer for it.
this is what I have tried so far.
and I'm using SF API 5.3.3
[shcode=cpp]
bool CALLBACK incomingRPC(stRakNetHookParams * params)
{
if (params->packetId == ScriptRPCEnumeration::RPC_ScrClientMessage)
{
char string1[64], string2[64], string3[64];
params->bitStream->ResetReadPointer();
params->bitStream->Read(string1); 
params->bitStream->Read(string2);
params->bitStream->Read(string3);
params->bitStream->ResetReadPointer();
AddMessageToChat(D3DCOLOR_XRGB(0, 0XAA, 0), "Read: %s  -  %s  -  %s", string1, string2, string3);
}

return true; 
}
[/shcode]
any help is greatly appreciated.
if I try RPCEnumeration::RPC_CHAT, it outputs random characters but I think RPC_CHAT is what we send, not we receive also anyways this code I posted above, there is no reading or messages in chat even if I type message in chat, I see it when I join the server but it is random characters too but after that, I never see the message. I don't know alot about RPC's and their reading.
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
174
First, it has nothing to do with RPC's in general it's a sequential "Bit"stream.
Second, you forgot to read the message length and color in fact I don't know how you come to the conclusion to read 3 arbitrary strings?

.. so for client messages it is:
DWORD -> color
DWORD -> strlen
actual message as c-type string.

Basically, read until strlen -> allocate buffer -> read to buffer with length given by strlen.
 

ini

Well-known member
Joined
Sep 28, 2015
Messages
321
Reaction score
115
if you want to study the rpc's i recomend you to use my raksamp , specially done for that purpose and more....
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
174
0x32789 said:
0x688 said:
Basically, read until strlen -> allocate buffer -> read to buffer with length given by strlen.
I didn't understand what do you mean, with "read until strlen"

bs.read(target, len)
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
ah, I thought you meant for(int i = 0; i < strlen; i++) { read(); }


also thanks, its solved. I'm giving my code here so if anyone is stuck on the same problem, he can get it fixed.
[shcode=cpp]
bool CALLBACK incomingRPC(stRakNetHookParams * params)
{
if (params->packetId == ScriptRPCEnumeration::RPC_ScrClientMessage)
{
DWORD color;
DWORD strlen;
char string[256];
params->bitStream->ResetReadPointer();
params->bitStream->Read(color);
params->bitStream->Read(strlen);
params->bitStream->Read(string, strlen);
string[strlen] = '\0';
AddMessageToChat(D3DCOLOR_XRGB(0, 0xAA, 0), "{00FF33}%s", string);
}
return true;
}
[/shcode]
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
174
@0x3278: You need to allocate your buffer dynamically or limit the size, this will turn into a memory corruption mess with every msg > 256.
 
Top