From 2591a8c124b341aff13f17a70d2adba18be71ba4 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 24 May 2018 05:35:54 -0400 Subject: [PATCH] Revert "clean up hookman some more" This reverts commit 1fb66ddc04cec7b2d31bdab4b8992e61d0696a43. --- vnr/texthook/host/hookman.cc | 21 +++++++++++++++++++++ vnr/texthook/host/hookman.h | 12 ++++++++++++ vnr/texthook/host/textthread.cc | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/vnr/texthook/host/hookman.cc b/vnr/texthook/host/hookman.cc index aaa0110..93512b0 100644 --- a/vnr/texthook/host/hookman.cc +++ b/vnr/texthook/host/hookman.cc @@ -211,6 +211,8 @@ HookManager::~HookManager() TextThread *HookManager::FindSingle(DWORD number) { return (number & 0x80008000) ? nullptr : thread_table->FindThread(number); } +void HookManager::DetachProcess(DWORD pid) {} + void HookManager::SetCurrent(TextThread *it) { if (current) @@ -624,6 +626,25 @@ void HookManager::AddConsoleOutput(LPCWSTR text) } } +void HookManager::ClearText(DWORD pid, DWORD hook, DWORD retn, DWORD spl) +{ + HM_LOCK; + //bool flag=false; + //ConsoleOutput("vnrhost:ClearText: lock"); + //EnterCriticalSection(&hmcs); + ThreadParameter tp = {pid, hook, retn, spl}; + if (TreeNode *in = Search(&tp)) + if (TextThread *it = thread_table->FindThread(in->data)) { + it->Reset(); + //SetCurrent(it); + if (reset) + reset(it); + //it->ResetEditText(); + } + + //LeaveCriticalSection(&hmcs); + //ConsoleOutput("vnrhost:ClearText: unlock"); +} void HookManager::ClearCurrent() { HM_LOCK; diff --git a/vnr/texthook/host/hookman.h b/vnr/texthook/host/hookman.h index 94322f8..4d1b71c 100644 --- a/vnr/texthook/host/hookman.h +++ b/vnr/texthook/host/hookman.h @@ -57,12 +57,14 @@ public: void UnLink(WORD from); void UnLinkAll(WORD from); void SelectCurrent(DWORD num); + void DetachProcess(DWORD pid); void SetCurrent(TextThread *it); void AddConsoleOutput(LPCWSTR text); // jichi 10/27/2013: Add const; add space. void DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD split, int len, bool space); + void ClearText(DWORD pid, DWORD hook, DWORD retn, DWORD split); // private void RemoveProcessContext(DWORD pid); // private void RemoveSingleHook(DWORD pid, DWORD addr); void RegisterThread(TextThread*, DWORD); // private @@ -76,6 +78,9 @@ public: ConsoleCallback RegisterConsoleCallback(ConsoleCallback cf) { return (ConsoleCallback)_InterlockedExchange((long*)&console,(long)cf); } + ConsoleWCallback RegisterConsoleWCallback(ConsoleWCallback cf) + { return (ConsoleWCallback)_InterlockedExchange((long*)&wconsole,(long)cf); } + ThreadEventCallback RegisterThreadCreateCallback(ThreadEventCallback cf) { return (ThreadEventCallback)_InterlockedExchange((long*)&create,(long)cf); } @@ -102,6 +107,13 @@ public: ProcessRecord *Records() { return record; } // private ThreadTable *Table() { return thread_table; } // private + //DWORD& SplitTime() { return split_time; } + //DWORD& RepeatCount() { return repeat_count; } + //DWORD& CyclicRemove() { return cyclic_remove; } + //DWORD& GlobalFilter() { return global_filter; } + void ConsoleOutput(LPCSTR text) { if (console) console(text); } // not thread safe + void ConsoleOutputW(LPCWSTR text) { if (wconsole) wconsole(text); } // not thread safe + void OnThreadCreate(pugi::xml_node profile_node, TextThread* thread); void GetProfile(DWORD pid, pugi::xml_node profile_node); diff --git a/vnr/texthook/host/textthread.cc b/vnr/texthook/host/textthread.cc index 7ca9996..53fe518 100644 --- a/vnr/texthook/host/textthread.cc +++ b/vnr/texthook/host/textthread.cc @@ -558,7 +558,7 @@ DWORD TextThread::GetEntryString(LPSTR str, DWORD max) } else { len = ::sprintf(str, "%.4X:%.4d:0x%08X:0x%08X:0x%08X:", - thread_number, tp.pid, tp.hook, tp.retn, tp.spl); + thread_number, tp. pid, tp.hook, tp.retn, tp.spl); len += GetHookName(str + len, tp.pid, tp.hook, max - len); thread_string = new char[len + 1];