better ux for attaching games
This commit is contained in:
parent
4e10a597c9
commit
0b3599cb84
@ -183,12 +183,22 @@ QVector<HookParam> MainWindow::GetAllHooks(DWORD processId)
|
|||||||
|
|
||||||
void MainWindow::on_attachButton_clicked()
|
void MainWindow::on_attachButton_clicked()
|
||||||
{
|
{
|
||||||
|
std::unordered_map<std::wstring, DWORD> allProcesses = GetAllProcesses();
|
||||||
|
QStringList processList;
|
||||||
|
for (auto i : allProcesses)
|
||||||
|
processList.push_back(QString::fromStdWString(i.first));
|
||||||
|
processList.sort(Qt::CaseInsensitive);
|
||||||
bool ok;
|
bool ok;
|
||||||
QString process = QInputDialog::getItem(this, "Select Process",
|
QString process = QInputDialog::getItem(this, "Select Process",
|
||||||
"If you don't see the process you want to inject, try running with admin rights\r\nYou can just type in the process id if you know it",
|
"If you don't see the process you want to inject, try running with admin rights\r\nYou can just type in the process id if you know it",
|
||||||
GetAllProcesses(), 0, true, &ok);
|
processList, 0, true, &ok);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
if (!Host::InjectProcess(process.split(":")[0].toInt())) Host::AddConsoleOutput(L"Failed to attach");
|
if (process.toInt())
|
||||||
|
{
|
||||||
|
if (Host::InjectProcess(process.toInt())) return;
|
||||||
|
}
|
||||||
|
else if (Host::InjectProcess(allProcesses[process.toStdWString()])) return;
|
||||||
|
Host::AddConsoleOutput(L"Failed to attach");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_detachButton_clicked()
|
void MainWindow::on_detachButton_clicked()
|
||||||
|
@ -19,18 +19,15 @@ QString GetModuleName(DWORD processId, HMODULE module)
|
|||||||
return fullName.remove(0, fullName.lastIndexOf("\\") + 1);
|
return fullName.remove(0, fullName.lastIndexOf("\\") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GetAllProcesses()
|
std::unordered_map<std::wstring, DWORD> GetAllProcesses()
|
||||||
{
|
{
|
||||||
DWORD allProcessIds[0x1000];
|
DWORD allProcessIds[0x1000];
|
||||||
DWORD spaceUsed;
|
DWORD spaceUsed;
|
||||||
QStringList ret;
|
std::unordered_map<std::wstring, DWORD> ret;
|
||||||
if (!EnumProcesses(allProcessIds, sizeof(allProcessIds), &spaceUsed)) return ret;
|
if (!EnumProcesses(allProcessIds, sizeof(allProcessIds), &spaceUsed)) return ret;
|
||||||
for (int i = 0; i < spaceUsed / sizeof(DWORD); ++i)
|
for (int i = 0; i < spaceUsed / sizeof(DWORD); ++i)
|
||||||
if (GetModuleName(allProcessIds[i]).size())
|
if (GetModuleName(allProcessIds[i]).size())
|
||||||
ret.push_back(GetModuleName(allProcessIds[i]) + ":" + QString::number(allProcessIds[i]));
|
ret[GetModuleName(allProcessIds[i]).toStdWString()] = allProcessIds[i];
|
||||||
ret.sort(Qt::CaseInsensitive);
|
|
||||||
for (int i = 0; i < ret.size(); ++i)
|
|
||||||
ret[i] = ret[i].split(":")[1] + ": " + ret[i].split(":")[0];
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
#define MISC_H
|
#define MISC_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <unordered_map>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "../host/host.h"
|
#include "../host/host.h"
|
||||||
|
|
||||||
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
QStringList GetAllProcesses();
|
std::unordered_map<std::wstring, DWORD> GetAllProcesses();
|
||||||
HookParam ParseCode(QString HCode);
|
HookParam ParseCode(QString HCode);
|
||||||
QString GenerateCode(HookParam hp, DWORD processId);
|
QString GenerateCode(HookParam hp, DWORD processId);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user