Take the 2-minute tour ×

So, some background: I'm using a memory scanner called cheat engine to get real-time values for game stats (e.g. hp, mana, exp) in a non open-source video game that I'm trying to make a bot for.

For my bot to effectively use this information, I need to get it from cheat engine (or any memory scanner with similar functionality) to my bot code in a timely manner.

Now, one obvious way to do that would be to save all of the information to a file and then load the file in my bot code, but since this data needs updating about every half second or so, that isn't a real solution.

What I really need is either a terribly convenient memory scanner that allows you to use the information you uncover as a set of variables in some programming language (preferably java, c, or matlab), or a way to access the memory addresses found in one of the above languages.

This latter option should hopefully be doable, as cheat engine gives the memory address, controlling process ID, and data type.

share|improve this question
MATLAB would be a very poor choice for this, I think. I don't think MATLAB (or Java for that matter, but I'm no Java expert) lets you directly interact with memory. Even if it could, the overhead you get from running MATLAB on top of the game and cheat engine would make it expensive. I'd do this in C. –  Dang Khoa Aug 31 '11 at 19:02
If the data keeps moving, you're almost certainly going to have race conditions where it moves between the time you scan for it and the time you use the results. Depending on exactly what you want to do with the data, this could result in just momentary misbehavior by your bot, or complete crashes of the bot and/or the game... –  R.. Aug 31 '11 at 19:05
@strictlyrude27 I'd figured as much; I only mentioned MATLAB because I've written a great deal of the AIs behaviors in it, and I doubt java can touch memory since it runs on a VM. I'll probably end up doing with stuff in c. –  zergylord Aug 31 '11 at 19:56
@R.. yeah, luckily I know the range the data should be in so I can discard spurious queries. And to be clear, I'm just looking at the values of a few integers, no complex data structures. Also, I'm not trying to modify any of the values I obtain. –  zergylord Aug 31 '11 at 19:59
Why not use lua which is built into Cheat Engine to do what you want? Lua is a pretty cool language. You haven't indicated how tightly your AI is to MATLAB. Is there some reason you need matlab? If there is, write a small ASCII socket program between matlab and cheatengine and you're good to go. More exotic approach is to write a JNI/Java interface around CheatEngine, run it in java, and run all of it out of Matlab. Depends on your needs. –  John Aug 31 '11 at 20:50
show 2 more comments

6 Answers

up vote 9 down vote accepted

This question doesn't have an easy answer. As far as I can tell you are very new to this area, so what you really need is a proper introduction to the subject, and for that I recommend reading Exploiting Online Games: Cheating Massively Distributed Systems.

It's an awesome book and it shows in a detailed manner how game hacks work, and it dedicates an entire chapter on how to build bots.

If you want to write an application to read/write data to those memory addresses you need to investigate functions like ReadProcessMemory() and WriteProcessMemory(). Whatever language you to choose to implement your bot needs to provide access to the Windows API. This is needed because you have to manipulate another process' memory space.

There are lots of tutorials out there that shows how to do this using C and C++, since they are the preferred languages to do this kind of stuff. Another option is to use a macro tool if you want something simple to play the game for you.

Modern computer games implement their own anti-cheat mechanisms to make it a little more difficult for people like you (and me). And since this book presents attack and defense techniques I recommend it to anyone interested on how to exploit computer games. The book is fully loaded with code examples.

I'm sorry for not providing more information but I was criticized once in the past for helping people with your curiosity and I would also never do a better job than the authors of the book explaining how to do this stuff.

share|improve this answer
add comment

Try using the Lua interface to get what you need.

Here's an example (I have not tried it, but I'm assuming it works....)


share|improve this answer
Eh, that example doesn't actually do what I need; its focused on mainly a GUI for code injection, whilst I need a Lua function that returns the current value of a memory address obtained via cheat engine. –  zergylord Aug 31 '11 at 22:15
add comment

You can probably use COM with a script in Lua (with LuaCOM) on one side and Matlab or C on the other

share|improve this answer
add comment

You would need to use a debugging library to do that. You would set a watchpoint on your variable's location, and when it triggers, you would get its value.

scanmem does that for Linux.

Unfortunately, many closed-source games go to great lengths to avoid the use of debuggers, so this won't probably work on your game.

share|improve this answer
add comment

Have you tried Visual VM?


share|improve this answer
add comment

Cheat Engine is open source, so what you do is look in the source code of Cheat Engine, and look how the memory dump thing works.

However, it is highly non-trivial to monitor a live process that you are not controlling, so unless you are a black hat code wizard, level 11, I suspect that it won't work.

Even if You say You want to look at a few integers that you can guess looking at memory dump, it is a lot harder to find that area programmatically, consistently, while possibly retracking every so often as the data may be copied or moved when the state of the program changes.

Also read this encouraging citation from Cheat Engines FAQ:

Q:Will Cheat Engine work on online games?

A:Most of the time, no

But anyway, try it - it sounds fun and I am sure you will learn something, and there is always a chance that you'll make it work :-)

share|improve this answer
add comment

Your Answer


