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;
}