GameTrainer:训练游戏的工具(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/gametrainer-a-tool-to-train-games-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1531 个词 阅读量 0GameTrainer:训练游戏的工具(译文)
原文地址:https://www.codeproject.com/Articles/18675/GameTrainer-A-Tool-to-Train-Games
原文作者:pinturic
译文由本站 robot-v1.0 翻译
前言
An easy way to train games
一种简单的游戏训练方法
介绍(Introduction)
借助很少的Windows API调用,可以轻松读写其他正在运行的进程的内存.通过监视此类进程的内存,可以很容易地检测出内存位置在游戏中包含特殊变量(子弹,黄金,生命等)的位置;一旦找到变量,就可以用新值覆盖它.(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.)
背景(Background)
Windows为程序员提供了很少的API,这些API可用于访问以读取和写入另一个正在运行的进程的内存:下一段显示了所使用的API以及如何使用平台调用以便在C#中使用它们.(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
[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 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
已选择,因为1000需要存储两个字节.(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 !)
历史(History)
- 6(6)日(th)2007年5月:1.0版(May, 2007: Version 1.0)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C# C#2.0 Windows .NET .NET2.0 Visual-Studio VS2005 Dev 新闻 翻译