Solved Question regarding ReadProcessMemory.

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Khonnor

Newbie
Full Member
Mar 7, 2014
30
1,248
0
Hello.

I'm having an issue with ReadProcessMemory where I am reading a level 5 pointer in a function and then use the read value with other functions.
For some reason I am only getting an output of "0" and I'm not quite sure.


Example Code:
C++:
#include <tchar.h>
#include <Windows.h>
#include <iostream>
void Bla();
void Buff();
void Read();
using namespace std;

HANDLE hProc;
DWORD Final_Address;

int main()
{
	HWND hWnd = FindWindow(0, "MU");
	if (hWnd == 0){
		cout << "Error, could not find Window" << endl;
	}
	else {
		cout << "Found Clientt" << endl;

		DWORD proc_id;
		GetWindowThreadProcessId(hWnd, &proc_id);

		HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
		if (!hProc) {
			cout << "Error!" << endl;
		}
		else {
			cout << "Process opened" << endl;


while (1){
				if (GetAsyncKeyState(VK_DELETE))
				{
					Buff();

				}

				if (GetAsyncKeyState(VK_END)){
					Bla();
}
			return 0;
}
}








void Bla()
{
while (y == 1){

			Read();
			Sleep(2000);

			if (Final_Address > 150)
			{
				Bla();
			}
			else
			{
				Buff();
			}


		
	}
}



void Buff()
{
while (y == 1){

			Read();
			Sleep(2000);

			if (Final_Address > 150)
			{
				Bla();
			}
			else
			{
				Buff();
			}


		
	}
}




void Read()
{
	ReadProcessMemory(hProc, (LPCVOID)(0x400000 + 0x97CCFDC), &Temp1, 4, NULL);
	ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0xf4), &Temp1, 4, NULL);
	ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x4c), &Temp1, 4, NULL);
	ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x0), &Temp1, 4, NULL);
	ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x80), &Temp1, 4, NULL);
	ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0xc0), &Final_Address, 4, NULL);
	cout << Final_Address << endl;
}

When I RPM in int main() it seems to read fine, but not between functions why is this?

GetLastError(); on Bla() returns 6. I'm not quite sure how that could be though.



EDIT: I found the solution!

I didn't realize that OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id); wasn't global, I needed to initiate it in my Read() function.

C++:
void Read()
{
	HWND hWnd = FindWindow(0, "MU");
	if (hWnd == 0){
		cout << "Error, could not find Window" << endl;
	}
	else {
		cout << "Found Client." << endl;

		DWORD proc_id;
		GetWindowThreadProcessId(hWnd, &proc_id);

		HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
		if (!hProc) {
			cout << "Error." << endl;
		}
		cout << "Process opened" << endl;
		ReadProcessMemory(hProc, (LPCVOID)(0x400000 + 0x97CCFDC), &Temp1, 4, NULL);
		ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0xf4), &Temp1, 4, NULL);
		ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x4c), &Temp1, 4, NULL);
		ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x0), &Temp1, 4, NULL);
		ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0x80), &Temp1, 4, NULL);
		ReadProcessMemory(hProc, (LPCVOID)(Temp1 + 0xc0), &Final_Address, 4, NULL);
		cout << Final_Address << endl;
		CloseHandle(hProc);
	}

}
God damn I was losing my mind trying to figure that one out...
 
Last edited:

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
Thanks for posting your solution. Hopefully this'll help someone out in the future. Just a thought You may want to add &1 to your vkey call:
C++:
if (GetAsyncKeyState(VK_DELETE) &1)
This will allow the action to only fire once per key press. Without it if you hold the delete key down it'll repeatedly fire Buff(); This is also useful for ensuring your program is working correctly and not just repeatedly firing the code/function from turning on/off if you program that feature into your hack in the future. Good Luck!
 
Last edited:

Khonnor

Newbie
Full Member
Mar 7, 2014
30
1,248
0
Thanks for posting your solution. Hopefully this'll help someone out in the future. Just a thought You may want to add &1 to your vkey call:
C++:
if (GetAsyncKeyState(VK_DELETE) &1)
This will allow the action to only fire once per key press. Without it if you hold the delete key down it'll repeatedly fire Buff(); This is also useful for ensuring your program is working correctly and not just repeatedly firing the code/function from turning on/off if you program that feature into your hack in the future. Good Luck!
Awesome, I didn't know that. That'll definitely be useful, thanks!



This is the perfect example of how to post a question, follow through, and put your brain to use while waiting for a reply. You have a bright future. I look forward to more from you :)
Thanks! :cool:
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods