diff --git a/GUI/host/host.cc b/GUI/host/host.cc index 8ca9df0..a24e1f1 100644 --- a/GUI/host/host.cc +++ b/GUI/host/host.cc @@ -44,7 +44,7 @@ namespace WinMutex sectionMutex; }; - ThreadEventCallback OnCreate, OnRemove; + ThreadEventCallback OnCreate, OnDestroy; ProcessEventCallback OnAttach, OnDetach; std::unordered_map> textThreadsByParams; @@ -72,7 +72,7 @@ namespace for (auto it = textThreadsByParams.begin(); it != textThreadsByParams.end();) if (auto curr = it++; removeIf(curr->first)) { - OnRemove(curr->second); + OnDestroy(curr->second); textThreadsByParams.erase(curr->first); } } @@ -172,9 +172,10 @@ namespace namespace Host { - void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove, TextThread::OutputCallback output) + void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onDestroy, TextThread::OutputCallback output) { - OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnRemove = onRemove; TextThread::Output = output; + OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnDestroy = onDestroy; TextThread::Output = output; + RegisterProcess(CONSOLE.pid, INVALID_HANDLE_VALUE); OnCreate(textThreadsByParams[CONSOLE] = std::make_shared(CONSOLE, HookParam{}, L"Console")); OnCreate(textThreadsByParams[CLIPBOARD] = std::make_shared(CLIPBOARD, HookParam{}, L"Clipboard")); StartCapturingClipboard(); diff --git a/GUI/host/host.h b/GUI/host/host.h index 6702dc0..5a4cd5b 100644 --- a/GUI/host/host.h +++ b/GUI/host/host.h @@ -12,7 +12,7 @@ typedef std::function)> ThreadEventCallback; namespace Host { - void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove, TextThread::OutputCallback output); + void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onDestroy, TextThread::OutputCallback output); void Close(); bool InjectProcess(DWORD processId, DWORD timeout = 5000); diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index d2321f4..7fc777d 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -161,7 +161,6 @@ QVector MainWindow::GetAllHooks(DWORD processId) { QSet addresses; QVector hooks; - if (!processId) return hooks; for (int i = 0; i < ttCombo->count(); ++i) { ThreadParam tp = ParseTextThreadString(ttCombo->itemText(i)); @@ -188,7 +187,6 @@ void MainWindow::on_attachButton_clicked() void MainWindow::on_detachButton_clicked() { - if (processCombo->count() == 0) return; Host::DetachProcess(GetSelectedProcessId()); } @@ -197,7 +195,6 @@ void MainWindow::on_hookButton_clicked() bool ok; QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint); if (!ok) return; - if (processCombo->count() == 0) return; if (auto hp = ParseCode(hookCode)) Host::InsertHook(GetSelectedProcessId(), hp.value()); else Host::AddConsoleOutput(INVALID_CODE); }