From 55764bf8e2171d02eb2ceb3f2c50cfd5c20b00b7 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 19 Jul 2018 02:02:42 -0400 Subject: [PATCH] more bugfixing --- vnr/texthook/hookman.cc | 7 +++---- vnr/vnrhook/src/engine/match.cc | 3 +++ vnr/vnrhook/src/hijack/texthook.cc | 11 ----------- vnr/vnrhook/src/hijack/texthook.h | 1 - vnr/vnrhook/src/pipe.cc | 18 +----------------- 5 files changed, 7 insertions(+), 33 deletions(-) diff --git a/vnr/texthook/hookman.cc b/vnr/texthook/hookman.cc index 19cd2aa..13dd418 100644 --- a/vnr/texthook/hookman.cc +++ b/vnr/texthook/hookman.cc @@ -18,7 +18,6 @@ #define HM_LOCK CriticalSectionLocker hmLocker(hmCs) // Synchronized scope for accessing private data HookManager::HookManager() : - current(nullptr), create(nullptr), remove(nullptr), reset(nullptr), @@ -30,9 +29,9 @@ HookManager::HookManager() : { InitializeCriticalSection(&hmCs); - TextThread* consoleTextThread = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay); - consoleTextThread->Status() |= USING_UNICODE; - SetCurrent(consoleTextThread); + // Console text thread + current = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay); + current->Status() |= USING_UNICODE | CURRENT_SELECT; } HookManager::~HookManager() diff --git a/vnr/vnrhook/src/engine/match.cc b/vnr/vnrhook/src/engine/match.cc index 5bbb318..917d17a 100644 --- a/vnr/vnrhook/src/engine/match.cc +++ b/vnr/vnrhook/src/engine/match.cc @@ -879,10 +879,13 @@ DWORD InsertDynamicHook(LPVOID addr, DWORD frame, DWORD stack) void Hijack() { + static bool hijacked = false; + if (hijacked) return; GetModuleFileNameW(nullptr, processPath, MAX_PATH); processName = wcsrchr(processPath, L'\\') + 1; DetermineEngineType(); + hijacked = true; } } // namespace Engine diff --git a/vnr/vnrhook/src/hijack/texthook.cc b/vnr/vnrhook/src/hijack/texthook.cc index ea1302f..c0177ac 100644 --- a/vnr/vnrhook/src/hijack/texthook.cc +++ b/vnr/vnrhook/src/hijack/texthook.cc @@ -728,17 +728,6 @@ int TextHook::ClearHook() return err; } -int TextHook::RecoverHook() -{ - if (hp.address) { - // jichi 9/28/2013: Only enable TextOutA to debug Cross Channel - //if (hp.address == (DWORD)TextOutA) - InsertHook(); - return 1; - } - return 0; -} - int TextHook::SetHookName(LPCSTR name) { name_length = strlen(name) + 1; diff --git a/vnr/vnrhook/src/hijack/texthook.h b/vnr/vnrhook/src/hijack/texthook.h index 4fa9be1..a5a1013 100644 --- a/vnr/vnrhook/src/hijack/texthook.h +++ b/vnr/vnrhook/src/hijack/texthook.h @@ -37,7 +37,6 @@ public: int InitHook(LPVOID addr, DWORD data, DWORD data_ind, DWORD split_off, DWORD split_ind, WORD type, DWORD len_off = 0); DWORD Send(DWORD dwDataBase, DWORD dwRetn); - int RecoverHook(); int RemoveHook(); int ClearHook(); int SetHookName(LPCSTR name); diff --git a/vnr/vnrhook/src/pipe.cc b/vnr/vnrhook/src/pipe.cc index 32d1324..de7be82 100644 --- a/vnr/vnrhook/src/pipe.cc +++ b/vnr/vnrhook/src/pipe.cc @@ -45,19 +45,11 @@ DWORD WINAPI PipeManager(LPVOID unused) *(DWORD*)buffer = GetCurrentProcessId(); WriteFile(::hookPipe, buffer, sizeof(DWORD), &count, nullptr); - for (int i = 0, count = 0; count < ::currentHook; i++) - { - if (hookman[i].RecoverHook()) // jichi 9/27/2013: This is the place where built-in hooks like TextOutA are inserted - { - count++; - } - } - ReleaseMutex(pipeAcquisitionMutex); CloseHandle(pipeAcquisitionMutex); - Engine::Hijack(); ConsoleOutput("vnrcli:WaitForPipe: pipe connected"); + Engine::Hijack(); while (::running) { @@ -104,14 +96,6 @@ DWORD WINAPI PipeManager(LPVOID unused) } CloseHandle(::hookPipe); CloseHandle(hostPipe); - - for (int i = 0, count = 0; count < ::currentHook; i++) - { - if (hookman[i].RemoveHook()) - { - count++; - } - } } FreeLibraryAndExitThread(::currentModule, 0); return 0;