diff --git a/gui/utility.cpp b/gui/utility.cpp index 2c47320..402c446 100644 --- a/gui/utility.cpp +++ b/gui/utility.cpp @@ -36,15 +36,6 @@ 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 ab349b1..c744e9c 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -752,7 +752,6 @@ 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 94322f8..d88b9c5 100644 --- a/vnr/texthook/host/hookman.h +++ b/vnr/texthook/host/hookman.h @@ -7,6 +7,7 @@ #include "host/avl_p.h" #include "host/textthread.h" #include "winmutex/winmutex.h" +#include namespace pugi { class xml_node; @@ -25,6 +26,9 @@ struct ProcessRecord { HANDLE hookman_mutex; HANDLE hookman_section; LPVOID hookman_map; + HANDLE hostPipe; + HANDLE hookPipe; + HANDLE processThread; }; class ThreadTable : public MyVector @@ -40,6 +44,19 @@ 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: @@ -73,9 +90,6 @@ 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); } @@ -106,6 +120,10 @@ 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;