From aeb0cafb1541e2e21d9816921853016b5af6ff48 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 23 Nov 2019 12:44:26 -0500 Subject: [PATCH] new cotopha hook --- include/types.h | 2 +- texthook/engine/engine.cc | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/types.h b/include/types.h index f983a0c..c8da53a 100644 --- a/include/types.h +++ b/include/types.h @@ -42,7 +42,7 @@ struct HookParam DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games void(*text_fun)(DWORD stack, HookParam* hp, BYTE obsoleteAlwaysZero, DWORD* data, DWORD* split, DWORD* len); - bool(*filter_fun)(void* data, DWORD* len, HookParam* hp, BYTE obsoleteAlwaysZero); // jichi 10/24/2014: Add filter function. Return true if skip the text + bool(*filter_fun)(void* data, DWORD* len, HookParam* hp, BYTE obsoleteAlwaysZero); // jichi 10/24/2014: Add filter function. Return false to skip the text bool(*hook_fun)(DWORD stack, HookParam* hp); // jichi 10/24/2014: Add generic hook function, return false if stop execution. int(*length_fun)(uintptr_t stack, uintptr_t data); // data after padding added diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 823768c..d32aeaa 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -6332,7 +6332,7 @@ static bool InsertYuris2Hook() bool InsertYurisHook() { return InsertYuris1Hook() || InsertYuris2Hook(); } -bool InsertCotophaHook() +bool InsertCotophaHook1() { enum : DWORD { ins = 0xec8b55 }; // mov ebp,esp, sub esp,* ; jichi 7/12/2014 ULONG addr = MemDbg::findCallerAddress((ULONG)::GetTextMetricsA, ins, processStartAddress, processStopAddress); @@ -6351,6 +6351,30 @@ bool InsertCotophaHook() return true; } +bool InsertCotophaHook2() +{ + if (void* addr = GetProcAddress(GetModuleHandleW(NULL), "eslHeapFree")) + { + HookParam hp = {}; + hp.address = (uintptr_t)addr; + hp.offset = 8; + hp.type = USING_UNICODE | USING_STRING; + hp.filter_fun = [](void* data, DWORD* len, HookParam*, BYTE) + { + return std::wstring_view((wchar_t*)data, *len / sizeof(wchar_t)).find(L'\\') != std::wstring_view::npos; + }; + ConsoleOutput("Textractor: INSERT Cotopha 2"); + NewHook(hp, "Cotopha2"); + return true; + } + return false; +} + +bool InsertCotophaHook() +{ + return InsertCotophaHook1() | InsertCotophaHook2(); +} + // jichi 5/10/2014 // See also: http://bbs.sumisora.org/read.php?tid=11044704&fpage=2 //