From 8fb762e2bcd11b74f404053dce9c8c7048d25916 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sun, 30 Jul 2023 11:45:18 +0200 Subject: [PATCH] CatSystem2 engine hook --- texthook/engine/engine.cc | 39 ++++++++++++++++++++++++++++++++++++++ texthook/engine/engine.h | 2 +- texthook/engine/match32.cc | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c2c7abc..04cf4d4 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -6586,6 +6586,45 @@ bool InsertCatSystemHook() return true; } +bool InsertCatSystem2Hook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/v26987 + */ + const BYTE bytes[] = { + 0x38, 0x08, // cmp [eax],cl + 0x0F, 0x84, XX4, // je cs2.exe+23E490 + 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, XX4, // nop word ptr [eax+eax+00000000] + 0x4F, // dec edi + 0xC7, 0x85, XX4, XX4, // mov [ebp-000005A0],00000000 + 0x33, 0xF6, // xor esi,esi + 0xC7, 0x85, XX4, XX4, // mov [ebp-0000057C],00000000 + 0x85, 0xFF // test edi,edi + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:CatSystem2new: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr; + hp.offset = pusha_eax_off -4; + hp.index = 0; + hp.codepage = 65001; + hp.type = USING_STRING; + ConsoleOutput("vnreng: INSERT CatSystem2new"); + NewHook(hp, "CatSystem2new"); + return true; +} + +bool InsertCatSystemHooks() +{return InsertCatSystemHook() || InsertCatSystem2Hook();} + bool InsertNitroplusHook() { const BYTE bytes[] = {0xb0, 0x74, 0x53}; diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 5e167b2..4a9bede 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -93,7 +93,7 @@ bool InsertBootupHook(); // Bootup: Bootup.dat bool InsertC4Hook(); // C4: C4.EXE or XEX.EXE bool InsertCaramelBoxHook(); // Caramel: *.bin bool InsertCandyHook(); // SystemC@CandySoft: *.fpk -bool InsertCatSystemHook(); // CatSystem2: *.int +bool InsertCatSystemHooks(); // CatSystem2: *.int bool InsertCMVSHook(); // CMVS: data/pack/*.cpz; do not support the latest cmvs32.exe and cmvs64.exe bool InsertCotophaHook(); // Cotopha: *.noa bool InsertDebonosuHook(); // Debonosu: bmp.bak and dsetup.dll diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index fffc4c7..17428c2 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -192,7 +192,7 @@ bool DetermineEngineByFile1() InsertArtemisHook(); return true; } - if (Util::CheckFile(L"*.int") && InsertCatSystemHook()) { + if (Util::CheckFile(L"*.int") && InsertCatSystemHooks()) { return true; } if (Util::CheckFile(L"message.dat")) {