diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 73d772d..0b921d0 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -19240,6 +19240,56 @@ bool NoAsciiFilter(LPVOID data, DWORD *size, HookParam *, BYTE) return false; } +bool Anim3Filter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + + StringFilterBetween(text, len, "\x81\x40", 2, "@m", 2); // @r(2,はと) + StringFilterBetween(text, len, "\x81\x40", 2, "@n", 2); // @r(2,はと) + StringCharReplacer(text, len, "@b", 2, ' '); + StringCharReplacer(text, len, "\x81\x42", 2, '.'); + StringCharReplacer(text, len, "\x81\x48", 2, '?'); + StringCharReplacer(text, len, "\x81\x49", 2, '!'); + + return true; +} + +bool InsertAnim3Hook() +{ + //mod by Blu3train + /* + * Sample games: + * https://vndb.org/v17427 + * https://vndb.org/v18837 + */ + const BYTE bytes[] = { + 0xCC, // int 3 + 0x55, // push ebp << hook here + 0x8B, 0xEC, // mov ebp,esp + 0x81, 0xEC, XX4, // sub esp,00000830 + 0xA1, XX4, // mov eax,[musu_mama.exe+A91F0] + 0x33, 0xC5, // xor eax,ebp + 0x89, 0x45, 0xE8 // mov [ebp-18],eax + }; + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:Anim3: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr + 1; + hp.offset = pusha_edx_off - 4; + hp.type = USING_STRING; + hp.filter_fun = Anim3Filter; + ConsoleOutput("vnreng: INSERT Anim3"); + NewHook(hp, "Anim3"); + + return true; +} + bool InsertMonoHooks() { HMODULE h = ::GetModuleHandleA("mono.dll"); diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index ed14c33..94ac829 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -198,6 +198,9 @@ bool InsertAges7Hook(); // AGES 7.0: Ages3ResT.dll bool InsertCircusHook1(); bool InsertCircusHook2(); +// Anim engines +bool InsertAnim3Hook(); + bool InsertDmmHooks(); // DMM: Data/Exi_UT2.sdat } // namespace Engine diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index c753897..c49f132 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -549,6 +549,10 @@ bool DetermineEngineByFile4() return true; } + if (Util::CheckFile(L"voice\\*.pck")) { + return /*InsertAnimHook() || InsertAnim2Hook() ||*/ InsertAnim3Hook(); + } + // jichi 11/22/2015: 凍京NECRO 体験版 // Jazzinghen 23/05/2020: Add check for 凍京NECRO // ResEdit shows multiple potential strings: