diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index 1eedf3c..40bd57e 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -54,7 +54,7 @@ namespace }; ThreadSafePtr>> textThreadsByParams; - ThreadSafePtr>> processRecordsByIds; + ThreadSafePtr> processRecordsByIds; ThreadParam CONSOLE{ 0, -1ULL, -1ULL, -1ULL }, CLIPBOARD{ 0, 0, -1ULL, -1ULL }; @@ -82,7 +82,7 @@ namespace BYTE buffer[PIPE_BUFFER_SIZE] = {}; DWORD bytesRead, processId; ReadFile(hookPipe, &processId, sizeof(processId), &bytesRead, nullptr); - processRecordsByIds->insert({ processId, std::make_unique(processId, hostPipe) }); + processRecordsByIds->try_emplace(processId, processId, hostPipe); CreatePipe(); @@ -136,7 +136,7 @@ namespace Host TextThread::OnCreate = OnCreate; TextThread::OnDestroy = OnDestroy; TextThread::Output = Output; - processRecordsByIds->insert({ CONSOLE.processId, std::make_unique(CONSOLE.processId, INVALID_HANDLE_VALUE) }); + processRecordsByIds->try_emplace(CONSOLE.processId, CONSOLE.processId, INVALID_HANDLE_VALUE); textThreadsByParams->insert({ CONSOLE, std::make_shared(CONSOLE, HookParam{}, L"Console") }); textThreadsByParams->insert({ CLIPBOARD, std::make_shared(CLIPBOARD, HookParam{}, L"Clipboard") }); StartCapturingClipboard(); @@ -187,17 +187,17 @@ namespace Host void DetachProcess(DWORD processId) { - processRecordsByIds->at(processId)->Send(HostCommandType(HOST_COMMAND_DETACH)); + processRecordsByIds->at(processId).Send(HostCommandType(HOST_COMMAND_DETACH)); } void InsertHook(DWORD processId, HookParam hp) { - processRecordsByIds->at(processId)->Send(InsertHookCmd(hp)); + processRecordsByIds->at(processId).Send(InsertHookCmd(hp)); } HookParam GetHookParam(ThreadParam tp) { - return processRecordsByIds->at(tp.processId)->GetHook(tp.addr).hp; + return processRecordsByIds->at(tp.processId).GetHook(tp.addr).hp; } std::shared_ptr GetThread(ThreadParam tp)