this is not mine, i just filled it in and added examples for people that are newer to c++ than me if thats even possible. credits go to PerfectsDaily
Code:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#pragma comment(lib, "user32.lib")
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "gogogokitty199's contagion ammo modifier\n"; //first display message
cout << " \n";
HWND hWnd = FindWindow(0, L"Contagion"); //name of the game window, example (Contagion, Dayz, ect)
if (hWnd == 0){
cout << "could not find Contagion.exe . Please verify that your game is running!\n";
}
else {
cout << "Found Contagion \n";
DWORD proc_id;
GetWindowThreadProcessId(hWnd, &proc_id);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
if (!hProc) {
cout << "error could not find the process \n";
}
else {
cout << "Opened Contagion. \n";
DWORD Pointer = 0x018EF124; //change the static pointer to one of a game that you want, just an example and this isnt correct
DWORD Pointed;
WORD Offset = 0x0; //offset for the pointer
int CurrentAmmo = 0; //read ammo, money, items ect
int newValue;
ReadProcessMemory(hProc, (LPCVOID)(Pointer), &Pointed, 4, NULL);
ReadProcessMemory(hProc, (LPCVOID)(Pointer + Offset), &CurrentAmmo, 4, NULL);
cout << "Enter your desired amount of ammo, max is 250: "; //this is just for contagion, ammo in mag limit is 250 max
cin >> newValue;
int Success = WriteProcessMemory(hProc, (LPVOID)(Pointed + Offset), &newValue, (DWORD) sizeof(newValue), NULL);
if (Success > 0){
ReadProcessMemory(hProc, (LPCVOID)(Pointer), &Pointed, 4, NULL);
ReadProcessMemory(hProc, (LPCVOID)(Pointer + Offset), &CurrentAmmo, 4, NULL);
cout << "your ammo has been loaded into your mag \n"; //write success
cin.get();
cout << "Press Enter to close \n";
}
else{
cout << "Error could not write to process memory"; //write failed
cout << "Press Enter to close \n";
cin.get();
}
}
}
cin.get();
return 0;
}
i used contagion as a base example because its easy and simple.