Define a window to be hProcess?
Nov 28, 2014 at 8:54pm UTC
Hello, im having a bit of trouble im working on a simple program that should get a process called: "Notepad" and i want it to define it as hProcess, but im not sure on how i should do...
This is how it looks like:
ReadProcessMemory(hProcess, (LPCVOID*)(dw_Text + dw_Numbers), &Addr, sizeof (DWORD), 0);
So how do i define hProcess to be Notepad?
Thanks for taking time and reading!
(just noticed i typed the title wrong, is there away i can change it?)
Last edited on Nov 28, 2014 at 8:55pm UTC
Nov 29, 2014 at 12:44am UTC
How about this?
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
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
HWND hwnd = FindWindow(0, "Notepad" );
if (hwnd == 0) {
cout << "Couldn't connect." << endl;
}
else {
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
HANDLE hproc = OpenProcess(PROCESS_ALL_ACCESS, false , pid);
if (!hproc) {
cout << "Couldn't open the process." << endl;
}
else {
// do stuff
}
}
return 0;
}
Topic archived. No new replies allowed.