(c++) (external) How to I connect a pointer and an offset

Posts 1–7 of 7 · Page 1 of 1
(c++) (external) How to I connect a pointer and an offset
Hello yall,

I am having trouble binding the pointer and the offset in c++

The game I am trying to hack is Assault Cube

What am I doing wrong???

Code:
// MemoryEditing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<Windows.h>
#include<string>

using namespace std;


int main()
{
	DWORD localplayer = 0x00509b74;
	DWORD health = 0xF8;
	SetConsoleTitle(_T("AssaultCube Exploit"));
    //int readTest = 0;
	HWND hwnd = FindWindowA(NULL, "AssaultCube");
	if (hwnd == NULL)
	{
		cout << "Cannot find Window." << endl;
		Sleep(3000);
		exit(-1);
	}
	else
	{
		DWORD procID;
		GetWindowThreadProcessId(hwnd, &procID);
		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
		if (procID = NULL)
		{
			cout << "Cannot find Process." << endl;
			Sleep(3000);
			exit(-1);
		}
		else
		{
			int CurrentAdress = 0;
			ReadProcessMemory(handle, (PBYTE)(localplayer) + health, &CurrentAdress, sizeof(CurrentAdress), 0);
			//cout << "The view value was set to ";
			cout << CurrentAdress << endl;
			system("pause");
			cout << CurrentAdress << endl;
		}
	}
    return 0;
}
Regards,
You will have to read the pointer first, add the offset to the value you have read and then read from there to get health.
Example
Quote Originally Posted by Hell_Demon View Post
You will have to read the pointer first, add the offset to the value you have read and then read from there to get health.
Please may I have an example
Quote Originally Posted by KimJohnUn View Post
Please may I have an example
this is the function i made to find the pointers, this ones for ammo. uses a for loop, reads the base address/ammoAddr, then takes what it read and adds the first position of the ammoOff array which is 374 and reads it again, then adds the second element of the array which is 14, reads again and then adds 0 and its done. ammoAddr now has the address needed for the array
Code:
void getPointers(HANDLE hHandle, DWORD& ammoAddress)
{
	DWORD ammoAddr = 0X00509B74;
	DWORD ammoOff[3] = { 0x374, 0x14, 0x0 };
	int ammoArrySize = sizeof(ammoOff) / sizeof(ammoOff[0]);

	for (int i = 0; i < ammoArrySize; i++)
	{
		ReadProcessMemory(hHandle, (LPCVOID)ammoAddr, &ammoAddr, sizeof(ammoAddr), NULL);
		ammoAddr += ammoOff[i];
	}
	ammoAddress = ammoAddr;
}
With using Pointer AND Offset you have to go deep, the most are doing Pointer + Offset but thats false because that would cause changing the pointer itself and would NOT work there will be no error but it doesnt work.
This is really working its my code for a game it took me some time when i did this first time

Quote Originally Posted by Archx64 View Post
With using Pointer AND Offset you have to go deep, the most are doing Pointer + Offset but thats false because that would cause changing the pointer itself and would NOT work there will be no error but it doesnt work.
This is really working its my code for a game it took me some time when i did this first time

then why does the other method work then eh?
Code:
// MemoryEditing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<Windows.h>
#include<string>

using namespace std;


int main()
{
	DWORD localplayer = 0x00509b74;
	DWORD health = 0xF8;
	SetConsoleTitle(_T("AssaultCube Exploit"));
    //int readTest = 0;
	HWND hwnd = FindWindowA(NULL, "AssaultCube");
	if (hwnd == NULL)
	{
		cout << "Cannot find Window." << endl;
		Sleep(3000);
		exit(-1);
	}
	else
	{
		DWORD procID;
		GetWindowThreadProcessId(hwnd, &procID);
		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
		if (procID = NULL)
		{
			cout << "Cannot find Process." << endl;
			Sleep(3000);
			exit(-1);
		}
		else
		{
			int CurrentAdress = 0;
                        uintptr_t local_player = nullptr;
                        ReadProcessMemory(handle, (PBYTE)(localplayer), &local_player, sizeof(CurrentAdress), 0);
			ReadProcessMemory(handle, (PBYTE)(local_player + health), &CurrentAdress, sizeof(CurrentAdress), 0);
			//cout << "The view value was set to ";
			cout << CurrentAdress << endl;
			system("pause");
			cout << CurrentAdress << endl;
		}
	}
    return 0;
}
You need to read game + localplayer offset to get localplayer.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us