2018-07-21 15:40:16 -07:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
2018-07-22 16:53:51 -07:00
|
|
|
#include "QMessageBox"
|
2018-07-23 12:25:02 -07:00
|
|
|
#include "QLineEdit"
|
|
|
|
#include "QTableWidget"
|
|
|
|
#include "QInputDialog"
|
2018-07-22 16:53:51 -07:00
|
|
|
#include <Windows.h>
|
2018-07-23 12:25:02 -07:00
|
|
|
#include <qdebug.h>
|
|
|
|
#include <Psapi.h>
|
2018-07-22 16:53:51 -07:00
|
|
|
#include "../texthook/host.h"
|
2018-07-21 15:40:16 -07:00
|
|
|
|
2018-07-23 12:25:02 -07:00
|
|
|
QTableWidget* processList;
|
|
|
|
|
|
|
|
QString GetModuleName(DWORD processId, HMODULE module = NULL)
|
|
|
|
{
|
|
|
|
HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
|
|
|
|
wchar_t buffer[MAX_PATH];
|
|
|
|
GetModuleFileNameExW(handle, module, buffer, MAX_PATH);
|
|
|
|
return QString::fromWCharArray(wcsrchr(buffer, L'\\') + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnProcessAttach(DWORD processId)
|
|
|
|
{
|
|
|
|
processList->setItem(processList->rowCount(), 0, new QTableWidgetItem(QString::number(processId)));
|
|
|
|
}
|
|
|
|
|
2018-07-21 15:40:16 -07:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
2018-07-23 12:25:02 -07:00
|
|
|
Host::Start();
|
2018-07-21 15:40:16 -07:00
|
|
|
ui->setupUi(this);
|
2018-07-23 12:25:02 -07:00
|
|
|
|
|
|
|
processList = this->findChild<QTableWidget*>("processList");
|
|
|
|
Host::RegisterProcessAttachCallback([](DWORD processId)
|
|
|
|
{
|
|
|
|
processList->insertRow(processList->rowCount());
|
|
|
|
processList->setItem(processList->rowCount() - 1, 0, new QTableWidgetItem(QString::number(processId)));
|
|
|
|
processList->setItem(processList->rowCount() - 1, 1, new QTableWidgetItem(GetModuleName(processId)));
|
|
|
|
});
|
|
|
|
Host::Open();
|
2018-07-21 15:40:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2018-07-22 16:53:51 -07:00
|
|
|
|
2018-07-23 12:25:02 -07:00
|
|
|
void MainWindow::on_attachButton_clicked()
|
2018-07-22 16:53:51 -07:00
|
|
|
{
|
2018-07-23 12:25:02 -07:00
|
|
|
//processList->insertRow(processList->rowCount());
|
|
|
|
//processList->setItem(processList->rowCount() - 1, 0, new QTableWidgetItem(QString::number(6000)));
|
|
|
|
Host::InjectProcess(QInputDialog::getInt(this, "Process ID?", ""));
|
2018-07-22 16:53:51 -07:00
|
|
|
}
|