🕹️ Game_Memory_Hacking_Tutorial
This repository is a beginner-friendly, comprehensive guide and collection of scripts for learning the fundamentals of game memory hacking and reverse engineering. The goal of this project is to demonstrate how to scan process memory, handle pointers, find static offsets using Cheat Engine, and read/write values dynamically during runtime.
It includes simple, fully commented proof-of-concept scripts for classic games like Grand Theft Auto: Vice City, GTA: San Andreas, Tomb Raider, and more.
🏎️ Looking for a production-ready implementation? If you want to see how these core memory hacking concepts can be used to build a professional tool with a modern graphical interface, check out my advanced project here: NFS_Most_Wanted_Telemetry_Dashboard.
🧠 How It Works: The Core Concepts
When a game runs, it stores temporary data (like Health, Ammo, Coordinates) in the system's RAM. Memory hacking is the practice of finding where these values live and changing them using external scripts.
1. Finding Addresses with Cheat Engine
Before writing a script, we must find the memory addresses using Cheat Engine:
- Static Offsets (Module-Based): Some values are at a fixed distance from the game's main module (e.g.,
tomb2.dll + 0x2CA416). These are easy to lock because the module's base address is found dynamically by our script.
- Dynamic Pointers (Player Base): Modern or complex structures change their location every time the game starts. We find a Base Pointer (e.g.,
PLAYER_BASE) and use Offsets (like HP_OFFSET = 0x22) to always find the correct data relative to the player object.
2. How the Python Script Manipulates RAM
Using the pymem library, our scripts perform three main tasks in a continuous loop:
- Open Process Handle: Attaches to the game (e.g.,
tomb123.exe) to gain permission to read/write its memory.
- Read Pointer Paths: Resolves dynamic addresses by reading the base pointer first.
- Write / Freeze Values: Constantly overwrites the target memory address with our desired value (e.g., keeping HP at
1000) before the game can decrease it.
💻 Code Example: Tomb Raider II Ultimate Cheat
Here is a quick look at how we structure a basic memory script in Python. This script freezes ammo, locks health via pointers, and introduces a custom fly/levitation mechanic.
import pymem
import pymem.process
import time
import keyboard
PROCESS_NAME = "tomb123.exe"
MODULE_NAME = "tomb2.dll"
# Offsets & Base Pointers found via Cheat Engine
PLAYER_BASE = 0x025B23A0
HP_OFFSET = 0x22
AIR_OFFSET = 0x2CA416
def tomb_raider_ultimate_cheat():
pm = pymem.Pymem(PROCESS_NAME)
# Get the dynamic base address of the DLL
module = pymem.process.module_from_name(pm.process_handle, MODULE_NAME).lpBaseOfDll
print("[+] Trainer Active. Press 'X' to fly, 'Z' to hover.")
while True:
# 1. Freeze Static Value (Air/Oxygen)
pm.write_short(module + AIR_OFFSET, 1800)
# 2. Resolve Pointer for Dynamic Value (Health)
p_ptr = pm.read_longlong(module + PLAYER_BASE)
if p_ptr > 0:
pm.write_short(p_ptr + HP_OFFSET, 1000) # Lock HP to 1000
time.sleep(0.01) # Prevent high CPU usage
if __name__ == "__main__":
tomb_raider_ultimate_cheat()
⚙️ Project Structure & Usage
Each game features a straightforward, isolated script designed to show the exact process of attaching to a game, resolving pointers, and modifying specific parameters like infinite ammo, health, or gravity/flying modifiers.
🔹 Core Requirements
To test or run these basic scripts, you will need to install the memory wrapper and input handling libraries via your terminal:
pip install pymem keyboard
🔹 Repository Layout
The scripts are categorized cleanly by game title:
gta_vice_city/ -> Contains scripts for modifying ammo, health, or enabling flight mechanics.
gta_san_andreas/ -> Contains memory manipulation scripts for San Andreas values.
tomb_raider/ -> Contains classic Tomb Raider memory tools (e.g., dynamic pointer handling for HP, static modules for oxygen).
[!WARNING]
This repository is strictly for educational and self-learning purposes in reverse engineering and software security. Modifying game memory should only be done in single-player modes. I am not responsible for any misuse, bans, or data corruption.
📱 Pictures & Demonstrations
⏳ Coming Soon! Screenshots of Cheat Engine scans, pointer maps, and gameplay GIFs showing the trainers in action will be added here shortly.
🛠️ Key Topics Covered
- Process Attaching: Learning how to find a running game's Process ID (PID) and securely open a handle to its virtual memory space using
pymem.Pymem.
- Memory Reading & Writing: Utilizing fundamental system API calls (such as
ReadProcessMemory and WriteProcessMemory) wrapped cleanly in Python (write_short, write_int, read_longlong).
- Pointer Arithmetic & Offsets: Understanding how static base pointers and multi-level dynamic offsets work to keep scripts working across game restarts and map loads.
- Trainer Mechanics: Implementing fast loops (
time.sleep(0.01)) that constantly freeze or rewrite values to maintain infinite states (e.g., locking oxygen or ammo count) and tracking hotkeys with the keyboard library.
☕ Support My Work
If you enjoy my projects and want to support me, you can do so through the links below:
📬 Contact
For information, job offers, collaboration, or sponsorship, you can contact me via email.
📧 Email: muksin.muksin04@gmail.com