From 4ce7425034b5b8ce0ae400bc52be1c64f48dfe24 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Wed, 26 Dec 2018 13:07:59 -0500 Subject: [PATCH] fix error spam --- vnrhook/engine/engine.cc | 8 -------- vnrhook/texthook.cc | 20 +++++++------------- vnrhook/texthook.h | 1 + 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/vnrhook/engine/engine.cc b/vnrhook/engine/engine.cc index 9abf6a1..c4e6ed4 100644 --- a/vnrhook/engine/engine.cc +++ b/vnrhook/engine/engine.cc @@ -4502,7 +4502,6 @@ bool InsertRUGP1Hook() */ bool InsertRUGP2Hook() { - DWORD low, high; if (!Util::CheckFile(L"vm60.dll") /*|| !SafeFillRange(L"vm60.dll", &low, &high)*/) { ConsoleOutput("vnreng:rUGP2: vm60.dll does not exist"); return false; @@ -8814,7 +8813,6 @@ bool InsertIGSDynamicHook(LPVOID addr, DWORD frame, DWORD stack) DWORD i; i = *(DWORD *)frame; i = *(DWORD *)(i+4); - DWORD j, k; //if (SafeFillRange(L"mscorlib.ni.dll", &j, &k)) { // Artikash 6/30/2018: Dunno why addresses are needed while (*(BYTE *)i != 0xe8) i++; @@ -16280,12 +16278,6 @@ bool InsertAIRNovelHook() hp.split = 0x4; hp.index = 0x8; hp.split_index = 0x4; - hp.text_fun = [](DWORD stack, auto, auto, DWORD* data, auto, DWORD* count) - { - DWORD string = *(DWORD*)(stack + 4); - *data = IsBadReadPtr((void*)string, 1) ? 0 : *(DWORD*)(string + 8); - *count = IsBadReadPtr((void*)*data, 1) ? 0 : wcslen((wchar_t*)*data) * 2; - }; //hp.filter_fun = [](void* str, DWORD* len, HookParam* hp, BYTE index) // removes some of the garbage threads //{ // return *len < 4 && diff --git a/vnrhook/texthook.cc b/vnrhook/texthook.cc index fadcf10..63170dc 100644 --- a/vnrhook/texthook.cc +++ b/vnrhook/texthook.cc @@ -111,11 +111,11 @@ bool TextHook::Insert(HookParam h, DWORD set_flag) // jichi 5/11/2014: // - dwDataBase: the stack address -#ifndef _WIN64 void TextHook::Send(uintptr_t dwDataBase) { __try { +#ifndef _WIN64 DWORD dwCount = 0, dwSplit = 0, dwDataIn = *(DWORD*)(dwDataBase + hp.offset), // default values @@ -156,17 +156,7 @@ void TextHook::Send(uintptr_t dwDataBase) if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) dwRetn = 0; TextOutput({ GetCurrentProcessId(), address, dwRetn, dwSplit }, pbData, dwCount); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - ConsoleOutput("Textractor: Send ERROR (likely an incorrect H-code)"); - } -} #else // _WIN32 -void TextHook::Send(uintptr_t dwDataBase) -{ - __try - { int count = 0; ThreadParam tp = { GetCurrentProcessId(), address, *(uintptr_t*)dwDataBase, 0 }; // first value on stack (if hooked start of function, this is return address) uintptr_t data = *(uintptr_t*)(dwDataBase + hp.offset); // default value @@ -193,13 +183,17 @@ void TextHook::Send(uintptr_t dwDataBase) if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) tp.ctx = 0; TextOutput(tp, pbData, count); +#endif // _WIN64 } __except (EXCEPTION_EXECUTE_HANDLER) { - ConsoleOutput("Textractor: Send ERROR (likely an incorrect H-code)"); + if (!err) + { + ConsoleOutput("Textractor: Send ERROR (likely an incorrect H-code)"); + err = true; + } } } -#endif // _WIN64 bool TextHook::InsertHookCode() { diff --git a/vnrhook/texthook.h b/vnrhook/texthook.h index e5f2690..2295a5a 100644 --- a/vnrhook/texthook.h +++ b/vnrhook/texthook.h @@ -38,6 +38,7 @@ private: void RemoveReadCode(); HANDLE readerThread, readerEvent; + bool err; BYTE trampoline[130]; };