Skip to content

Commit

Permalink
final commits, ready for next release!
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Jul 31, 2018
1 parent f63bd97 commit bc8ba90
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
29 changes: 25 additions & 4 deletions GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
mainWindow = this;
processCombo = mainWindow->findChild<QComboBox*>("processCombo");
processCombo->lineEdit()->setAlignment(Qt::AlignHCenter);
processCombo->lineEdit()->setReadOnly(true);
ttCombo = mainWindow->findChild<QComboBox*>("ttCombo");
ttCombo->lineEdit()->setAlignment(Qt::AlignHCenter);
ttCombo->lineEdit()->setReadOnly(true);
extenCombo = mainWindow->findChild<QComboBox*>("extenCombo");
extenCombo->lineEdit()->setAlignment(Qt::AlignHCenter);
extenCombo->lineEdit()->setReadOnly(true);
textOutput = mainWindow->findChild<QPlainTextEdit*>("textOutput");

hostSignaller->Initialize();
Expand All @@ -65,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) :
std::map<int, QString> 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()
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -144,8 +155,11 @@ QVector<HookParam> 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()
Expand All @@ -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()
Expand Down
30 changes: 16 additions & 14 deletions GUI/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
</property>
<item>
<widget class="QComboBox" name="processCombo">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAtBottom</enum>
</property>
Expand Down Expand Up @@ -181,7 +184,11 @@
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="extenCombo"/>
<widget class="QComboBox" name="extenCombo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addExtenButton">
Expand Down Expand Up @@ -231,7 +238,14 @@
<number>4</number>
</property>
<item>
<widget class="QComboBox" name="ttCombo"/>
<widget class="QComboBox" name="ttCombo">
<property name="editable">
<bool>true</bool>
</property>
<property name="maxVisibleItems">
<number>50</number>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="textOutput">
Expand Down Expand Up @@ -265,18 +279,6 @@
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuOptions">
<property name="title">
<string>Options</string>
</property>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
</widget>
<addaction name="menuOptions"/>
<addaction name="menuAbout"/>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down
16 changes: 15 additions & 1 deletion GUI/misc.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "misc.h"
#include "../vnrhook/include/const.h"
#include <QRegExp>
#include <QStringList>
#include <Psapi.h>

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);
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions GUI/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit bc8ba90

Please sign in to comment.