From 4570708c2dd9a8a22406ce988b6228917504085c Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sat, 28 Oct 2023 11:20:53 +0200 Subject: [PATCH] New NeXAS engine hook --- texthook/engine/engine.cc | 57 ++++++++++++++++++++++++++++++++++++++ texthook/engine/engine.h | 2 +- texthook/engine/match32.cc | 2 +- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c2c7abc..c7bb867 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -13209,6 +13209,63 @@ bool InsertNeXASHook() return true; } +bool NeXAS2Filter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + static std::string prevText; + + StringCharReplacer(text, len, "@n", 2, ' '); + StringFilter(text, len, "@v", 7); // remove "@v" followed by 5 char + StringFilter(text, len, "@p", 2); + StringFilter(text, len, "@k", 2); + if (cpp_strnstr(text, "@", *len)) + return false; + + if (prevText.find(text, 0, *len) != std::string::npos) // Check if the string is present in the previous one + return false; + prevText.assign(text, *len); + + return true; +} + +bool InsertNeXAS2Hook() { + //by Blu3train + /* + * Sample games: + * https://vndb.org/r113353 + */ + const BYTE bytes[] = { + 0x50, // push eax <- hook here + 0xE8, XX4, // call Aquarium.exe+2796B0 + 0x8B, 0x86, XX4, // mov eax,[esi+000000A4] + 0x8B, 0x40, 0xFC // mov eax,[eax-04] + }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:NeXAS2: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr; + hp.offset = pusha_eax_off -4; + hp.index = 0; + hp.split = pusha_edx_off -4; + hp.split_index = 0; + hp.type = USING_STRING | USING_UTF8 | USING_SPLIT; + hp.filter_fun = NeXAS2Filter; + ConsoleOutput("vnreng: INSERT NeXAS2"); + NewHook(hp, "NeXAS2"); + + return true; +} + +bool InsertNeXASHooks() +{ return InsertNeXASHook() || InsertNeXAS2Hook();} + /** jichi 7/6/2014 YukaSystem2 * Sample game: セミラミスの天秤 * diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 5e167b2..2839635 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -121,7 +121,7 @@ bool InsertMEDHook(); // MED: *.med bool InsertMinkHook(); // Mink: *.at2 //bool InsertMonoHook(); // Mono (Unity3D): */Mono/mono.dll bool InsertNekopackHook(); // Nekopack: *.dat -bool InsertNeXASHook(); // NeXAS: Thumbnail.pac +bool InsertNeXASHooks(); // NeXAS: Thumbnail.pac bool InsertNextonHook(); // NEXTON: aInfo.db bool InsertNexton1Hook(); bool InsertNitroplusHook(); // Nitroplus: *.npa diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index fffc4c7..3315739 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -221,7 +221,7 @@ bool DetermineEngineByFile1() if (Util::CheckFile(L"Thumbnail.pac")) { //ConsoleOutput("vnreng: IGNORE NeXAS"); - InsertNeXASHook(); // jichi 7/6/2014: GIGA + InsertNeXASHooks(); // jichi 7/6/2014: GIGA return true; }