diff --git a/GUI/hostsignaller.cpp b/GUI/hostsignaller.cpp index 7287f81..bbcbb40 100644 --- a/GUI/hostsignaller.cpp +++ b/GUI/hostsignaller.cpp @@ -5,18 +5,6 @@ void HostSignaller::Initialize() { Host::RegisterProcessAttachCallback([&](DWORD pid){ emit AddProcess(pid); }); Host::RegisterProcessDetachCallback([&](DWORD pid){ emit RemoveProcess(pid); }); - Host::RegisterThreadCreateCallback([&](TextThread* thread) - { - emit AddThread(thread); - thread->RegisterOutputCallBack([&](TextThread* thread, std::wstring output) - { - output = DispatchSentenceToExtensions(output, - { - { "current select", ttCombo->currentText().split(":")[0].toInt() == thread->Number() ? 1 : 0 } - }); - emit ThreadOutput(thread, QString::fromWCharArray(output.c_str())); - return output; - }); - }); + Host::RegisterThreadCreateCallback([&](TextThread* thread) { emit AddThread(thread); }); Host::RegisterThreadRemoveCallback([&](TextThread* thread){ emit RemoveThread(thread); }); } diff --git a/GUI/hostsignaller.h b/GUI/hostsignaller.h index 79d8ccb..4935890 100644 --- a/GUI/hostsignaller.h +++ b/GUI/hostsignaller.h @@ -18,7 +18,6 @@ signals: void RemoveProcess(unsigned int processId); void AddThread(TextThread* thread); void RemoveThread(TextThread* thread); - void ThreadOutput(TextThread* thread, QString output); }; #endif // HOSTSIGNALLER_H diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index cb61dd5..8bb472a 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -67,7 +67,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(hostSignaller, &HostSignaller::RemoveProcess, this, &MainWindow::RemoveProcess); connect(hostSignaller, &HostSignaller::AddThread, this, &MainWindow::AddThread); connect(hostSignaller, &HostSignaller::RemoveThread, this, &MainWindow::RemoveThread); - connect(hostSignaller, &HostSignaller::ThreadOutput, this, &MainWindow::ThreadOutput); + connect(this, &MainWindow::ThreadOutputReceived, this, &MainWindow::ThreadOutput); std::map extensions = LoadExtensions(); for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second); Host::Open(); @@ -115,6 +115,15 @@ void MainWindow::AddThread(TextThread* thread) GenerateHCode(Host::GetHookParam(thread->GetThreadParameter().pid, thread->GetThreadParameter().hook), thread->GetThreadParameter().pid) + ")" ); + thread->RegisterOutputCallBack([&](TextThread* thread, std::wstring output) + { + output = DispatchSentenceToExtensions(output, + { + { "current select", ttCombo->currentText().split(":")[0].toInt() == thread->Number() ? 1 : 0 } + }); + emit ThreadOutputReceived(thread, QString::fromWCharArray(output.c_str())); + return output; + }); } void MainWindow::RemoveThread(TextThread* thread) @@ -218,7 +227,7 @@ void MainWindow::on_ttCombo_activated(int index) void MainWindow::on_addExtenButton_clicked() { - QString extenFileName = QFileDialog::getOpenFileName(this, "Select extension dll", "C:\\", "Extensions (*.dll)"); + QString extenFileName = QFileDialog::getOpenFileName(this, "Select Extension dll", "C:\\", "Extensions (*.dll)"); if (!extenFileName.length()) return; QString extenName = extenFileName.split("/")[extenFileName.split("/").count() - 1]; extenName.chop(4); @@ -233,6 +242,7 @@ void MainWindow::on_addExtenButton_clicked() void MainWindow::on_rmvExtenButton_clicked() { + if (extenCombo->currentText().size() == 0) return; QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(":")[1] + "_nexthooker_extension.dll"; FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str())); DeleteFileW(extenFileName.toStdWString().c_str()); diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index 0453517..3c65361 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -22,6 +22,9 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); +signals: + void ThreadOutputReceived(TextThread* thread, QString output); + private slots: void AddProcess(unsigned int processId); void RemoveProcess(unsigned int processId); @@ -35,7 +38,6 @@ private slots: void on_hookButton_clicked(); void on_saveButton_clicked(); void on_addExtenButton_clicked(); - void on_rmvExtenButton_clicked(); private: