diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 288b251..a950e71 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -23712,6 +23712,51 @@ bool InsertNamcoPS2Hook() } #endif // 0 +bool KogadoFilter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + + text[(*len)++] = ' '; + + return true; +} + +bool InsertKogadoHook() { + //by Blu3train + /* + * Sample games: + * https://vndb.org/r12750 + */ + const BYTE bytes[] = { + 0x8B, 0xC7, // mov eax,edi <- hook here + 0xF3, 0xA5, // repe movsd + 0x8B, 0xCA, // mov ecx,edx + 0x83, 0xE1, 0x03, // and ecx,03 + 0xF3, 0xA4, // repe movsb + 0x5F, // pop edi + 0x5E // pop esi + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:Kogado: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr; + hp.offset = pusha_esi_off -4; + hp.index = 0; + hp.type = USING_UTF8 | USING_STRING | NO_CONTEXT; + hp.filter_fun = KogadoFilter; + ConsoleOutput("vnreng: INSERT Kogado"); + NewHook(hp, "Kogado"); + + return true; +} + bool SysdFilter(LPVOID data, DWORD *size, HookParam *, BYTE) { auto text = reinterpret_cast(data); diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 04155dc..d229558 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -156,6 +156,7 @@ bool InsertWillPlusHook(); // WillPlus: Rio.arc bool InsertWolfHook(); // Wolf: Data.wolf bool InsertYukaSystemHooks(); // YukaSystem2: *.ykc bool InsertYurisHook(); // YU-RIS: *.ypf +bool InsertKogadoHook(); // Kogado: *.pak bool InsertSysdHook(); // Sysd: sysd.ini bool InsertKissHook(); // Kiss: GameData/*.arc bool InsertKidHook(); // Kid: resource string diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index 644ea3f..564af5e 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -380,6 +380,10 @@ bool DetermineEngineByFile3() bool DetermineEngineByFile4() { + if (Util::CheckFile(L"*.pak")) { + if (InsertKogadoHook()) + return true; + } if (Util::CheckFile(L"sysd.ini")) { if (InsertSysdHook()) return true;