From 389db72dd20fc5a5997690f89ec923cb2e8d0e87 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 23 Aug 2018 12:18:03 -0400 Subject: [PATCH] bugfixes --- host/host.cc | 10 +++++----- host/host.h | 6 +++--- vnrhook/main.cc | 2 +- vnrhook/main.h | 5 ++--- vnrhook/pipe.cc | 7 ++++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/host/host.cc b/host/host.cc index 68e6574..96fd694 100644 --- a/host/host.cc +++ b/host/host.cc @@ -124,13 +124,13 @@ namespace Host return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); } - DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr) + DLLEXPORT bool RemoveHook(DWORD pid, unsigned __int64 addr) { auto info = RemoveHookCmd(addr); return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); } - DLLEXPORT HookParam GetHookParam(DWORD pid, DWORD addr) + DLLEXPORT HookParam GetHookParam(DWORD pid, unsigned __int64 addr) { HOST_LOCK; HookParam ret = {}; @@ -139,14 +139,14 @@ namespace Host MutexLocker locker(pr.sectionMutex); const TextHook* hooks = (const TextHook*)pr.sectionMap; for (int i = 0; i < MAX_HOOK; ++i) - if ((DWORD)hooks[i].Address() == addr) + if (hooks[i].Address() == addr) ret = hooks[i].hp; return ret; } DLLEXPORT HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); } - DLLEXPORT std::wstring GetHookName(DWORD pid, DWORD addr) + DLLEXPORT std::wstring GetHookName(DWORD pid, unsigned __int64 addr) { if (pid == 0) return L"Console"; HOST_LOCK; @@ -156,7 +156,7 @@ namespace Host MutexLocker locker(pr.sectionMutex); const TextHook* hooks = (const TextHook*)pr.sectionMap; for (int i = 0; i < MAX_HOOK; ++i) - if ((DWORD)hooks[i].Address() == addr) + if (hooks[i].Address() == addr) { buffer.resize(hooks[i].NameLength()); ReadProcessMemory(pr.processHandle, hooks[i].Name(), &buffer[0], hooks[i].NameLength(), nullptr); diff --git a/host/host.h b/host/host.h index 8113447..7cdacc5 100644 --- a/host/host.h +++ b/host/host.h @@ -20,10 +20,10 @@ namespace Host DLLEXPORT bool DetachProcess(DWORD pid); DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = ""); - DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr); - DLLEXPORT HookParam GetHookParam(DWORD pid, DWORD addr); + DLLEXPORT bool RemoveHook(DWORD pid, unsigned __int64 addr); + DLLEXPORT HookParam GetHookParam(DWORD pid, unsigned __int64 addr); DLLEXPORT HookParam GetHookParam(ThreadParam tp); - DLLEXPORT std::wstring GetHookName(DWORD pid, DWORD addr); + DLLEXPORT std::wstring GetHookName(DWORD pid, unsigned __int64 addr); DLLEXPORT TextThread* GetThread(ThreadParam tp); DLLEXPORT void AddConsoleOutput(std::wstring text); diff --git a/vnrhook/main.cc b/vnrhook/main.cc index d60b8ad..2adb010 100644 --- a/vnrhook/main.cc +++ b/vnrhook/main.cc @@ -109,7 +109,7 @@ DWORD NewHook(const HookParam &hp, LPCSTR lpname, DWORD flag) } return 0; } -DWORD RemoveHook(DWORD addr) +DWORD RemoveHook(unsigned __int64 addr) { for (int i = 0; i < MAX_HOOK; i++) if (::hookman[i].Address() == addr) { diff --git a/vnrhook/main.h b/vnrhook/main.h index 7593de5..895f239 100644 --- a/vnrhook/main.h +++ b/vnrhook/main.h @@ -9,11 +9,10 @@ void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text void NotifyHookInsert(HookParam hp, LPCSTR name); -void NotifyHookRemove(DWORD addr); +void NotifyHookRemove(unsigned __int64 addr); DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE); -DWORD RemoveHook(DWORD addr); +DWORD RemoveHook(unsigned __int64 addr); DWORD SwitchTrigger(DWORD on); -DWORD GetFunctionAddr(const char *name, DWORD *addr, DWORD *base, DWORD *size, LPWSTR *base_name); // 10/14/2014 jichi: disable GDI hooks void EnableGDIHooks(); diff --git a/vnrhook/pipe.cc b/vnrhook/pipe.cc index 73d1e2c..ba08cd6 100644 --- a/vnrhook/pipe.cc +++ b/vnrhook/pipe.cc @@ -21,7 +21,7 @@ DWORD DUMMY[100]; void CreatePipe() { - std::thread([]() + CreateThread(nullptr, 0, [](LPVOID unused) { enum { STANDARD_WAIT = 50 }; while (::running) @@ -86,7 +86,8 @@ void CreatePipe() CloseHandle(hostPipe); } FreeLibraryAndExitThread(GetModuleHandleW(ITH_DLL), 0); - }).detach(); + return (DWORD)0; + }, nullptr, 0, nullptr); } void ConsoleOutput(LPCSTR text) @@ -107,7 +108,7 @@ void NotifyHookInsert(HookParam hp, LPCSTR name) //return; } -void NotifyHookRemove(DWORD addr) +void NotifyHookRemove(unsigned __int64 addr) { auto info = HookRemovedNotif(addr); WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr);