Code Monkey home page Code Monkey logo

gamehackingcode's Introduction

Please read this before reporting any issues with the code, as it is quite likely to solve your issues!

About

Code for the book Game Hacking: Developing Autonomous Bots for Online Games.

Each project in this repository corresponds to a chapter or section in the book. The projects are referenced in the relevant pages.

Purpose

The exact purpose of each binary will be explained in the book. Some binaries are meant to be scanned and debugged, others simply exist as proof-of-concepts for lessons, and a few actually illustrate how certain algorithms look with different inputs.

Compiling

All of the example code should compile out-of-the-box on Visual Studio 2010, and any newer version. The exception is the two practice binaries for Chapter 1, which rely on the Allegro 5.0.10 library to be installed with the bin, lib, and include directories properly set up in your Visual Studio paths for additional include directories and additional linker directories.

If you can't compile yourself, all of the binaries are in the /bin/ directory. Debug binaries are in the /bin/DEBUG_BUILDS/ directory with included debug databases. Specifically, there is zero need to compile the binaries for the labs, and these are the ones likely to give you trouble (because of missing Allegro libs). The remaining code should compile fine, as you can poke it and recompile as much as you'd like.

Usage

You may need to grab this redistributable package from Microsoft to run the binaries if you don't have Visual Studio. If you get errors about loading fonts or map, move arial.ttf and game.map into the same directory as the binary and try again.

If you for same reason want to use the debug binaries, you will need the debug redistributable installed. This comes with Visual Studio 2010, and you can also find the stand-alone DLLs online. If this gives you trouble, I'd recommend either sticking to the release binaries, or compiling on your local version of Visual studio given the compile steps above.

gamehackingcode's People

Contributors

nickcano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gamehackingcode's Issues

allegro5/allegro.h

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'allegro5/allegro.h': No such file or directory C:\Users\Admin\Desktop\GameHackingCode-master\GameHackingCode-master\Chapter1_BasicMemory\game-BasicMem.cpp 3
Severity Code Description Project File Line Suppression State
Warning D9035 option 'Gm' has been deprecated and will be removed in a future release C:\Users\Admin\Desktop\GameHackingCode-master\GameHackingCode-master\Chapter1_BasicMemory\cl 1

chapter 2

i couldn't find the "ball hidden.." in ollydbg from reference text or search by binary.

Errors in Chapter 1, 2, and 3 binaries

Chapter 1 programs result in "error failed to initialize map!"
Chapter 2 and 3 programs result in "error failed to initialize font!"

Running the debug versions show "missing MSVCR100d.dll" for both errors; as expected.

Using the binaries for Allegro, I get the following errors when compiling:

C:\Users\user\Desktop\GameHackingCode\Chapter1_BasicMemory>g++ game-BasicMem
.cpp -o gamebasic.exe -IC:\MinGW\include
game-BasicMem.cpp: In function 'int main()':
game-BasicMem.cpp:95:16: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:108:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:119:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:124:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:130:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:135:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:140:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:145:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:150:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:155:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
game-BasicMem.cpp:211:68: warning: passing NULL to non-pointer argument 6 of 'in
t al_show_native_message_box(ALLEGRO_DISPLAY*, const char*, const char*, const c
har*, const char*, int)' [-Wconversion-null]
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x93):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xfb): undefined reference to al_draw_filled_rectangle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x144):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x1ac): undefined reference to al_draw_filled_rectangle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x1f5):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x25d): undefined reference to al_draw_filled_rectangle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x2a6):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x30e): undefined reference to al_draw_filled_rectangle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x362):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x3d6): undefined reference to al_draw_filled_rectangle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x3f3):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x445): undefined reference to al_draw_filled_circle'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x475):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x4b9): undefined reference to al_draw_text'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x4d6):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x51a): undefined reference to al_draw_text'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x8fd):
undefined reference to al_install_system' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x923): undefined reference to al_init_primitives_addon'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x949):
undefined reference to al_init_font_addon' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x94e): undefined reference to al_init_ttf_addon'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x974):
undefined reference to al_install_keyboard' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x9ac): undefined reference to al_load_ttf_font'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0x9f4):
undefined reference to al_create_timer' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xa33): undefined reference to al_create_display'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xa68):
undefined reference to al_create_event_queue' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xaa7): undefined reference to al_get_display_event_source'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xab9):
undefined reference to al_register_event_source' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xabe): undefined reference to al_get_keyboard_event_source'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xad0):
undefined reference to al_register_event_source' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xadf): undefined reference to al_get_timer_event_source'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xaf1):
undefined reference to al_register_event_source' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xb00): undefined reference to al_start_timer'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xb1d):
undefined reference to al_wait_for_event' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xbc2): undefined reference to al_is_event_queue_empty'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xbea):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xc0c): undefined reference to al_clear_to_color'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xc3f):
undefined reference to al_map_rgb' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xc8c): undefined reference to al_draw_text'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xc91):
undefined reference to al_flip_display' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xcb3): undefined reference to al_flip_display'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xd06):
undefined reference to al_show_native_message_box' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xd23): undefined reference to al_destroy_timer'
C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xd32):
undefined reference to al_destroy_display' C:\Users\user\AppData\Local\Temp\ccN7M3iA.o:game-BasicMem.cpp:(.text+0xd41): undefined reference to al_destroy_event_queue'
collect2.exe: error: ld returned 1 exit status

Ch5 _vector Struct

I am not sure if this is due to an update to the std library but I found that the _vector struct is incorrect and that there is some unknown DWORD value as the first value to be accessed given vectorAddress. Does anyone know what this is? After adding this value then the rest of the original code works. I have attached an image of what I mean.

I have changed vectorData to reserve 3 values and have values 0x123456 and 0x654321
Memory 1: Memory view of the vectorData
Memory 2: Location of the first data value in vectorData

capture

failed to initialize map

going off the book to do basic memory editing (page 11) when i go to the bin and run BasicMemory.exe I get a failed to initialize map error.

Virus

Virus detected in ZIP file when downloading.

Community forum?

does a forum or message board exist for help with some of the labs?

edit

I wanted clarify, help with solving them. Not running or compiling :P

Executables not working

downloading the repository and installing all the necessary requirements and following the instructions I noticed that in the 'bin' folder the executables: from chapter05 (AdvancedMemoryForensics.exe) to the executables of chapter11 do not work and the error appears: 0xc000007b.
what can be done to resolve the error?

std::vector scanning problem

Hey, could it be that the structure of std::vector changed?

This function doesn't seem to work for me.
Am I doing something wrong? Maybe for this code to work I need to use some c++ version or sdk in particular?

TY

`void readVector(DWORD vectorAddress)
{
struct _vector
{
DWORD* begin;
DWORD* end;
DWORD* tail;
};

_vector* vec = (_vector*)vectorAddress;

DWORD count = ((DWORD)vec->end - (DWORD)vec->begin) / sizeof(DWORD);
DWORD capacity = ((DWORD)vec->tail - (DWORD)vec->begin) / sizeof(DWORD);

printf("Vector has %d items and %d capacity\n", count, capacity);

for (int i = 0; i < count; i++)
	printf("\tValue at %d is %d\n", i, vec->begin[i]);

}`

Trouble Getting Binaries to Run

After cloning I figured I'd skip trying to get dependencies straight and try to launch the precompiled binaries.

I am running Windows 10 Professional. At the moment I am continually getting "failed to initialized map" for Chapter1_BasicMemory.exe. Am I missing a dependency here?

Additionally building them has proved difficult. I'm not familiar with Allegro, and using Visual Studio 2017 and the nuget version of Allegro to build it just results in even more errors. If I can figure it out I'll try to put up a PR, but it's really getting in the way of reading the book ๐Ÿ˜ข.

Freezing pointers crashes Chapter1_MemoryPointers.exe

Hi, hoping there's some support for this book as I recently purchased from No Starch Press. I believe I found the correct pointers for this exercise because I can close and restart Chapter1_MemoryPointers.exe and the pointers still affect the ball's X and Y values.

However, when I freeze the pointer values in Cheat Engine 6.7 and run the test (to win 50 times) the exe crashes. What am I doing wrong?

Let me know if you need any additional info.

Errata: function rScan pseudocode implementation

In "Chapter 1, Listing 1-1 pseudocode"

   list<int> pointerScan(target, maxAdd, maxDepth) {
โžŠ    for address = BASE, 0x7FFFFFF, 4 {
           ret = rScan(address, target, maxAdd, maxDepth, 1)
           if (ret.len > 0) {
               ret.pushFront(address)
               return ret
           }
      }
      return {}
   }
   list<int> rScan(address, target, maxAdd, maxDepth, curDepth) {
โž‹      for offset = 0, maxAdd, 4 {
            value = read(address + offset)
โžŒ          if (value == target)
                return list<int>(offset)
        }
โž      if (curDepth < maxDepth) {
            curDepth++
โžŽ          for offset = 0, maxAdd, 4 {
                ret = rScan(address + offset, target, maxAdd, maxDepth, curDepth)
โž              if (ret.len > 0) {
                    ret.pushFront(offset)
โž                  return ret
                }
            }
        }
        return {}
   }

In the middle of line 5 and 6, shouldn't the line correct to
ret = rScan(read(address + offset), target, maxAdd, maxDepth, curDepth) by replacing address + offset into read(address + offset)

Got multiple errors when trying to compile chapter 1 project

Hi,

I am trying to compile chapter 1 project, but it seems to be missing something (I already installed Allegro though NuGet)

Severity    Code    Description Project File    Line    Suppression State
Error (active)      identifier "BYTE" is undefined  Chapter1_BasicMemory    c:\Users\Tu Do\visual studio 2015\Projects\GameHackingExamples\Chapter1_BasicMemory\game-BasicMem.cpp   15  
Error (active)      identifier "ZeroMemory" is undefined    Chapter1_BasicMemory    c:\Users\Tu Do\visual studio 2015\Projects\GameHackingExamples\Chapter1_BasicMemory\game-BasicMem.cpp   103 
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   15  
Error   C2146   syntax error: missing ';' before identifier 'map'   Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   15  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   21  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   28  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   30  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   32  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   34  
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   86  
Error   C3861   'ZeroMemory': identifier not found  Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   103 
Error   C2065   'map': undeclared identifier    Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   113 
Warning C4996   'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. Chapter1_BasicMemory    c:\users\tu do\visual studio 2015\projects\gamehackingexamples\chapter1_basicmemory\game-basicmem.cpp   105 

I have been working on Linux, so I'm really not familiar with Windows toolchain, like VS. I hope you could help me on this. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.