From fe552f6e19c73300a843126a70414aaf2a5e56ff Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 24 May 2018 05:35:50 -0400 Subject: [PATCH] Revert "remove unused code" This reverts commit b3496222ec1b24df40365d77e8ea6c902873cbc1. --- gui/utility.cpp | 9 +++++++++ gui/window.cpp | 1 + vnr/texthook/host/hookman.h | 24 +++--------------------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/gui/utility.cpp b/gui/utility.cpp index 402c446..2c47320 100644 --- a/gui/utility.cpp +++ b/gui/utility.cpp @@ -36,6 +36,15 @@ void ConsoleOutput(LPCWSTR text) man->AddConsoleOutput(text); } +void ConsoleOutput(LPCSTR text) +{ + int wc_length = MB_WC_count(text, -1); + LPWSTR wc = new WCHAR[wc_length]; + MB_WC(text, wc, wc_length); + man->AddConsoleOutput(wc); + delete wc; +} + std::wstring GetProcessPath(DWORD pid) { UniqueHandle hProc(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); diff --git a/gui/window.cpp b/gui/window.cpp index c744e9c..ab349b1 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -752,6 +752,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) man->RegisterProcessDetachCallback(RemoveProcessList); man->RegisterProcessNewHookCallback(RefreshProfileOnNewHook); man->RegisterAddRemoveLinkCallback(AddRemoveLink); + man->RegisterConsoleCallback(ConsoleOutput); StartHost(); { static const WCHAR program_name[] = L"Interactive Text Hooker"; diff --git a/vnr/texthook/host/hookman.h b/vnr/texthook/host/hookman.h index d88b9c5..94322f8 100644 --- a/vnr/texthook/host/hookman.h +++ b/vnr/texthook/host/hookman.h @@ -7,7 +7,6 @@ #include "host/avl_p.h" #include "host/textthread.h" #include "winmutex/winmutex.h" -#include namespace pugi { class xml_node; @@ -26,9 +25,6 @@ struct ProcessRecord { HANDLE hookman_mutex; HANDLE hookman_section; LPVOID hookman_map; - HANDLE hostPipe; - HANDLE hookPipe; - HANDLE processThread; }; class ThreadTable : public MyVector @@ -44,19 +40,6 @@ struct IHFSERVICE TLen { int operator()(const ThreadParameter *t); }; typedef DWORD (*ProcessEventCallback)(DWORD pid); -struct ThreadParameterHasher -{ - size_t operator()(const ThreadParameter& threadParam) const - { - return std::hash()((threadParam.pid << 4) + threadParam.hook + threadParam.retn + threadParam.spl); - } -}; - -//bool operator==(const ThreadParameter& one, const ThreadParameter& two) -//{ -// return one.pid == two.pid && one.hook == two.hook && one.retn == two.retn && one.spl == two.spl; -//} - class IHFSERVICE HookManager : public AVLTree { public: @@ -90,6 +73,9 @@ public: HANDLE GetCmdHandleByPID(DWORD pid); + ConsoleCallback RegisterConsoleCallback(ConsoleCallback cf) + { return (ConsoleCallback)_InterlockedExchange((long*)&console,(long)cf); } + ThreadEventCallback RegisterThreadCreateCallback(ThreadEventCallback cf) { return (ThreadEventCallback)_InterlockedExchange((long*)&create,(long)cf); } @@ -120,10 +106,6 @@ public: void GetProfile(DWORD pid, pugi::xml_node profile_node); private: - std::unordered_map processRecords; - std::unordered_map threadTable; - - typedef win_mutex mutex_type; mutex_type hmcs;