Solved Trouble reading ptrs

Hexui Undetected CSGO Cheats PUBG Accounts

darthbollo

Newbie
Full Member
Dec 13, 2014
15
102
0
I've been using the standard way of reading pointers yet i get this whenever i try. writing pointers wont do anything either
https://gyazo.com/744db6f896538d7a4c3543f2bd673bb4



C++:
#include <Windows.h>
#include <iostream>
int main()
{
	HWND hWnd = FindWindow(0, L"AssaultCube");
	DWORD iProc = GetWindowThreadProcessId(hWnd, 0);
	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, iProc);
	DWORD temp = NULL;
	int val = NULL;
	DWORD base = 0x00504545;
	DWORD offsets = { 0xF8 };
	ReadProcessMemory(hProc, (LPCVOID)base, &temp, sizeof(temp), NULL);
	ReadProcessMemory(hProc, (LPCVOID)(temp+offsets), &temp, sizeof(temp), NULL);
	ReadProcessMemory(hProc, (LPCVOID)temp, &val, sizeof(val), NULL);
	std::cout << val;
	return 0;
}
 

Broihon

Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,791
41,598
324
Screenshot - 5d820e43bfbc0b27bef1ac2fcdf7bc53 - Gyazo The first Readprocessmemory reads good but the second one doesn't, I think it's a problem with the offsets, am i doing it wrong?
Since you only have one offset you only need to use RPM (ReadProcessMemory) twice:
C++:
DWORD dwBase = 0x00504545;
DWORD dwOffset = 0xF8;
DWORD dwAddress = 0;
int Health;
ReadProcessMemory(hProc, (void*)dwBase, &dwAddress, 4, 0);
ReadProcessMemory(hProc, (void*)dwAddress + dwOffset), &Health, 4, 0);
Try this tutorial
 
Last edited by a moderator:

Broihon

Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,791
41,598
324
Debug it properly. Add checks and debug shouts. Basically it's correct but:
1. Maybe it doesn't find the window.
2. OpenProcess might fail when not running as admin. Also consider enabling SE_DEBUG_PRIVILEGE.
3. Every ReadProcessMemory call can fail if the previously read address is invalid or 0.
 

darthbollo

Newbie
Full Member
Dec 13, 2014
15
102
0
ReadProcessMemory(hProc, (LPCVOID)(temp+offsets), &temp, sizeof(temp), NULL)

is failing with 299 :( fml
 

darthbollo

Newbie
Full Member
Dec 13, 2014
15
102
0
#include <Windows.h>
#include <iostream>
#define SE_DEBUG_PRIVILEGE

int main()
{
HWND hWnd = FindWindow(0, L"AssaultCube");
if (!hWnd)
MessageBox(hWnd, L"window!", L"ERROR", MB_OK);
DWORD iProc;
GetWindowThreadProcessId(hWnd, &iProc);
if (!iProc)
MessageBox(NULL, L"iproc!", L"ERROR", MB_OK);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, iProc);
if(!hProc)
std::cout << GetLastError();
DWORD temp = NULL;
int val = NULL;
DWORD base = 0x00504545;

DWORD offsets = { 0xF8 };
if( !ReadProcessMemory(hProc, (LPCVOID)base, &temp, sizeof(temp), NULL))
std::cout << GetLastError();
if(! ReadProcessMemory(hProc, (LPCVOID)(temp+offsets), &temp, sizeof(temp), NULL))
std::cout << GetLastError();
if (! ReadProcessMemory(hProc, (LPCVOID)temp, &val, sizeof(val), NULL))
std::cout << GetLastError();
std::cout << val;
system("PAUSE");
return 0;
}
 

Broihon

Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,791
41,598
324
C++:
#include <Windows.h>
#include <iostream>
#define SE_DEBUG_PRIVILEGE

int main()
{
	HWND hWnd = FindWindow(0, L"AssaultCube");
	if (!hWnd)
		MessageBox(hWnd, L"window!", L"ERROR", MB_OK);
	DWORD iProc;
		GetWindowThreadProcessId(hWnd, &iProc);
	if (!iProc)
		MessageBox(NULL, L"iproc!", L"ERROR", MB_OK);
	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, iProc);
	if(!hProc)
		std::cout << GetLastError();
	DWORD temp = NULL;
	int val = NULL;
	DWORD base = 0x00504545;
	
	DWORD offsets = { 0xF8 };
	if( !ReadProcessMemory(hProc, (LPCVOID)base, &temp, sizeof(temp), NULL))
	std::cout << GetLastError();
	if(! ReadProcessMemory(hProc, (LPCVOID)(temp+offsets), &temp, sizeof(temp), NULL))
		std::cout << GetLastError();
	if (! ReadProcessMemory(hProc, (LPCVOID)temp, &val, sizeof(val), NULL))
		std::cout << GetLastError();
	std::cout << val;
	system("PAUSE");
	return 0;
}
That's not how SE_DEBUG_PRIVILEGE works. Forget that for now.
Are you sure that the base address is correct? I mean it's a not 4-byte aligned address (it ends with 5) and that's veeeeeery unlikely.
 
Community Mods