diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index a950e71..30647f1 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -13942,6 +13942,52 @@ bool InsertSilkysHook() return true; } +bool Silkys2Filter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + + WideStringCharReplacer(text, len, L"\\i", 2, L'\''); + + return true; +} + +bool InsertSilkys2Hook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/r89173 + */ + const BYTE bytes[] = { + 0x75, 0x10, // jne doukyuusei.exe+A5F7E + 0x56, // push esi + 0x57, // push edi + 0xE8, XX4 // call doukyuusei.exe+A6120 << hook here + }; + enum { addr_offset = sizeof(bytes) - 5 }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:Silkys2: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr + addr_offset; + hp.offset = pusha_edi_off -4; + hp.index = 0; + hp.filter_fun = Silkys2Filter; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + ConsoleOutput("vnreng: INSERT Silkys2"); + NewHook(hp, "Silkys2"); + return true; +} + +bool InsertSilkysHooks() +{ return InsertSilkysHook() || InsertSilkys2Hook();} + /** jichi 6/1/2014 Eushully * Insert to the last GetTextExtentPoint32A * diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index d229558..f6071d2 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -141,7 +141,7 @@ bool InsertElfHook(); // elf: Silky.exe bool InsertScenarioPlayerHook();// sol-fa-soft: *.iar && *.sec5 bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe bool InsertSideBHook(); // SideB: Copyright side-B -bool InsertSilkysHook(); // SilkysPlus +bool InsertSilkysHooks(); // SilkysPlus bool InsertSyuntadaHook(); // Syuntada: dSoh.dat bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini bool InsertSystemAoiHook(); // SystemAoi: *.vfs diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index 564af5e..9728fec 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -164,7 +164,7 @@ bool DetermineEngineByFile1() // jichi 6/9/2015: Skip Silkys Sakura if ( // Almost the same as Silkys except mes.arc is replaced by Script.arc Util::CheckFile(L"data.arc") && Util::CheckFile(L"effect.arc") && Util::CheckFile(L"Script.arc")) { - InsertSilkysHook(); + InsertSilkysHooks(); return true; } if (Util::CheckFile(L"data\\pack\\*.cpz")) {