diff --git a/texthook/hookman.cc b/texthook/hookman.cc index ea0ec1b..2571940 100644 --- a/texthook/hookman.cc +++ b/texthook/hookman.cc @@ -20,7 +20,6 @@ HookManager::HookManager() : create(nullptr), remove(nullptr), - reset(nullptr), attach(nullptr), detach(nullptr), nextThreadNumber(0), @@ -31,8 +30,7 @@ HookManager::HookManager() : InitializeCriticalSection(&hmCs); // Console text thread - current = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay); - current->Status() |= USING_UNICODE | CURRENT_SELECT; + (textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay))->Status() |= USING_UNICODE; } HookManager::~HookManager() @@ -50,25 +48,6 @@ TextThread *HookManager::FindSingle(DWORD number) return nullptr; } -void HookManager::SetCurrent(TextThread *it) -{ - HM_LOCK; - if (it == nullptr) return; - current->Status() &= ~CURRENT_SELECT; - current = it; - it->Status() |= CURRENT_SELECT; -} - -void HookManager::SelectCurrent(DWORD num) -{ - HM_LOCK; - if (TextThread *st = FindSingle(num)) - { - SetCurrent(st); - if (reset) reset(st); - } -} - void HookManager::RemoveSingleHook(DWORD pid, DWORD addr) { HM_LOCK; @@ -81,7 +60,6 @@ void HookManager::RemoveSingleHook(DWORD pid, DWORD addr) removedThreads.push_back(i.first); } for (auto i : removedThreads) textThreadsByParams.erase(i); - SelectCurrent(0); } void HookManager::RemoveProcessContext(DWORD pid) @@ -96,7 +74,6 @@ void HookManager::RemoveProcessContext(DWORD pid) removedThreads.push_back(i.first); } for (auto i : removedThreads) textThreadsByParams.erase(i); - SelectCurrent(0); } void HookManager::RegisterProcess(DWORD pid, HANDLE hostPipe) @@ -136,6 +113,7 @@ void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, con if ((it = textThreadsByParams[tp]) == nullptr) { it = textThreadsByParams[tp] = new TextThread(tp, nextThreadNumber++, splitDelay); + if (GetHookParam(pid, hook).type & USING_UNICODE) it->Status() |= USING_UNICODE; if (create) create(it); } it->AddText(text, len); @@ -148,13 +126,6 @@ void HookManager::AddConsoleOutput(std::wstring text) console->AddSentence(std::wstring(text)); } -void HookManager::ClearCurrent() -{ - HM_LOCK; - current->Reset(); - if (reset) reset(current); -} - HANDLE HookManager::GetHostPipe(DWORD pid) { HM_LOCK; diff --git a/texthook/hookman.h b/texthook/hookman.h index 8b8dbfd..c5e939a 100644 --- a/texthook/hookman.h +++ b/texthook/hookman.h @@ -39,9 +39,6 @@ public: TextThread *FindSingle(DWORD number); HANDLE GetHostPipe(DWORD pid); - void ClearCurrent(); - void SelectCurrent(DWORD num); - void SetCurrent(TextThread *it); void AddConsoleOutput(std::wstring text); void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len); void RemoveProcessContext(DWORD pid); // private @@ -53,7 +50,6 @@ public: void RegisterThreadCreateCallback(ThreadEventCallback cf) { create = cf; } void RegisterThreadRemoveCallback(ThreadEventCallback cf) { remove = cf; } - void RegisterThreadResetCallback(ThreadEventCallback cf) { reset = cf; } void RegisterProcessAttachCallback(ProcessEventCallback cf) { attach = cf; } void RegisterProcessDetachCallback(ProcessEventCallback cf) { detach = cf; } @@ -65,9 +61,7 @@ private: CRITICAL_SECTION hmCs; - TextThread *current; - - ThreadEventCallback create, remove, reset; + ThreadEventCallback create, remove; ProcessEventCallback attach, detach; WORD nextThreadNumber;