Read/write in another program’s memory


Following my very brief introduction tutorial on how to hack most games with Cheat Engine (in french, sorry) I go a bit further in this post by allowing you to practice with a home made C program. In this post I will show you how to load 2 variables in memory and then modifying them with an external program.

I made a small program in C that allows you to load a number in a variable and a string in another so you can use any memory exploration/modification tool to practice looking for variables in memory and modify them.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
    // Initialising our variables
    int varNum = 0, varExit = 0;
    char varString[255] = "";
    // Giving a value to our integer type variable to find it in memory afterwards
    printf("Enter a number to load in memory: ");
    scanf("%d", &varNum);
    // Giving a value to our char type variable to find it in memory afterwards
    printf("Enter a string to load in memory: ");
    scanf("%s", &varString);
    // Infinite loop to check the variable values after modification in memory
    while (varExit != 1) {
        printf("varNum = %d\n", varNum);
        printf("varString = \"%s\"\n", varString);
        printf("\nEnter 1 to exit: ");
        scanf("%d", &varExit);
    return 0;

As you can see this C program is quite simple, it initiates two variables: an integer (a number) and a char (string). It then prompts the user to enter values for both and finally lets you print them on the screen over and over again until you decide to quit it.

I start it and enter the date of today as a number (06012017) and my first and last name as a string (PierreCiholas) :


Now if I start another program to read/write the memory, such as Cheat Engine, load the memory of the my program’s process and look for the number that I entered, I will find it and I can modify it as shown on the following screenshot:


Now let’s do the same thing for the string variable…


I press OK and in my program I enter 0 and enter to ask it to simply re-print the variable values in the console and …


We can see that now the variables have different values, so everything worked.

In the next tutorial we are going to do the same thing but with our own C program to read and write in the memory instead (Cheat Engine is good but if you want to make something advanced like a radar to detect players in a game, it will never be good enough and you will need to do this program yourself!)

Leave a Reply

Your email address will not be published. Required fields are marked *