diff --git a/GUI/host/host.cc b/GUI/host/host.cc index 1f8bb64..e38d690 100644 --- a/GUI/host/host.cc +++ b/GUI/host/host.cc @@ -60,7 +60,7 @@ namespace if (textThreadsByParams[tp] == nullptr) { if (textThreadsByParams.size() > MAX_THREAD_COUNT) return Host::AddConsoleOutput(L"too many text threads: can't create more"); - OnCreate(textThreadsByParams[tp] = std::make_shared(tp)); + OnCreate(textThreadsByParams[tp] = std::make_shared(tp, Host::GetHookParam(tp), Host::GetHookName(tp))); } textThreadsByParams[tp]->AddText(text, len); } @@ -153,7 +153,7 @@ namespace Host void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove, TextThread::OutputCallback output) { OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnRemove = onRemove; TextThread::Output = output; - OnCreate(textThreadsByParams[CONSOLE] = std::make_shared(CONSOLE)); + OnCreate(textThreadsByParams[CONSOLE] = std::make_shared(CONSOLE, HookParam{}, L"Console")); StartPipe(); } @@ -238,14 +238,12 @@ namespace Host HookParam GetHookParam(DWORD processId, uint64_t addr) { - if (processId == 0) return {}; LOCK(hostMutex); return processRecordsByIds.at(processId)->GetHook(addr).hp; } std::wstring GetHookName(DWORD processId, uint64_t addr) { - if (processId == 0) return L"Console"; LOCK(hostMutex); return StringToWideString(processRecordsByIds.at(processId)->GetHook(addr).hookName, CP_UTF8); } @@ -256,7 +254,10 @@ namespace Host return textThreadsByParams[tp]; } - void AddConsoleOutput(std::wstring text) { GetThread(CONSOLE)->AddSentence(text); } + void AddConsoleOutput(std::wstring text) + { + GetThread(CONSOLE)->AddSentence(text); + } } // EOF diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index 095030c..a448d0f 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -8,7 +8,7 @@ #include #include -TextThread::TextThread(ThreadParam tp) : handle(threadCounter++), name(Host::GetHookName(tp)), tp(tp), hp(Host::GetHookParam(tp)) {} +TextThread::TextThread(ThreadParam tp, HookParam hp, std::wstring name) : handle(threadCounter++), name(name), tp(tp), hp(hp) {} TextThread::~TextThread() { diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 389f468..8cdbd89 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -19,7 +19,7 @@ public: inline static int maxBufferSize = 200; inline static int threadCounter = 0; - TextThread(ThreadParam tp); + TextThread(ThreadParam tp, HookParam hp, std::wstring name); ~TextThread(); std::wstring GetStorage();