ReadProcessMemory
This is used to read memory in a certain program
This is made for : wolfguardiann who asked me for help, and for anyone else who may need it
This is the entire code:
Now I will explain bit by bit.
Normal Everyday Stuff:
Declarations:
Find the Window
GetProcess
Read
This is basically it. If you still have issues or if I explained something wrong, please tell me. If you want a tutorial on how to write into memory, let me know as well.
Press Thanks!
This is made for : wolfguardiann who asked me for help, and for anyone else who may need it
This is the entire code:
Now I will explain bit by bit.
Normal Everyday Stuff:
Code:
#include <windows.h> #include <iostream> using namespace std;
Code:
DWORD address = 0x100579C; // This is the address that we want to read from int value = 0; // This will store our value. In my case, its an integer, which is the timer DWORD pid; //This will store our Process ID, used to read/write into the memory HWND hwnd; //Finally a handle to our window
Code:
hwnd = FindWindow(NULL,L"Minesweeper"); //Finds the Window called "Minesweeper"
if(!hwnd) //If none, display an error
{
cout <<"Window not found!\n";
cin.get();
}
Code:
GetWindowThreadProcessId(hwnd,&pid); //Get the process id and place it in pid
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,pid); //Get permission to read
if(!phandle) //Once again, if it fails, tell us
{
cout <<"Could not get handle!\n";
cin.get();
}
Code:
while(1) //Forever, or until you force close the program
{
ReadProcessMemory(phandle,(void*)address,&value,sizeof(value),0); //Read what is in "address" and store it in "value", then what is the size of what we are going to read which is "value",and finally the number of bytes read, but I dont care about that so I put a 0, or NULL
cout << value << "\n"; //Display it
Sleep(1000); //I was reading the timer which increases every second, so I made my program go through that loop every second
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD address = 0x100579C;
int value = 0;
DWORD pid;
HWND hwnd;
hwnd = FindWindow(NULL,L"Minesweeper");
if(!hwnd)
{
cout <<"Window not found!\n";
cin.get();
}
else
{
GetWindowThreadProcessId(hwnd,&pid);
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,pid);
if(!phandle)
{
cout <<"Could not get handle!\n";
cin.get();
}
else
{
while(1)
{
ReadProcessMemory(phandle,(void*)address,&value,sizeof(value),0);
cout << value << "\n";
Sleep(1000);
}
return 0;
}
}
}
Press Thanks!



