From cebeb0d2278b3bb1defe531d9cd1630a7d22b60b Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sun, 13 Aug 2023 00:07:09 +0200 Subject: [PATCH 1/5] Bishop engine hook --- texthook/engine/engine.cc | 37 +++++++++++++++++++++++++++++++++++++ texthook/engine/engine.h | 1 + texthook/engine/match32.cc | 4 ++++ 3 files changed, 42 insertions(+) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c2c7abc..c833bfe 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21728,6 +21728,43 @@ bool InsertNamcoPS2Hook() } #endif // 0 +bool InsertBishopHook() +{ + //by Blu3train + /* + * Sample games: + * https://vndb.org/r49553 + */ + const BYTE bytes[] = { + 0xDD, 0x9E, XX4, // fstp qword ptr [esi+000001C8] + 0xC7, 0x86, XX4, XX4, // mov [esi+000001C0],00000000 + 0xE8, XX4, // call smie.exe+3170 + 0x5F, // pop edi + 0x5B, // pop ebx + 0x8B, 0xE5 // mov esp,ebp << hook here + }; + enum { addr_offset = sizeof(bytes) - 2 }; + + ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR); + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range); + if (!addr) { + ConsoleOutput("vnreng:Bishop: pattern not found"); + return false; + } + + HookParam hp = {}; + hp.address = addr + addr_offset; + hp.offset = pusha_ebx_off -4; + hp.index = 0; + hp.split = pusha_esp_off -4; + hp.split_index = 0; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT | USING_SPLIT; + hp.filter_fun = BishopFilter; + ConsoleOutput("vnreng: INSERT Bishop"); + NewHook(hp, "Bishop"); + return true; +} + } // namespace Engine // EOF diff --git a/texthook/engine/engine.h b/texthook/engine/engine.h index 5e167b2..2378437 100644 --- a/texthook/engine/engine.h +++ b/texthook/engine/engine.h @@ -156,6 +156,7 @@ bool InsertWillPlusHook(); // WillPlus: Rio.arc bool InsertWolfHook(); // Wolf: Data.wolf bool InsertYukaSystem2Hook(); // YukaSystem2: *.ykc bool InsertYurisHook(); // YU-RIS: *.ypf +bool InsertBishopHook(); // Bishop: *.bsa void InsertBrunsHook(); // Bruns: bruns.exe void InsertIronGameSystemHook();// IroneGameSystem: igs_sample.exe diff --git a/texthook/engine/match32.cc b/texthook/engine/match32.cc index fffc4c7..f49b5cd 100644 --- a/texthook/engine/match32.cc +++ b/texthook/engine/match32.cc @@ -370,6 +370,10 @@ bool DetermineEngineByFile3() bool DetermineEngineByFile4() { + if (Util::CheckFile(L"*.bsa")) { + if (InsertBishopHook()) + return true; + } if (Util::CheckFile(L"EAGLS.dll")) { // jichi 3/24/2014: E.A.G.L.S //ConsoleOutput("vnreng: IGNORE EAGLS"); InsertEaglsHook(); From fc3dd56113292132e4ef78d6f9b62582a66ca989 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sun, 13 Aug 2023 00:18:51 +0200 Subject: [PATCH 2/5] fixed Bishop engine hook --- texthook/engine/engine.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index c833bfe..36cf9b8 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21728,6 +21728,18 @@ bool InsertNamcoPS2Hook() } #endif // 0 +bool BishopFilter(LPVOID data, DWORD *size, HookParam *, BYTE) +{ + auto text = reinterpret_cast(data); + auto len = reinterpret_cast(size); + + WideStringCharReplacer(text, len, L"\\n", 2, L' '); + WideStringFilter(text, len, L"\\b", 2); + WideCharFilter(text, len, L'\xE000'); // heart symbol + + return true; +} + bool InsertBishopHook() { //by Blu3train From 52a9e2f0d482215ea3c39b938cc891f88895b057 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Sun, 20 Aug 2023 18:57:11 +0200 Subject: [PATCH 3/5] improved filter --- 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 36cf9b8..d5d815b 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21734,7 +21734,7 @@ bool BishopFilter(LPVOID data, DWORD *size, HookParam *, BYTE) auto len = reinterpret_cast(size); WideStringCharReplacer(text, len, L"\\n", 2, L' '); - WideStringFilter(text, len, L"\\b", 2); + WideStringFilter(text, len, L"\\", 2); // remove \ followed by 1 char WideCharFilter(text, len, L'\xE000'); // heart symbol return true; From f8e18ed44382859c27fd12191251f35eb58712d8 Mon Sep 17 00:00:00 2001 From: Blu3train Date: Tue, 22 Aug 2023 19:27:44 +0200 Subject: [PATCH 4/5] modified filter for win10 compatibility --- texthook/engine/engine.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index d5d815b..00172ba 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -21734,7 +21734,8 @@ bool BishopFilter(LPVOID data, DWORD *size, HookParam *, BYTE) auto len = reinterpret_cast(size); WideStringCharReplacer(text, len, L"\\n", 2, L' '); - WideStringFilter(text, len, L"\\", 2); // remove \ followed by 1 char + WideStringFilter(text, len, L"\\b", 2); + WideStringFilter(text, len, L"\\s", 2); WideCharFilter(text, len, L'\xE000'); // heart symbol return true; From 31ef17bfd6f45f082dcaba35f2fcc9cc4672c4cc Mon Sep 17 00:00:00 2001 From: Blu3train Date: Thu, 24 Aug 2023 23:17:34 +0200 Subject: [PATCH 5/5] fixed filter bug and reverse fron last win10 compatibility --- texthook/engine/engine.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 00172ba..663aabe 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -363,7 +363,7 @@ void WideStringCharReplacer(wchar_t *str, size_t *size, const wchar_t *src, size curlen = len - (cur - str); if (curlen == 0) break; - ::memmove(cur, cur + srclen, 2 * curlen); + ::memmove(cur, cur + srclen -1, 2 * curlen); } *size = len * 2; } @@ -21734,8 +21734,7 @@ bool BishopFilter(LPVOID data, DWORD *size, HookParam *, BYTE) auto len = reinterpret_cast(size); WideStringCharReplacer(text, len, L"\\n", 2, L' '); - WideStringFilter(text, len, L"\\b", 2); - WideStringFilter(text, len, L"\\s", 2); + WideStringFilter(text, len, L"\\", 2); // remove \ followed by 1 char WideCharFilter(text, len, L'\xE000'); // heart symbol return true; @@ -21747,6 +21746,20 @@ bool InsertBishopHook() /* * Sample games: * https://vndb.org/r49553 + * https://vndb.org/v38604 + * https://vndb.org/v16953 + * https://vndb.org/v33842 + * https://vndb.org/v29168 + * https://vndb.org/v22697 + * https://vndb.org/v27492 + * https://vndb.org/v26206 + * https://vndb.org/v21769 + * https://vndb.org/v24825 + * https://vndb.org/v31037 + * https://vndb.org/v20734 + * https://vndb.org/v19583 + * https://vndb.org/v18591 + * https://vndb.org/v16104 */ const BYTE bytes[] = { 0xDD, 0x9E, XX4, // fstp qword ptr [esi+000001C8]