ReadProcessMemory

Posts 16–28 of 28 · Page 2 of 2
Quote Originally Posted by fukojr2 View Post


So around my age? Like when I started. You're 19 right?
I'm 18 /short
Quote Originally Posted by aanthonyz View Post
Wow I am only at 1.5 years max. Minimum would be 1 year.. I dont remember
haha, I started on June with VB xD then I did go for C# and then for C++
Its funny how this went from memory reading to when we started C++
Quote Originally Posted by aanthonyz View Post
Its funny how this went from memory reading to when we started C++
Derailing threads is fun
Quote Originally Posted by Hell_Demon View Post
Derailing threads is fun
Says the Minion of the section. LOL =P
Quote Originally Posted by why06 View Post


Says the Minion of the section. LOL =P
haha,that's a really funny section...
Registered to say thank you for this tutorial and explanation.

Can you explain how to read from static pointer? I don't have code for it.
Old thread I know...
but this is my code where I have a base pointer and an offset and it gives me weird shit. I am using the game assault cube.

Code:
#include <iostream>
#include <conio.h>
#include <windows.h>

int main()
{
				DWORD base = 0x00509B74;
				DWORD offset = 0xF8;
				int value = 0;
				int memes = 0;
				int k = 100;
				unsigned long address = value + offset;
				HWND pWND = FindWindow(0, ("AssaultCube"));
				DWORD pID;
				GetWindowThreadProcessId(pWND, &pID);
				std::cout << "pID = " << pID << std::endl;
				HANDLE hPROC = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
				int i = ReadProcessMemory(hPROC, (LPCVOID*)base, (LPVOID)(&value), (DWORD)sizeof(int), NULL);
				int ii = ReadProcessMemory(hPROC, (LPCVOID*)address, (LPVOID)(&k), (DWORD)sizeof(int), NULL);
				std::cout << k << std::endl;
				std::cout << std::hex << k << std::dec << " = " << k << std::endl;

				_getch();
				return 0;
}
Thanks so much man, 5 years later and you example works for me

Quote Originally Posted by aanthonyz View Post
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:
Code:
#include <windows.h>
#include <iostream>

using namespace std;
Declarations:
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
Find the 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();
	}
GetProcess
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();
		}
Read
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;
		}
	}
}
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!
So what can you do with this information like the DWORD Pid and INT Value?
Quote Originally Posted by J0ker_ View Post
So what can you do with this information like the DWORD Pid and INT Value?
Did you learn C++ before? pID is the process id wich is needed to open a handle to a process. The Value is an integer that you want to write into the memory of the process.
Thank you, this will help me out a ton.
Posts 16–28 of 28 · Page 2 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?