From 1b9febb4a526a8ff72bb917b2d367a3d1a4093cc Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 3 Aug 2018 14:07:11 -0400 Subject: [PATCH] bugfix/clean up engine --- vnrhook/src/hijack/texthook.cc | 20 -------------------- vnrhook/src/hijack/texthook.h | 5 +---- vnrhook/src/main.cc | 1 - vnrhook/src/util/util.cc | 10 ++++++++++ 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/vnrhook/src/hijack/texthook.cc b/vnrhook/src/hijack/texthook.cc index 16ff21e..6041830 100644 --- a/vnrhook/src/hijack/texthook.cc +++ b/vnrhook/src/hijack/texthook.cc @@ -640,26 +640,6 @@ int TextHook::UnsafeInsertHookCode() return 0; } -int TextHook::InitHook(LPVOID addr, DWORD data, DWORD data_ind, - DWORD split_off, DWORD split_ind, WORD type, DWORD len_off) -{ - WaitForSingleObject(hmMutex, 0); - hp.address = (DWORD)addr; - hp.offset = data; - hp.index = data_ind; - hp.split = split_off; - hp.split_index = split_ind; - hp.type = type; - hp.hook_len = 0; - hp.module = 0; - hp.length_offset = len_off & 0xffff; - currentHook++; - if (current_available >= this) - for (current_available = this + 1; current_available->Address(); current_available++); - ReleaseMutex(hmMutex); - return this - hookman; -} - int TextHook::InitHook(const HookParam &h, LPCSTR name, WORD set_flag) { WaitForSingleObject(hmMutex, 0); diff --git a/vnrhook/src/hijack/texthook.h b/vnrhook/src/hijack/texthook.h index a5a1013..bf66782 100644 --- a/vnrhook/src/hijack/texthook.h +++ b/vnrhook/src/hijack/texthook.h @@ -30,18 +30,15 @@ class TextHook : public Hook { int UnsafeInsertHookCode(); DWORD UnsafeSend(DWORD dwDataBase, DWORD dwRetn); + int RemoveHook(); public: int InsertHook(); int InsertHookCode(); int InitHook(const HookParam &hp, LPCSTR name = 0, WORD set_flag = 0); - 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 RemoveHook(); int ClearHook(); int SetHookName(LPCSTR name); int GetLength(DWORD base, DWORD in); // jichi 12/25/2013: Return 0 if failed - void CoolDown(); // jichi 9/28/2013: flush instruction cache on wine }; extern TextHook *hookman, diff --git a/vnrhook/src/main.cc b/vnrhook/src/main.cc index a97ec20..4d5f5a7 100644 --- a/vnrhook/src/main.cc +++ b/vnrhook/src/main.cc @@ -126,7 +126,6 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID unused) CloseHandle(pipeThread); } - for (TextHook *man = ::hookman; man->RemoveHook(); man++); for (TextHook *man = ::hookman; man < ::hookman + MAX_HOOK; man++) man->ClearHook(); //if (ith_has_section) diff --git a/vnrhook/src/util/util.cc b/vnrhook/src/util/util.cc index 9f04cde..a522b77 100644 --- a/vnrhook/src/util/util.cc +++ b/vnrhook/src/util/util.cc @@ -196,6 +196,16 @@ bool Util::CheckFile(LPCWSTR name) FindClose(file); return true; } + wchar_t path[MAX_PATH * 2]; + wchar_t* end = path + GetModuleFileNameW(nullptr, path, MAX_PATH); + while (*(--end) != L'\\'); + wcscpy(end + 1, name); + file = FindFirstFileW(path, &unused); + if (file != INVALID_HANDLE_VALUE) + { + FindClose(file); + return true; + } return false; }