Why is this code not working ? memory hacking

Posts 1–9 of 9 · Page 1 of 1
Why is this code not working ? memory hacking
hey guys im trying to get into game hacking i have experience with c++, made a few crypters and so :P anyways i can't figure out why this ain't working, im using the static address with the offsets correct :S

Code:
#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

DWORD ReadMemAddr(HANDLE win, DWORD baseaddress, DWORD offsets[]);

int _tmain(int argc, _TCHAR* argv[])
{
	int option;

	printf("Press 1 for ammo hack:");
	cin >> option;

	DWORD procID;

	//Ammo variables
	DWORD base = 0x4DF73C;
	DWORD AmmoOffsets[] = {0x368, 0x14, 0x0};
	BYTE AmmoAmount[] = {0x09, 0x09, 0x00, 0x00};

	HWND hwnd = FindWindow(0, L"AssaultCube");
	if(hwnd == 0) {
		MessageBox(0, L"Could not load game!", L"Error:", MB_OK|MB_ICONERROR);
		exit(EXIT_FAILURE);
	}else {
		printf("Hacks Loaded Interface Succesfully!\n");
		
		GetWindowThreadProcessId(hwnd, &procID);
		HANDLE window = OpenProcess(PROCESS_ALL_ACCESS, false, procID);

		if(!window) {
			MessageBox(0, L"Could not access game process!", L"Error:", MB_OK|MB_ICONERROR);
		}else {
			DWORD DMA = ReadMemAddr(window, base, AmmoOffsets);
			WriteProcessMemory(window, (BYTE*) DMA, &AmmoAmount, sizeof(AmmoAmount), NULL);
			MessageBox(0, L"Ammo hacked!", L"Success:", MB_OK);
		}
	}
	return 0;
}

DWORD ReadMemAddr(HANDLE win, DWORD baseaddress, DWORD offsets[]) {
	
	int pointerLvl = sizeof(offsets);
	DWORD tempAddr;
	DWORD result;
	
	for(int i = 0; i < pointerLvl; i++) {
		ReadProcessMemory(win, (LPCVOID) baseaddress, &tempAddr, sizeof(tempAddr), NULL);
		result = tempAddr + offsets[i];

		ReadProcessMemory(win, (LPCVOID) result, &tempAddr, sizeof(tempAddr), NULL);
	}

	return result;
}
Code:
DWORD ReadMemAddr(HANDLE win, DWORD baseaddress, DWORD offsets[]) {
	
int pointerLvl = sizeof(offsets);
Think about what you are doing there.

Size of a pointer is 32bit (atleast in this case), sizeof will always return 4 there.
yea i fixed that and it is still not working :S im now passing the lvl as a parameter now :P the reason wo why it is not working is because it can't find the correct address for some reason :S its really close but that does not help :P

---------- Post added at 11:02 AM ---------- Previous post was at 10:53 AM ----------

nvm got it working, a mod can close this thread now
umm i really don't know the solution :L i pretty much rewrote huge parts of the program and got it working first try, i think it had something to do with the code calculating the wrong memory address(non static one)
Quote Originally Posted by xXsc00pedXx View Post
umm i really don't know the solution :L i pretty much rewrote huge parts of the program and got it working first try, i think it had something to do with the code calculating the wrong memory address(non static one)
He meant upload it
ZOMGGGGGGGGGGGGGGGGGGGGGGGGG
@Codenever
ZOMGGGGGGGGGGGGGGGG
Why is there second ReadPRocessMemory in loop?
He got it to work, can you guys stop spamming shit?
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us