From bc8ba908388dade1fe06f01ed0e63053ff7da670 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 30 Jul 2018 20:25:08 -0700 Subject: [PATCH] final commits, ready for next release! --- GUI/mainwindow.cpp | 29 +++++++++++++++++++++++++---- GUI/mainwindow.ui | 30 ++++++++++++++++-------------- GUI/misc.cpp | 16 +++++++++++++++- GUI/misc.h | 1 + 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 2fa7bd1..6e61abb 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -52,8 +52,14 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); mainWindow = this; processCombo = mainWindow->findChild("processCombo"); + processCombo->lineEdit()->setAlignment(Qt::AlignHCenter); + processCombo->lineEdit()->setReadOnly(true); ttCombo = mainWindow->findChild("ttCombo"); + ttCombo->lineEdit()->setAlignment(Qt::AlignHCenter); + ttCombo->lineEdit()->setReadOnly(true); extenCombo = mainWindow->findChild("extenCombo"); + extenCombo->lineEdit()->setAlignment(Qt::AlignHCenter); + extenCombo->lineEdit()->setReadOnly(true); textOutput = mainWindow->findChild("textOutput"); hostSignaller->Initialize(); @@ -65,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) : std::map extensions = LoadExtensions(); for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second); Host::Open(); + Host::AddConsoleOutput(L"NextHooker beta v2.0.0 by Artikash\r\nSource code and more information available under GPLv3 at https://github.com/Artikash/NextHooker"); } MainWindow::~MainWindow() @@ -85,7 +92,11 @@ void MainWindow::AddProcess(unsigned int processId) { Sleep(50); QStringList hooks = allProcesses.at(i).split(" , "); - for (int j = 1; j < hooks.length(); ++j) Host::InsertHook(processId, ParseHCode(hooks.at(j))); + for (int j = 1; j < hooks.length(); ++j) + { + Sleep(10); + Host::InsertHook(processId, ParseHCode(hooks.at(j))); + } return; } } @@ -144,8 +155,11 @@ QVector MainWindow::GetAllHooks(DWORD processId) void MainWindow::on_attachButton_clicked() { bool ok; - int processId = QInputDialog::getInt(this, "Attach Process", "Process ID?\r\nYou can find this under Task Manager -> Details", 0, 0, 100000, 1, &ok); - if (ok) Host::InjectProcess(processId); + QString process = QInputDialog::getItem(this, "Select Process", + "If you don't see the process you want to inject, try running with admin rights", + GetAllProcesses(), 0, true, &ok); + if (!ok) return; + if (!Host::InjectProcess(process.split(":")[1].toInt())) Host::AddConsoleOutput(L"Failed to attach"); } void MainWindow::on_detachButton_clicked() @@ -160,7 +174,14 @@ void MainWindow::on_hookButton_clicked() "Enter hook code\r\n/H{A|B|W|S|Q}[N]data_offset[*drdo][:sub_offset[*drso]]@addr[:module]", QLineEdit::Normal, "/H", &ok ); - if (ok) Host::InsertHook(processCombo->currentText().split(":")[0].toInt(), ParseHCode(hookCode)); + if (!ok) return; + HookParam toInsert = ParseHCode(hookCode); + if (toInsert.type == 0 && toInsert.length_offset == 0) + { + Host::AddConsoleOutput(L"invalid /H code"); + return; + } + Host::InsertHook(processCombo->currentText().split(":")[0].toInt(), ParseHCode(hookCode)); } void MainWindow::on_unhookButton_clicked() diff --git a/GUI/mainwindow.ui b/GUI/mainwindow.ui index d2bb034..191844b 100644 --- a/GUI/mainwindow.ui +++ b/GUI/mainwindow.ui @@ -97,6 +97,9 @@ + + true + QComboBox::InsertAtBottom @@ -181,7 +184,11 @@ 0 - + + + true + + @@ -231,7 +238,14 @@ 4 - + + + true + + + 50 + + @@ -265,18 +279,6 @@ 20 - - - Options - - - - - About - - - - diff --git a/GUI/misc.cpp b/GUI/misc.cpp index 9e96e31..01580ff 100644 --- a/GUI/misc.cpp +++ b/GUI/misc.cpp @@ -1,12 +1,13 @@ #include "misc.h" #include "../vnrhook/include/const.h" #include +#include #include QString GetFullModuleName(DWORD processId, HMODULE module) { HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId); - wchar_t buffer[MAX_PATH]; + wchar_t buffer[MAX_PATH] = {}; GetModuleFileNameExW(handle, module, buffer, MAX_PATH); CloseHandle(handle); return QString::fromWCharArray(buffer); @@ -18,6 +19,19 @@ QString GetModuleName(DWORD processId, HMODULE module) return fullName.remove(0, fullName.lastIndexOf("\\") + 1); } +QStringList GetAllProcesses() +{ + DWORD allProcessIds[0x1000]; + DWORD spaceUsed; + QStringList ret; + if (!EnumProcesses(allProcessIds, sizeof(allProcessIds), &spaceUsed)) return ret; + for (int i = 0; i < spaceUsed / sizeof(DWORD); ++i) + if (GetModuleName(allProcessIds[i]).size()) + ret.push_back(GetModuleName(allProcessIds[i]) + ": " + QString::number(allProcessIds[i])); + ret.sort(); + return ret; +} + DWORD Hash(QString module) { module = module.toLower(); diff --git a/GUI/misc.h b/GUI/misc.h index 802b50f..bde6202 100644 --- a/GUI/misc.h +++ b/GUI/misc.h @@ -7,6 +7,7 @@ QString GetFullModuleName(DWORD processId, HMODULE module = NULL); QString GetModuleName(DWORD processId, HMODULE module = NULL); +QStringList GetAllProcesses(); HookParam ParseHCode(QString HCode); QString GenerateHCode(HookParam hp, DWORD processId);