From c2f85a1e6bec42e03697fb2658af833fca057fd1 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Fri, 22 Dec 2023 17:52:24 +0100 Subject: [PATCH 1/3] Waffle3 engine hook --- texthook/engine/engine.cc | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c2c7abc..278f8c0 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -5890,6 +5890,25 @@ bool InsertShinaHook() return false; } +bool Waffle3Filter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + static std::string prevText; + + 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); + + StringCharReplacer(text, len, "\r\n\x81\x40", 4, ' '); + StringCharReplacer(text, len, "\r\n", 2, ' '); + StringCharReplacer(text, len, "\x81\x40", 2, ' '); + + return true; +} bool InsertWaffleDynamicHook(LPVOID addr, DWORD frame, DWORD stack) { ConsoleOutput("WaffleDynamic:triggered"); @@ -6022,6 +6041,30 @@ bool InsertWaffleHook() NewHook(hp, "WAFFLE2"); found = true; } + //by Blu3train +/** new waffle3 +* test on https://vndb.org/v31003 +*/ + const BYTE bytes2[] = { + 0xCC, // int 3 + 0x55, // push ebp <- hook here + 0x8B, 0xEC, // mov ebp,esp + 0x8B, 0x55, 0x0C, // mov edx,[ebp+0C] + 0x53 // push ebx + }; + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + if (DWORD addr = MemDbg::findBytes(bytes2, sizeof(bytes2), processStartAddress, processStartAddress + range)) + { + HookParam hp = {}; + hp.address = addr + 1; + hp.offset = pusha_eax_off - 4; + hp.index = 0x00; + hp.filter_fun = Waffle3Filter; + hp.type = USING_STRING; + ConsoleOutput("Textractor: INSERT WAFFLE3"); + NewHook(hp, "WAFFLE3"); + found = true; + } //ConsoleOutput("Probably Waffle. Wait for text."); if (!found) trigger_fun = InsertWaffleDynamicHook; return found; From 70ee2e34fca195de79a4fcba61cedbf47691d600 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sat, 23 Dec 2023 11:37:59 +0100 Subject: [PATCH 2/3] filter bug fixed --- texthook/engine/engine.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 278f8c0..5e73c6e 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -5896,8 +5896,9 @@ bool Waffle3Filter(LPVOID data, DWORD *size, HookParam *, BYTE) auto len = reinterpret_cast(size); static std::string prevText; - if (cpp_strnstr(text, "\\", *len)) - return false; + if (LPSTR bs=cpp_strnstr(text, "\\", *len)) + if ( bs > text && *--bs >= 65 && *bs <= 122) // garbage text + return false; if (prevText.find(text, 0, *len) != std::string::npos) // Check if the string is present in the previous one return false; From e7a0227418075e67543e970fc9a38cbe7bca3740 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Fri, 2 Feb 2024 18:28:58 +0100 Subject: [PATCH 3/3] filter fixed --- texthook/engine/engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 5e73c6e..4f5a788 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -5897,7 +5897,7 @@ bool Waffle3Filter(LPVOID data, DWORD *size, HookParam *, BYTE) static std::string prevText; if (LPSTR bs=cpp_strnstr(text, "\\", *len)) - if ( bs > text && *--bs >= 65 && *bs <= 122) // garbage text + if (bs > text && !IsSJIS(text)) // garbage text return false; if (prevText.find(text, 0, *len) != std::string::npos) // Check if the string is present in the previous one