Information Security 14 min read

Memory Editing and Cheat Development for PC Games: Techniques, Tools, and Sample Code

This article explains how to locate and modify in‑memory game data, write simple Windows‑API cheat programs, automate gameplay actions, and intercept network traffic for popular PC games, providing step‑by‑step examples and full source code for each technique.

Java Captain
Java Captain
Java Captain
Memory Editing and Cheat Development for PC Games: Techniques, Tools, and Sample Code

The author recounts early experiences with browser and desktop games and describes how curiosity about modifying game values led to learning basic memory‑editing concepts, such as locating data stored in files versus in a running process.

Three categories of game data modification are identified: (1) directly editing unencrypted local files (e.g., Mount & Blade), (2) changing values in a game's memory after it has been loaded, and (3) manipulating server‑side data in online games by mimicking network requests.

1. Memory Data Investigation – Using a memory scanner, the author demonstrates how to find the Sunlight value in Plants vs. Zombies (initially 75) by searching for the number, spending a bit of Sunlight to change the value, rescanning, and pinpointing the address 0x21BF10C8 . Screenshots illustrate each step, and the value is edited directly in the process.

2. Writing a Simple Cheat Program (C++)

#include
#include
int main() {
    HWND h = ::FindWindow(NULL, "植物大战僵尸中文版"); // locate window
    DWORD processid;
    GetWindowThreadProcessId(h, &processid);
    HANDLE hprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processid);
    if (hprocess == 0) {
        printf("打开进程失败!\n");
        return 1;
    } else {
        printf("打开进程成功!\n");
        DWORD hp = 3000; // new Sunlight value
        LPCVOID addr = (LPVOID)0x21BF10C8; // address found with Cheat Engine
        WriteProcessMemory(hprocess, (LPVOID)addr, &hp, 4, 0);
        return 0;
    }
}

This program opens the game process, writes a new Sunlight value, and confirms success.

3. Reading Game Data

#include
#include
int main() {
    HWND h = ::FindWindow(NULL, "植物大战僵尸中文版");
    DWORD processid;
    GetWindowThreadProcessId(h, &processid);
    HANDLE processh = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processid);
    if (processh == 0) {
        printf("打开进程失败!\n");
        return 1;
    } else {
        printf("打开进程成功!\n");
        int sun;
        LPCVOID mbase = (LPCVOID)0x1E0CF020; // example base address
        ReadProcessMemory(processh, mbase, &sun, 4, 0);
        printf("您有阳光:%d\n", sun);
        return 0;
    }
}

The code reads a 4‑byte integer from a known address and prints the current Sunlight amount.

4. Automated Gameplay (Auto‑clicker) – By using Windows messages SendMessage with WM_LBUTTONDOWN and WM_LBUTTONUP , a program can simulate mouse clicks without moving the physical cursor. Combined with a BFS algorithm that searches a 2‑D array for matching tiles, the cheat can automatically clear a Mahjong‑style matching game.

void clearapair() {
    // locate two identical tiles and click them
    for (int y1=0; y1<11; y1++)
        for (int x1=0; x1<19; x1++) {
            if (!chessdata[y1][x1]) continue;
            for (int y2=0; y2<11; y2++)
                for (int x2=0; x2<19; x2++)
                    if (chessdata[y2][x2] && chessdata[y1][x1]==chessdata[y2][x2] && (x1!=x2 || y1!=y2)) {
                        // check if a path exists via BFS
                        if (llk_bfs(y1, x1, y2, x2) != -1) {
                            click2p({x1,y1}, {x2,y2});
                            return;
                        }
                    }
        }
}

5. Network Game Cheat (HTTP Request Spoofing) – For an old online game, the author captures a form request, modifies the Age parameter, and repeatedly sends it using an Apache HttpClient in Java. The sample Java code shows how to set custom headers, cookies, and execute a GET request to simulate item usage.

import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;

public class Renren {
    private static String renRenLoginURL = "http://resourcemop.l.imop.com/res/fc/fcde1f39034b164a0d5fe7e455b0c32e";
    private HttpResponse response;
    private CloseableHttpClient httpclient = HttpClients.createDefault();
    private boolean login() {
        HttpGet httpGet = new HttpGet(renRenLoginURL);
        httpGet.setHeader("User-Agent", "Mozilla/5.0 ...");
        // other headers omitted for brevity
        try { response = httpclient.execute(httpGet); }
        catch (Exception e) { e.printStackTrace(); return false; }
        finally { httpGet.abort(); }
        return true;
    }
    public static void main(String[] args) { new Renren().login(); }
}

The article concludes with a promise to add more cheat tutorials, such as Steam card‑grinding scripts, and encourages readers to explore game hacking as a hobby.

CReverse Engineeringmemory editinggame hackingWindows APIcheat development
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.