I am trying to WriteProcessMemory using Qt with QtCreator. When i press the button it doesn’t write. Here is the code i am using if anyone could help.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <windows.h>
HANDLE hProcess;
int MYBASE;
void Attach() {
DWORD pid;
HWND hWindow = FindWindow(NULL, L"Generic Property Editor Thingy");
GetWindowThreadProcessId(hWindow, &pid);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
Attach();
WriteProcessMemory(hProcess, (void*)0x4E709C, (void*)(PBYTE)"\xEB", 1, NULL);
}
In case you haven’t solve this error:
function names are cases sensitive in C/C++ etc … So rename your function to “Attach(…)”