From 679317b5f558d453fdc3ea450ded17bf906137cc Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 23 Aug 2018 13:15:24 -0400 Subject: [PATCH] bugfixes --- host/host.cc | 2 +- vnrhook/hijack/texthook.cc | 6 +++--- vnrhook/main.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/host/host.cc b/host/host.cc index 96fd694..0ce63c1 100644 --- a/host/host.cc +++ b/host/host.cc @@ -19,7 +19,7 @@ struct ProcessRecord // Artikash 5/31/2018: required for unordered_map to work with struct key template <> struct std::hash { size_t operator()(const ThreadParam& tp) const { return std::hash<__int64>()((tp.pid + tp.hook) ^ (tp.retn + tp.spl)); } }; -bool operator==(const ThreadParam& one, const ThreadParam& two) { return memcmp(&one, &two, sizeof(ThreadParam)) == 0; } +bool operator==(const ThreadParam& one, const ThreadParam& two) { return one.pid == two.pid && one.hook == two.hook && one.retn == two.retn && one.spl == two.spl; } // Artikash 7/20/2018: similar to std::lock guard but use Winapi objects for cross process comms class MutexLocker diff --git a/vnrhook/hijack/texthook.cc b/vnrhook/hijack/texthook.cc index ad5725c..a74189b 100644 --- a/vnrhook/hijack/texthook.cc +++ b/vnrhook/hijack/texthook.cc @@ -448,12 +448,12 @@ DWORD WINAPI ReaderThread(LPVOID threadParam) TextHook* hook = (TextHook*)threadParam; BYTE buffer[PIPE_BUFFER_SIZE] = {}; unsigned int changeCount = 0; - int dataLen = 1; + int dataLen = 0; const char* currentAddress = (char*)hook->hp.address; while (true) { Sleep(500); - if (memcmp(buffer + sizeof(ThreadParam), currentAddress, dataLen) == 0) + if (memcmp(buffer + sizeof(ThreadParam), currentAddress, dataLen + 1) == 0) { changeCount = 0; continue; @@ -471,7 +471,7 @@ DWORD WINAPI ReaderThread(LPVOID threadParam) dataLen = strlen(currentAddress); *(ThreadParam*)buffer = { GetCurrentProcessId(), hook->hp.address, 0, 0 }; - memcpy(buffer + sizeof(ThreadParam), currentAddress, dataLen); + memcpy(buffer + sizeof(ThreadParam), currentAddress, dataLen + 1); DWORD unused; WriteFile(::hookPipe, buffer, dataLen + sizeof(ThreadParam), &unused, nullptr); } diff --git a/vnrhook/main.cc b/vnrhook/main.cc index 2adb010..399695b 100644 --- a/vnrhook/main.cc +++ b/vnrhook/main.cc @@ -66,7 +66,7 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID unused) { ::running = false; - for (TextHook *man = ::hookman; man < ::hookman + MAX_HOOK; man++) man->ClearHook(); + for (TextHook *man = ::hookman; man < ::hookman + MAX_HOOK; man++) if (man->Address()) man->ClearHook(); //if (ith_has_section) UnmapViewOfFile(::hookman);