Merge remote-tracking branch 'Blu3train/Godot2Hook'

This commit is contained in:
Chenx221 2024-09-05 12:23:52 +08:00
commit 5e0e3eb49d

View File

@ -340,7 +340,6 @@ bool IllegalWideCharsFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
namespace Engine namespace Engine
{ {
enum : DWORD { X64_MAX_REL_ADDR = 0x00300000 };
enum : DWORD { X64_MAX_REL_ADDR = 0x00300000 }; enum : DWORD { X64_MAX_REL_ADDR = 0x00300000 };
/** Artikash 6/7/2019 /** Artikash 6/7/2019
* PPSSPP JIT code has pointers, but they are all added to an offset before being used. * 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"); ConsoleOutput("Textractor: Ren'py failed: failed to find python2X.dll");
return false; 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() bool InsertRenpy3Hook()
{ {
//by Blu3train //by Blu3train
@ -822,6 +856,10 @@ namespace Engine
{ {
if (Util::CheckFile(L"PPSSPP*.exe") && FindPPSSPP()) return true; 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; 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? if (GetModuleHandleW(L"GameAssembly.dll")) // TODO: is there a way to autofind hook?