2019-09-23 07:17:15 +08:00
|
|
|
int ChatHandler(wchar_t* msg) {
|
|
|
|
for (DLL* dll: modDLLs) {
|
|
|
|
if (dll->HandleChat) {
|
|
|
|
if ( ((int(*)(wchar_t*))dll->HandleChat)(msg) ){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
void* ChatHandler_ptr = (void*)&ChatHandler;
|
|
|
|
|
|
|
|
void* ASMChatHandler_jmpback;
|
|
|
|
void* ASMChatHandler_bail;
|
|
|
|
void no_optimize ASMChatHandler() {
|
|
|
|
asm(PUSH_ALL
|
|
|
|
|
2019-09-25 07:03:07 +08:00
|
|
|
"mov rcx, rbx \n" // The message
|
2019-09-23 07:17:15 +08:00
|
|
|
|
|
|
|
PREPARE_STACK
|
|
|
|
|
|
|
|
"call [ChatHandler_ptr] \n"
|
|
|
|
|
|
|
|
RESTORE_STACK
|
|
|
|
|
|
|
|
// Did the handler return true?
|
|
|
|
"test al, al \n"
|
|
|
|
"jnz bail \n"
|
|
|
|
|
|
|
|
POP_ALL
|
|
|
|
|
|
|
|
// original code
|
2019-10-06 03:59:20 +08:00
|
|
|
"mov qword ptr [rbp+0x88], 7 \n"
|
|
|
|
"mov [rbp+0x80], r12 \n"
|
|
|
|
"mov [rbp+0x70], r12w \n"
|
2019-09-23 07:17:15 +08:00
|
|
|
"jmp [ASMChatHandler_jmpback] \n"
|
|
|
|
|
|
|
|
|
|
|
|
"bail: \n"
|
|
|
|
POP_ALL
|
|
|
|
"jmp [ASMChatHandler_bail]"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
void SetupChatHandler() {
|
2019-10-06 03:59:20 +08:00
|
|
|
WriteFarJMP(base+0x97198, (void*)&ASMChatHandler);
|
|
|
|
ASMChatHandler_jmpback = (void*)base+0x971B0;
|
|
|
|
ASMChatHandler_bail = (void*)base+0x9777A;
|
2019-09-23 07:17:15 +08:00
|
|
|
}
|