remove unneeded logic from host

This commit is contained in:
Akash Mozumdar 2018-07-21 14:16:26 -07:00
parent 4aef775a6a
commit a4eede1b4e
2 changed files with 3 additions and 38 deletions

View File

@ -20,7 +20,6 @@
HookManager::HookManager() : HookManager::HookManager() :
create(nullptr), create(nullptr),
remove(nullptr), remove(nullptr),
reset(nullptr),
attach(nullptr), attach(nullptr),
detach(nullptr), detach(nullptr),
nextThreadNumber(0), nextThreadNumber(0),
@ -31,8 +30,7 @@ HookManager::HookManager() :
InitializeCriticalSection(&hmCs); InitializeCriticalSection(&hmCs);
// Console text thread // Console text thread
current = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay); (textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay))->Status() |= USING_UNICODE;
current->Status() |= USING_UNICODE | CURRENT_SELECT;
} }
HookManager::~HookManager() HookManager::~HookManager()
@ -50,25 +48,6 @@ TextThread *HookManager::FindSingle(DWORD number)
return nullptr; 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) void HookManager::RemoveSingleHook(DWORD pid, DWORD addr)
{ {
HM_LOCK; HM_LOCK;
@ -81,7 +60,6 @@ void HookManager::RemoveSingleHook(DWORD pid, DWORD addr)
removedThreads.push_back(i.first); removedThreads.push_back(i.first);
} }
for (auto i : removedThreads) textThreadsByParams.erase(i); for (auto i : removedThreads) textThreadsByParams.erase(i);
SelectCurrent(0);
} }
void HookManager::RemoveProcessContext(DWORD pid) void HookManager::RemoveProcessContext(DWORD pid)
@ -96,7 +74,6 @@ void HookManager::RemoveProcessContext(DWORD pid)
removedThreads.push_back(i.first); removedThreads.push_back(i.first);
} }
for (auto i : removedThreads) textThreadsByParams.erase(i); for (auto i : removedThreads) textThreadsByParams.erase(i);
SelectCurrent(0);
} }
void HookManager::RegisterProcess(DWORD pid, HANDLE hostPipe) 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) if ((it = textThreadsByParams[tp]) == nullptr)
{ {
it = textThreadsByParams[tp] = new TextThread(tp, nextThreadNumber++, splitDelay); it = textThreadsByParams[tp] = new TextThread(tp, nextThreadNumber++, splitDelay);
if (GetHookParam(pid, hook).type & USING_UNICODE) it->Status() |= USING_UNICODE;
if (create) create(it); if (create) create(it);
} }
it->AddText(text, len); it->AddText(text, len);
@ -148,13 +126,6 @@ void HookManager::AddConsoleOutput(std::wstring text)
console->AddSentence(std::wstring(text)); console->AddSentence(std::wstring(text));
} }
void HookManager::ClearCurrent()
{
HM_LOCK;
current->Reset();
if (reset) reset(current);
}
HANDLE HookManager::GetHostPipe(DWORD pid) HANDLE HookManager::GetHostPipe(DWORD pid)
{ {
HM_LOCK; HM_LOCK;

View File

@ -39,9 +39,6 @@ public:
TextThread *FindSingle(DWORD number); TextThread *FindSingle(DWORD number);
HANDLE GetHostPipe(DWORD pid); HANDLE GetHostPipe(DWORD pid);
void ClearCurrent();
void SelectCurrent(DWORD num);
void SetCurrent(TextThread *it);
void AddConsoleOutput(std::wstring text); void AddConsoleOutput(std::wstring text);
void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len); void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len);
void RemoveProcessContext(DWORD pid); // private void RemoveProcessContext(DWORD pid); // private
@ -53,7 +50,6 @@ public:
void RegisterThreadCreateCallback(ThreadEventCallback cf) { create = cf; } void RegisterThreadCreateCallback(ThreadEventCallback cf) { create = cf; }
void RegisterThreadRemoveCallback(ThreadEventCallback cf) { remove = cf; } void RegisterThreadRemoveCallback(ThreadEventCallback cf) { remove = cf; }
void RegisterThreadResetCallback(ThreadEventCallback cf) { reset = cf; }
void RegisterProcessAttachCallback(ProcessEventCallback cf) { attach = cf; } void RegisterProcessAttachCallback(ProcessEventCallback cf) { attach = cf; }
void RegisterProcessDetachCallback(ProcessEventCallback cf) { detach = cf; } void RegisterProcessDetachCallback(ProcessEventCallback cf) { detach = cf; }
@ -65,9 +61,7 @@ private:
CRITICAL_SECTION hmCs; CRITICAL_SECTION hmCs;
TextThread *current; ThreadEventCallback create, remove;
ThreadEventCallback create, remove, reset;
ProcessEventCallback attach, detach; ProcessEventCallback attach, detach;
WORD nextThreadNumber; WORD nextThreadNumber;