#include <windows.h> #include <iostream> using namespace std;
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
hwnd = FindWindow(NULL,L"Minesweeper"); //Finds the Window called "Minesweeper"
if(!hwnd) //If none, display an error
{
cout <<"Window not found!\n";
cin.get();
}
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();
}
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
#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;
}
}
}

DWORD address = 0x100579C;
hwnd = FindWindow(NULL,L"Minesweeper");