diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index f285619..3b58ed0 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -1,47 +1,11 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include -#include "QTextBrowser" -#include "QMessageBox" -#include "QComboBox" -#include "QLineEdit" -#include "QInputDialog" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "extensions.h" -#include "../vnrhook/include/const.h" #include "misc.h" - -QString ProcessString(DWORD processId) -{ - return QString("%1: %2").arg(QString::number(processId), GetModuleName(processId)); -} - -QString TextThreadString(TextThread* thread) -{ - ThreadParameter tp = thread->GetThreadParameter(); - return QString("%1:0x%2:0x%3:0x%4: ").arg( - QString::number(tp.pid).toUpper(), - QString::number(tp.hook, 16).toUpper(), - QString::number(tp.retn, 16).toUpper(), - QString::number(tp.spl, 16).toUpper() - ); -} - -ThreadParameter ParseTextThreadString(QString textThreadString) -{ - QStringList threadParam = textThreadString.split(":"); - return { threadParam[0].toUInt(), threadParam[1].toULongLong(nullptr, 0), threadParam[2].toULongLong(nullptr, 0), threadParam[3].toULongLong(nullptr, 0) }; -} +#include "../vnrhook/include/const.h" +#include +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -89,7 +53,7 @@ MainWindow::~MainWindow() void MainWindow::AddProcess(unsigned int processId) { - processCombo->addItem(ProcessString(processId)); + processCombo->addItem(QString::number(processId) + ": " + GetModuleName(processId)); QFile file("SavedHooks.txt"); if (!file.open(QIODevice::ReadOnly)) return; QString processName = GetFullModuleName(processId); @@ -150,6 +114,28 @@ void MainWindow::ThreadOutput(TextThread* thread, QString output) } } +QString MainWindow::TextThreadString(TextThread* thread) +{ + ThreadParameter tp = thread->GetThreadParameter(); + return QString("%1:%2:%3:%4: ").arg( + QString::number(tp.pid), + QString::number(tp.hook, 16), + QString::number(tp.retn, 16), + QString::number(tp.spl, 16) + ).toUpper(); +} + +ThreadParameter MainWindow::ParseTextThreadString(QString textThreadString) +{ + QStringList threadParam = textThreadString.split(":"); + return { threadParam[0].toUInt(), threadParam[1].toULongLong(nullptr, 16), threadParam[2].toULongLong(nullptr, 16), threadParam[3].toULongLong(nullptr, 16) }; +} + +DWORD MainWindow::GetSelectedProcessId() +{ + return processCombo->currentText().split(":")[0].toULong(); +} + void MainWindow::ReloadExtensions() { extenCombo->clear(); @@ -171,12 +157,12 @@ std::unordered_map MainWindow::GetInfoForExtensions(TextThread QVector MainWindow::GetAllHooks(DWORD processId) { - std::unordered_set addresses; + QSet addresses; QVector hooks; for (int i = 0; i < ttCombo->count(); ++i) { ThreadParameter tp = ParseTextThreadString(ttCombo->itemText(i)); - if (tp.pid == processId && !addresses.count(tp.hook)) + if (tp.pid == processId && !addresses.contains(tp.hook)) { addresses.insert(tp.hook); hooks.push_back(Host::GetHookParam(tp)); @@ -185,11 +171,6 @@ QVector MainWindow::GetAllHooks(DWORD processId) return hooks; } -DWORD MainWindow::GetSelectedProcessId() -{ - return processCombo->currentText().split(":")[0].toULong(); -} - void MainWindow::on_attachButton_clicked() { std::unordered_map allProcesses = GetAllProcesses(); @@ -207,7 +188,7 @@ void MainWindow::on_attachButton_clicked() if (Host::InjectProcess(process.toInt())) return; } else if (Host::InjectProcess(allProcesses[process.toStdWString()])) return; - Host::AddConsoleOutput(L"Failed to attach"); + Host::AddConsoleOutput(L"failed to attach"); } void MainWindow::on_detachButton_clicked() diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index dcfdac7..d349313 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -43,10 +43,12 @@ private slots: void on_rmvExtenButton_clicked(); private: + QString TextThreadString(TextThread* thread); + ThreadParameter ParseTextThreadString(QString textThreadString); + DWORD GetSelectedProcessId(); void ReloadExtensions(); std::unordered_map GetInfoForExtensions(TextThread* thread); QVector GetAllHooks(DWORD processId); - DWORD GetSelectedProcessId(); Ui::MainWindow *ui; QComboBox* processCombo; diff --git a/GUI/misc.cpp b/GUI/misc.cpp index 971d494..36d3f67 100644 --- a/GUI/misc.cpp +++ b/GUI/misc.cpp @@ -1,7 +1,6 @@ #include "misc.h" #include "../vnrhook/include/const.h" #include -#include #include QString GetFullModuleName(DWORD processId, HMODULE module)