diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 726db04..d85737b 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -20748,6 +20748,13 @@ bool InsertTecmoPSPHook() */ bool InsertPCSX2Hooks() { + memcpy(spDefault.pattern, Array{ 0x89, 0xc8, 0xc1, 0xe8, 0x0c }, spDefault.length = 5); + *spDefault.boundaryModule = 0; + spDefault.offset = 0; + spDefault.searchTime = 60'000; + spDefault.maxRecords = 500'000; + spDefault.padding = 0x20000000; + ConsoleOutput("Textractor: PCSX2 detected (searching for hooks may work)"); // TODO: Add generic hooks return InsertTypeMoonPS2Hook() || InsertMarvelousPS2Hook() diff --git a/texthook/hookfinder.cc b/texthook/hookfinder.cc index 2f757b8..a5988d5 100644 --- a/texthook/hookfinder.cc +++ b/texthook/hookfinder.cc @@ -19,6 +19,7 @@ namespace struct HookRecord { uint64_t address = 0; + uintptr_t padding = 0; int offset = 0; char text[MAX_STRING_SIZE] = {}; }; @@ -134,9 +135,9 @@ void Send(char** stack, uintptr_t address) // it is unsafe to call ANY external functions from this, as they may have been hooked (if called the hook would call this function making an infinite loop) // the exceptions are compiler intrinsics like _InterlockedDecrement if (recordsAvailable <= 0) return; - for (int i = -registers; i < 10; ++i) + for (int i = -registers; i < 10; ++i) for (auto padding : { uintptr_t{}, sp.padding }) { - char* str = stack[i] + sp.padding; + char* str = stack[i] + padding; if (IsBadReadPtr(str) || IsBadReadPtr(str + MAX_STRING_SIZE)) continue; __try { @@ -155,6 +156,7 @@ void Send(char** stack, uintptr_t address) if (n < sp.maxRecords) { records[n].address = address; + records[n].padding = padding; records[n].offset = i * sizeof(char*); for (int j = 0; j < length; ++j) records[n].text[j] = str[j]; records[n].text[length] = 0; @@ -240,7 +242,7 @@ void SearchForHooks(SearchParam spUser) hp.offset = records[i].offset; hp.type = USING_UNICODE | USING_STRING; hp.address = records[i].address; - hp.padding = sp.padding; + hp.padding = records[i].padding; hp.codepage = sp.codepage; if (sp.hookPostProcessor) sp.hookPostProcessor(hp); NotifyHookFound(hp, (wchar_t*)records[i].text);