Trying to write to a .exe
I am trying to write to a exe and have the program verify as it goes but I keep getting the find window error even if the name is correct
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
char continue1;
int newValue = 1200;
int readTest = 0;
string MyString;
string address;
cout << "What is the game name?(THE THING IN THE WHITE BAR)" <<endl;
cin >> MyString;
Sleep(2000);
if(continue1 == 'Y')
{
HWND hwnd = FindWindowA(NULL, MyString.c_str());
if(hwnd == NULL)
{
cout << "Cannot find window." <<endl;
Sleep(3000);
exit(-1);
}
else
{
cout << "Connected" <<endl;
Sleep(2000);
DWORD procID;
GetWindowThreadProcessId(hwnd, &procID);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
if(procID == NULL)
{
cout << "Cannot obtain process." <<endl;
Sleep(3000);
exit(-1);
}
else
{
cout << "Put in the address you want to edit." <<endl;
cin >> address;
WriteProcessMemory(handle, (LPVOID)address.c_str(), &newValue, sizeof(newValue), 0);
ReadProcessMemory(handle, (PBYTE*)address.c_str(), &readTest, sizeof(int), 0);
cout << readTest <<endl;
Sleep(3000);
}
}
}
if(continue1 == 'N')
{
cout << "Goodbye." <<endl;
Sleep(2000);
exit(-1);
}
return 0;
}
|
Topic archived. No new replies allowed.