diff --git a/texthook/engine/match64.cc b/texthook/engine/match64.cc index aea2fd7..b29887b 100644 --- a/texthook/engine/match64.cc +++ b/texthook/engine/match64.cc @@ -340,7 +340,6 @@ bool IllegalWideCharsFilter(LPVOID data, DWORD *size, HookParam *, BYTE) namespace Engine { - enum : DWORD { X64_MAX_REL_ADDR = 0x00300000 }; enum : DWORD { X64_MAX_REL_ADDR = 0x00300000 }; /** Artikash 6/7/2019 * PPSSPP JIT code has pointers, but they are all added to an offset before being used. @@ -568,6 +567,41 @@ namespace Engine ConsoleOutput("Textractor: Ren'py failed: failed to find python2X.dll"); return false; } + bool InsertGodotHook2_X64() { + //by Blu3train + /* + * Sample games: + * https://vndb.org/r109138 + */ + const BYTE bytes[] = { + 0x48, 0x8B, 0x94, 0x24, XX4, // mov rdx,[rsp+000001C0] <- hook here + 0x4C, 0x89, 0xE1, // mov rcx,r12 + 0xE8, XX4, // call NULL-Windows.exe+D150 + 0x49, 0x8B, 0x06, // mov rax,[r14] + 0x48, 0x85, 0xC0, // test rax,rax + 0x0F, 0x85, XX4 // jne NULL-Windows.exe+A359D4 + + }; + + ULONG64 range = min(processStopAddress - processStartAddress, X64_MAX_REL_ADDR); + for (auto addr : Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStartAddress + range)) { + HookParam hp = {}; + hp.address = addr; + hp.offset = pusha_rcx_off -4; //RCX + hp.type = USING_STRING | USING_UNICODE; + ConsoleOutput("vnreng: INSERT Godot2_x64 Hook "); + NewHook(hp, "Godot2_x64"); + return true; + } + + ConsoleOutput("vnreng:Godot2_x64: pattern not found"); + return false; + } + + bool InsertGodotHooks_X64() + { + return InsertGodotHook2_X64(); + } bool InsertRenpy3Hook() { //by Blu3train @@ -822,6 +856,10 @@ namespace Engine { if (Util::CheckFile(L"PPSSPP*.exe") && FindPPSSPP()) return true; + if (Util::CheckFile(L"*.pck")) { + return InsertGodotHooks_X64(); + } + for (const wchar_t* moduleName : { (const wchar_t*)NULL, L"node.dll", L"nw.dll" }) if (InsertV8Hook(GetModuleHandleW(moduleName))) return true; if (GetModuleHandleW(L"GameAssembly.dll")) // TODO: is there a way to autofind hook?