Originally Posted by
namreeb
You merely need to intercept the function which sends chat messages to the server...
Thank you for the idea.
I started search with lua_SendChatMessage and found this function:
Code:
// 3.3.5a 12340
int __usercall lua_SendChatMessage@<eax>(int edi0@<edi>, int a1)
{
//...
sub_577D00(*(int *)v37, &v31, 0x100u);
//...
}
where 0x100u it's length the input text
I tried to hook it like:
Code:
//int __cdecl sub_577D00(int a1, _BYTE *a2, unsigned int a3)
typedef int(__cdecl* WoWSendMessageDelegate)(char*, int, int);
WoWSendMessageDelegate WoWSendMessage = (WoWSendMessageDelegate)0x577D00;
BYTE WSM_original_bytes[5] = { 0, 0, 0, 0, 0 };
BYTE WSM_hook_bytes[5] = { 0, 0, 0, 0, 0 };
DWORD WSM_original_protection = 0;
int __cdecl WoWSendMessageHook(char* pText, int unk_1, int textSize)
{
memcpy(WoWSendMessage, WSM_original_bytes, 5);
MyMessageBox(pText);
int ret = 0;
if (pText[0] == '.') // <----- some command for the test. Example: ".test"
{
ret = WoWSendMessage(pText, unk_1, 0);
}
else ret = WoWSendMessage(pText, unk_1, textSize);
memcpy(WoWSendMessage, WSM_hook_bytes, 5);
return ret;
}
void WoWSendMessageInitHook()
{
memcpy(WSM_original_bytes, WoWSendMessage, 5);
WSM_hook_bytes[0] = 0xE9;
DWORD addr = (DWORD)WoWSendMessageHook - (DWORD)WoWSendMessage - 5;
memcpy(WSM_hook_bytes + 1, &addr, 5);
VirtualProtect(WoWSendMessage, 8, PAGE_EXECUTE_READWRITE, &WSM_original_protection);
memcpy(WoWSendMessage, WSM_hook_bytes, 5);
}
And it's work. If it's my command, not sent to the server.