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-09-24 07:09:22 +08:00
|
|
|
"mov qword ptr [rbp+0x78], 7 \n"
|
|
|
|
"mov [rbp+0x70], r12 \n"
|
2019-09-25 07:03:07 +08:00
|
|
|
"mov [rbp+0x60], r12w \n"
|
2019-09-23 07:17:15 +08:00
|
|
|
"jmp [ASMChatHandler_jmpback] \n"
|
|
|
|
|
|
|
|
|
|
|
|
"bail: \n"
|
|
|
|
POP_ALL
|
|
|
|
"jmp [ASMChatHandler_bail]"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
void SetupChatHandler() {
|
2019-09-26 08:01:17 +08:00
|
|
|
WriteFarJMP(base+0x97108, (void*)&ASMChatHandler);
|
|
|
|
ASMChatHandler_jmpback = (void*)base+0x9711A;
|
|
|
|
ASMChatHandler_bail = (void*)base+0x9785A;
|
2019-09-23 07:17:15 +08:00
|
|
|
}
|