From e14c9b6a0909f9514cb138b8355555f56de9fa14 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Tue, 11 Feb 2020 23:35:23 -0700 Subject: [PATCH] fix v8 hook x64 --- include/const.h | 2 +- texthook/engine/engine.cc | 19 +++++++++---------- texthook/engine/match64.cc | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/const.h b/include/const.h index dde44fd..995922f 100644 --- a/include/const.h +++ b/include/const.h @@ -4,7 +4,7 @@ // 8/23/2013 jichi // Branch: ITH/common.h, rev 128 -enum { STRING = 12, MESSAGE_SIZE = 500, PIPE_BUFFER_SIZE = 2000, SHIFT_JIS = 932, MAX_MODULE_SIZE = 120, PATTERN_SIZE = 30, HOOK_NAME_SIZE = 30, FIXED_SPLIT_VALUE = 0x10001 }; +enum { STRING = 12, MESSAGE_SIZE = 500, PIPE_BUFFER_SIZE = 10000, SHIFT_JIS = 932, MAX_MODULE_SIZE = 120, PATTERN_SIZE = 30, HOOK_NAME_SIZE = 30, FIXED_SPLIT_VALUE = 0x10001 }; enum WildcardByte { XX = 0x11 }; enum HostCommandType { HOST_COMMAND_NEW_HOOK, HOST_COMMAND_REMOVE_HOOK, HOST_COMMAND_FIND_HOOK, HOST_COMMAND_MODIFY_HOOK, HOST_COMMAND_HIJACK_PROCESS, HOST_COMMAND_DETACH }; diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 081dc80..cfa8df1 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -10351,16 +10351,15 @@ bool InsertV8Hook(HMODULE module) 0x5d, // pop ebp 0xc2 // ret }; - if (hp.address) - if (DWORD addr = MemDbg::findBytes(bytes, sizeof(bytes), hp.address, hp.address + 0x30)) - { - hp.address = addr; - hp.offset = 0x8 + *(BYTE*)(addr + 2); // second argument + amount that the stack pointer is offset from arguments - hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; - hp.length_offset = (0x10 + *(BYTE*)(addr + 2)) / 4; // fourth argument + amount that the stack pointer is offset from arguments - hp.text_fun = nullptr; - NewHook(hp, "JavaScript2"); - } + if (DWORD addr = MemDbg::findBytes(bytes, sizeof(bytes), hp.address, hp.address + 0x30)) + { + hp.address = addr; + hp.offset = 0x8 + *(BYTE*)(addr + 2); // second argument + amount that the stack pointer is offset from arguments + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + hp.length_offset = (0x10 + *(BYTE*)(addr + 2)) / 4; // fourth argument + amount that the stack pointer is offset from arguments + hp.text_fun = nullptr; + NewHook(hp, "JavaScript2"); + } return true; } diff --git a/texthook/engine/match64.cc b/texthook/engine/match64.cc index cd76817..c0edef2 100644 --- a/texthook/engine/match64.cc +++ b/texthook/engine/match64.cc @@ -104,7 +104,7 @@ namespace Engine even though this should get the true length mono uses internally there's still some garbage picked up on https://vndb.org/v20403 demo, don't know why */ int len = *(int*)(data - 4); - return len > 0 && len < 1000 ? len * 2 : 0; + return len > 0 && len < PIPE_BUFFER_SIZE ? len * 2 : 0; }; NewHook(hp, name); } @@ -139,7 +139,7 @@ namespace Engine hp.length_fun = [](uintptr_t, uintptr_t data) { int len = *(int*)(data - 4); - return len > 0 && len < 1000 ? len * 2 : 0; + return len > 0 && len < PIPE_BUFFER_SIZE ? len * 2 : 0; }; NewHook(hp, "JavaScript"); return true;