Click here to Skip to main content
14,739,619 members
Articles » General Programming » Game Development » Games
Posted 6 May 2007


35 bookmarked

GameTrainer: A Tool to Train Games

Rate me:
Please Sign up or sign in to vote.
4.32/5 (19 votes)
6 May 2007CPOL
An easy way to train games


With the aid of few Windows API calls, it is easy to read and write the memory of other running processes. By monitoring the memory of such processes, it is easy to detect where memory locations contain peculiar variables in games (bullets, gold, lives, etc.); as soon as the variable is found, it can be overridden with a new value.

The functioning of the program is very easy and with it, a gamer can obtain the desired amount of these elements.


Windows provides programmers with few APIs that are useful to access for reading and writing the memory of another running process: the following paragraph shows the used APIs and how platform invoke is employed in order to use them in C#.

// Used to read the memory of a process
public static extern bool ReadProcessMemory
	(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, 
	UInt32 size, ref IntPtr lpNumberOfBytesRead);
// Used to open process for reading and writing memory 
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, 
	bool bInheritHandle, UInt32 dwProcessId);

// Used to close the process    
public static extern Int32 CloseHandle(IntPtr hObject);

// Used to write into the memory of a process    
static extern bool WriteProcessMemory(IntPtr hProcess, 
	IntPtr lpBaseAddress, byte[] lpBuffer, Int32 nSize, 
	out IntPtr lpNumberOfBytesWritten);

Using the Program

The functioning principle of GameTrainer is very simple: it is based upon the fact that during a game certain game, variables (like bullets, lives, gold, etc.) change their value; by monitoring this value during a gameplay, it is easy to detect where these variable are stored in memory. Once the memory location is found, its value can be changed as desired. The graph here below shows the procedure a gamer should use to accomplish this task.


The sequence to follow is very easy and evolves through the steps shown in the flow chart. During the game, the user must choose the variable to monitor (for example, the amount of gold). At this point, the game must be paused and GameTrainer must be launched and it must be commanded to search for the quantity of gold present in the game (like in the picture below): in the value textbox, the user should put the amount to search. The length combobox shows three values (1, 2 and 4): this value indicates how many bytes are needed to store the variable to search. In this case, 2 has been chosen since 1000 needs two bytes to be stored.


When the search button is pressed, the memory is searched for the requested value; after few moments (when the memory search has finished), the following form is shown:


It means that to find the variable, the user has to refine the search: in other words, he has to resume the game and stop a little later until the variable changes (in the example, the new variable to search is 1001). When finally the variable is found, the shown form is the following one: it shows the memory location and presents a combobox where the user can choose the new value for his variable !



  • 6th May, 2007: Version 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
Italy Italy
2008 - Working on my own
2005 - ... still programming
2005 - Working at the Digigroup of Torino (Italy)
2004 - Got my PhD at the "Politecnico di Torino"
2001 - Got Graduated at the "Politecnico di Torino"
2000 - Got Graduated at the UIC (Chicago)
1983 - Started programming ...
1976 - Born

Comments and Discussions

GeneralThanks ! Pin
bi0s24-May-08 6:29
Memberbi0s24-May-08 6:29 
GeneralWorld of Warcraft hack Pin
Arghs10-Nov-07 0:33
MemberArghs10-Nov-07 0:33 
GeneralCrash with big scan Pin
Webtijn13-Jun-07 5:04
MemberWebtijn13-Jun-07 5:04 
GeneralRe: Crash with big scan Pin
pinturic18-Jun-07 22:00
Memberpinturic18-Jun-07 22:00 
GeneralAwesome Pin
thund3rstruck7-May-07 7:01
Memberthund3rstruck7-May-07 7:01 
GeneralRe: Awesome Pin
pinturic7-May-07 22:04
Memberpinturic7-May-07 22:04 
GeneralCheatEngine Pin
The_Mega_ZZTer6-May-07 7:25
MemberThe_Mega_ZZTer6-May-07 7:25 
GeneralRe: CheatEngine Pin
pinturic6-May-07 7:42
Memberpinturic6-May-07 7:42 
Generalomg THANK YOU!!! Pin
sharpiesharpie6-May-07 6:58
Membersharpiesharpie6-May-07 6:58 
GeneralRe: omg THANK YOU!!! Pin
pinturic6-May-07 7:05
Memberpinturic6-May-07 7:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.