diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 7d385ca..874bfde 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -6357,6 +6357,53 @@ bool InsertSystem43Hook() return ok; } +bool System42Filter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + + if (*len == 1) + return false; + if (all_ascii(text, *len)) { + CharReplacer(text, len, '`', ' '); + CharReplacer(text, len, '\x7D', '-'); + } + + return true; +} + +bool InsertSystem42Hook() { + //by Blu3train + /* + * Sample games: + * https://vndb.org/v1427 + */ + const BYTE bytes[] = { + 0x8B, 0x46, 0x04, // mov eax,[esi+04] + 0x57, // push edi + 0x52, // push edx + 0x50, // push eax + 0xE8, XX4 // call Sys42VM.DLL+4B5B0 + }; + + HMODULE module = GetModuleHandleW(L"Sys42VM.dll"); + auto [minAddress, maxAddress] = Util::QueryModuleLimits(module); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), minAddress, maxAddress); + if (!addr) + return false; + + HookParam hp = {}; + hp.address = addr; + hp.offset = pusha_edx_off -4; + hp.split = pusha_esp_off -4; + hp.type = NO_CONTEXT | USING_STRING | USING_SPLIT; + hp.filter_fun = System42Filter; + ConsoleOutput("vnreng: INSERT System42"); + NewHook(hp, "System42"); + + return true; +} + /******************************************************************************************** AtelierKaguya hook: Game folder contains message.dat. Used by AtelierKaguya games. diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 94ac829..f0658db 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -143,6 +143,7 @@ bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe bool InsertSideBHook(); // SideB: Copyright side-B bool InsertSilkysHooks(); // SilkysPlus bool InsertSyuntadaHook(); // Syuntada: dSoh.dat +bool InsertSystem42Hook(); // System42@AliceSoft: AliceStart.ini DLL/Sys42VM.dll bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini bool InsertSystemAoiHook(); // SystemAoi: *.vfs bool InsertTamamoHook(); // Tamamo diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index c49f132..162c690 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -675,6 +675,14 @@ bool DetermineEngineByProcessName() bool DetermineEngineOther() { + // jichi 12/26/2013: Add this after alicehook + if (Util::CheckFile(L"AliceStart.ini")) { + if (Util::CheckFile(L"DLL/Sys42VM.dll")) + if (InsertSystem42Hook()) + return true; + if (InsertSystem43Hook()) + return true; + } if (InsertAliceHook()) return true; // jichi 1/19/2015: Disable inserting Lstr for System40 @@ -683,11 +691,6 @@ bool DetermineEngineOther() ConsoleOutput("vnreng: IGNORE old System40.ini"); return true; } - // jichi 12/26/2013: Add this after alicehook - if (Util::CheckFile(L"AliceStart.ini")) { - InsertSystem43Hook(); - return true; - } // Artikash 7/16/2018: Uses node/libuv: likely v8 - sample game https://vndb.org/v22975 //if (GetProcAddress(GetModuleHandleW(nullptr), "uv_uptime") || GetModuleHandleW(L"node.dll"))