From 733a61a3bca8141371c671ebe30e4912d7c361df Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sat, 23 Sep 2023 20:27:31 +0200 Subject: [PATCH 1/2] Sekai Projec engine hooks --- texthook/engine/engine.cc | 69 ++++++++++++++++++++++++++++++++++++++ texthook/engine/engine.h | 1 + texthook/engine/match32.cc | 4 +++ 3 files changed, 74 insertions(+) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c2c7abc..71d838d 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21728,6 +21728,75 @@ bool InsertNamcoPS2Hook() } #endif // 0 +bool InsertSekaiProject1Hook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/r21174 + */ + const BYTE bytes[] = { + 0xC7, 0x45, 0xDC, 0x00, 0x00, 0x00, 0x00, // mov [ebp-24],00000000 << hook here + 0xEB, 0x09, // jmp "SCHOOLDAYS HQ.exe"+4C821 + 0x8B, 0x45, 0xDC, // mov eax,[ebp-24] + 0x83, 0xC0, 0x01, // add eax,01 + 0x89, 0x45, 0xDC // mov [ebp-24],eax + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:SekaiProject1: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr; + hp.offset = 0x4 * 21; //arg21 + hp.index = 0; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + ConsoleOutput("vnreng: INSERT SekaiProject1"); + NewHook(hp, "SekaiProject1"); + return true; +} + +bool InsertSekaiProject2Hook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/r39989 + */ + const BYTE bytes[] = { + 0xCC, // int 3 + 0x8B, 0x44, 0x24, 0x04, // mov eax,[esp+04] << hook here + 0x83, 0xEC, 0x14, // sub esp,14 + 0x55, // push ebp + 0x56, // push esi + 0x57, // push edi + 0x8B, 0xF9 // mov edi,ecx + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:SekaiProject2: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr + 1; + hp.offset = 0x4 * 1; //arg1 + hp.index = 0; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + ConsoleOutput("vnreng: INSERT SekaiProject2"); + NewHook(hp, "SekaiProject2"); + return true; +} + +bool InsertSekaiProjectHooks() +{ return InsertSekaiProject1Hook() || InsertSekaiProject2Hook();} + } // namespace Engine // EOF diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 5e167b2..0c97454 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -165,6 +165,7 @@ void InsertRealliveHook(); // RealLive: RealLive*.exe void InsertStuffScriptHook(); // Stuff: *.mpk bool InsertTinkerBellHook(); // TinkerBell: arc00.dat bool InsertWaffleHook(); // WAFFLE: cg.pak +bool InsertSekaiProjectHooks(); // Sekai Project: Packs/*.GPK // CIRCUS: avdata/ bool InsertCircusHook1(); diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index fffc4c7..2ab1919 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -370,6 +370,10 @@ bool DetermineEngineByFile3() bool DetermineEngineByFile4() { + if (Util::CheckFile(L"Packs/*.GPK")) { + if (InsertSekaiProjectHooks()) + return true; + } if (Util::CheckFile(L"EAGLS.dll")) { // jichi 3/24/2014: E.A.G.L.S //ConsoleOutput("vnreng: IGNORE EAGLS"); InsertEaglsHook(); From c19e1d0b248ca1b1c3a424733c2e5c1d17b1ee16 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sun, 24 Sep 2023 11:54:07 +0200 Subject: [PATCH 2/2] added hook for VN v1193 --- texthook/engine/engine.cc | 50 ++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 71d838d..79fb288 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21729,6 +21729,40 @@ bool InsertNamcoPS2Hook() #endif // 0 bool InsertSekaiProject1Hook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/v1193 + */ + const BYTE bytes[] = { + 0xCC, // int 3 + 0x83, 0xEC, 0x10, // sub esp,10 << hook here + 0x8B, 0x44, 0x24, 0x14, // mov eax,[esp+14] + 0x53, // push ebx + 0x56, // push esi + 0x50, // push eax + 0x8B, 0xD9 // mov ebx,ecx + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:SekaiProject1: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr + 1; + hp.offset = 0x4 * 1; //arg1 + hp.index = 0; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + ConsoleOutput("vnreng: INSERT SekaiProject1"); + NewHook(hp, "SekaiProject1"); + return true; +} + +bool InsertSekaiProject2Hook() { //by Blu3train /* @@ -21746,7 +21780,7 @@ bool InsertSekaiProject1Hook() ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); if (!addr) { - ConsoleOutput("vnreng:SekaiProject1: pattern not found"); + ConsoleOutput("vnreng:SekaiProject2: pattern not found"); return false; } @@ -21755,12 +21789,12 @@ bool InsertSekaiProject1Hook() hp.offset = 0x4 * 21; //arg21 hp.index = 0; hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; - ConsoleOutput("vnreng: INSERT SekaiProject1"); - NewHook(hp, "SekaiProject1"); + ConsoleOutput("vnreng: INSERT SekaiProject2"); + NewHook(hp, "SekaiProject2"); return true; } -bool InsertSekaiProject2Hook() +bool InsertSekaiProject3Hook() { //by Blu3train /* @@ -21780,7 +21814,7 @@ bool InsertSekaiProject2Hook() ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); if (!addr) { - ConsoleOutput("vnreng:SekaiProject2: pattern not found"); + ConsoleOutput("vnreng:SekaiProject3: pattern not found"); return false; } @@ -21789,13 +21823,13 @@ bool InsertSekaiProject2Hook() hp.offset = 0x4 * 1; //arg1 hp.index = 0; hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; - ConsoleOutput("vnreng: INSERT SekaiProject2"); - NewHook(hp, "SekaiProject2"); + ConsoleOutput("vnreng: INSERT SekaiProject3"); + NewHook(hp, "SekaiProject3"); return true; } bool InsertSekaiProjectHooks() -{ return InsertSekaiProject1Hook() || InsertSekaiProject2Hook();} +{ return InsertSekaiProject1Hook() || InsertSekaiProject2Hook() || InsertSekaiProject3Hook();} } // namespace Engine