5,442,984 members and growing! (18,756 online)
Email Password   helpLost your password?
Languages » C# » General     Intermediate License: The Code Project Open License (CPOL)

GameTrainer: A tool to train games

By pinturic

An easy way to train games
C# 2.0, C#, Windows, .NET, .NET 2.0VS2005, Visual Studio, Dev

Posted: 6 May 2007
Updated: 6 May 2007
Views: 12,797
Bookmarked: 26 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
18 votes for this Article.
Popularity: 4.57 Rating: 3.64 out of 5
3 votes, 16.7%
1
0 votes, 0.0%
2
2 votes, 11.1%
3
2 votes, 11.1%
4
11 votes, 61.1%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
Title:       GameTrainer: An easy way to train games
Author:      Luca Tagliaferri
Email:       pinturicchio@hotmail.com
Member ID:   12345
Language:    C# 2.0 
Platform:    Windows, .NET 2.0 
Technology:  .NET, Platorm Invoke
Level:       Beginner
Description: With the aid of platform invoke is easy to read and modify the memory of running processes 
Section      .NET General
SubSection   .NET

GameTrainer

Introduction

With the aid of few Windows API calls it is easy to read and write the memory of other running processes. By monitorg the memory of such process it is easy to detect where memory locations containin 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.

Background

Windows provides programmers with few API 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

    [DllImport("Kernel32.dll")]    
    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 

    [DllImport("kernel32.dll")]
    public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, bool bInheritHandle, UInt32 dwProcessId);

    // Used to close the process    

    [DllImport("kernel32.dll")]    
    public static extern Int32 CloseHandle(IntPtr hObject);

    // Used to write into the memory of a process    

    [DllImport("kernel32.dll")]    
    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 show the procedure a gamer should us to accomplish this task.

Flow

The sequence to follow is very easy and evolves thrpugh the steps shown in he 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 two has been chosen since 1000 needs two bytes to be stored.

Search

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

Search2

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 combox where the user can choose the new value for his variable !

Search3

History

This is version 1.0. !

License

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

About the Author

pinturic


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

Occupation: Software Developer (Senior)
Location: Italy Italy

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralThanks !memberbi0s6:29 24 May '08  
GeneralWorld of Warcraft hackmemberArghs0:33 10 Nov '07  
GeneralCrash with big scanmemberWebtijn5:04 13 Jun '07  
GeneralRe: Crash with big scanmemberpinturic22:00 18 Jun '07  
GeneralAwesomememberthund3rstruck7:01 7 May '07  
GeneralRe: Awesomememberpinturic22:04 7 May '07  
GeneralCheatEnginememberThe_Mega_ZZTer7:25 6 May '07  
GeneralRe: CheatEnginememberpinturic7:42 6 May '07  
Generalomg THANK YOU!!!membersharpiesharpie6:58 6 May '07  
GeneralRe: omg THANK YOU!!!memberpinturic7:05 6 May '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 May 2007
Editor:
Copyright 2007 by pinturic
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project