Difference between revisions of "Tutorials:Cheat Engine Tutorial Guide x32"

From Cheat Engine
Jump to navigation Jump to search
(Step 8)
(Step 8)
Line 413: Line 413:
  
  
Now we scan for that base '018CA6F0' and you should find a static address.
+
Now we scan for that base '018CA6F0' and you should find a static address, but in real games you would keep going until a static base is found.
  
 
With that static address as the base my pointer will look like this.
 
With that static address as the base my pointer will look like this.

Revision as of 09:16, 19 March 2017

So let's go through the Cheat Engine Tutorial (x32).

So open Cheat Engine, then in the main menu select help then select Cheat Engine Tutorial.

Tutorials.CETutorialx32.01.png

Then attach to the Cheat Engine Tutorial process, it should be 'Tutorial-i386.exe'.

If unsure how to attach to the process see: How to attach to a process


Step 1

When the tutorial launches you should see some thing like this, you can just click the next button after reading the help text.

Save the password in later steps in case of crashes (from injections) and for restarting at a later time.

Tutorials.CETutorialx32.02.png


Step 2

So for step 2 you will see some thing like this.

Tutorials.CETutorialx32.step01.01.png

What we need to find is the health, and here it's an integer.

So setup the memory scanner to find an integer and for exact value scan then set the value to the current health value, most integers will be stored in a 4 byte variable, so let's start there.

Note: Integers can be stored in a 1 byte variable (byte), 2 byte variable (int16/short), 4 byte variable (int32/int), or 8 byte variable (int64/long).

When ready click the first scan button.

Tutorials.CETutorialx32.step01.02.png

You should see a list of addresses, in the found address list, like this.

Tutorials.CETutorialx32.step02.03.png

Now Click the hit me button, then reenter the current value and click the next scan button.

Note the red value in the list, this shows that the value has changed.

Tutorials.CETutorialx32.step02.04.png

After clicking next scan you may need to keep clicking hit me and rescanning tell the found address list is small enough to work with.

Tutorials.CETutorialx32.step02.05.png

Just double click the address in the found list to add it to the cheat table. Then change the value and freeze the address, double click the value in the address list to edit it, freeze it by clicking the enabler/freeze box.

Tutorials.CETutorialx32.step02.06.png

Now the next button should be enabled, click it to go to the next step. Click the hit me button again if the next button is not enabled already.

Step 3

When you start step 3 you should see the form looking like this.

Tutorials.CETutorialx32.step03.01.png

Like the help text said make sure to click the new scan button before starting new scans.

Tutorials.CETutorialx32.step03.02.png

This clears the found results to start scanning for a new value.

Here is where I suggest going ahead and clicking the hit me button, just to see how the value is decreased to help in determining what value type to scan for.

Tutorials.CETutorialx32.step03.03.png

Note that the value was decreased by an integer, that is a non fractional number.

So I would setup the scanner for 4 bytes and unknown initial value. Then click the first scan button.

Tutorials.CETutorialx32.step03.04.png

Now click the hit me button.

Then set the scan type to decreased value and click the nest scan button.

Tutorials.CETutorialx32.step03.05.png

Note the number of found addresses, this is kinda small for most games these days, the found results can easily be in the millions for most games.

Now just keep decreasing the value with the hit me button, and scanning for a decreased value, until the found results is small enough to work with.

Tutorials.CETutorialx32.step03.06.png

Now we just pick an address and change the value to see if it has the desired effect, this is just how it works.

Here is where I suggest that you always note the values (or just Ctrl+C) before changing them to set them back if they are not the right value, to keep from changing a bunch of unknown addresses and corrupting your save files when doing this in games.

The next button should become enabled as soon as you set the value to 5000. After changing the value and clicking the hit me button the progress bar should fill, but this is not needed.

Tutorials.CETutorialx32.step03.07.png

Now the next button should be enabled, click it to go to the next step. Click the hit me button again if the next button is not enabled already.


Step 4

When you start step 4 you should see the form looking like this.

Tutorials.CETutorialx32.step04.01.png

So click the new scan button. Then setup the scanner for a float, exact value, enter the current health value.

When setup click the first scan button.

Tutorials.CETutorialx32.step04.02.png

So just scan like before to find the health address, then add it to the address list.


Now click the new scan button again. Then setup the scanner for a double, exact value, enter the current ammo value.

When setup click the first scan button.

Tutorials.CETutorialx32.step04.03.png

So just scan like before to find the ammo address, then add it to the address list.

Now change the values to 5000, then the next button should become enabled. Then click the next button to progress to the next step.


Step 5

When you start step 5 you should see the form looking like this.

Tutorials.CETutorialx32.step05.01.png

So first find the value then add it to the address list.

Go ahead and save the table and the password at this point, just in case the debugger isn't setup right.

If you need help setting up the debugger see: Debugger options

After you have the address in the address list right click it then select find out what accesses this address.

Tutorials.CETutorialx32.step05.02.png

Cheat Engine will prompt you about attaching the debugger, just click the yes button.

Tutorials.CETutorialx32.step05.03.png

Then a debugger form will open, now click the change value button, and you should get code that shows up in the debugger form.

What we want is a write instruction. So we will be looking for some thing like one of the following:

mov [**],** add [**],** sub [**],** *** [**],**

Select the code line of the write instruction, you can click the show disassembler button to see the code in memory, then click the replace button.

Don't forget to click the stop button.

Tutorials.CETutorialx32.step05.04.png

The replace button will replace that line of code with NOPs.

Cheat Engine will prompt you for a name for the entry it will add in the advanced options list.

Enter a name and click the OK button.

Tutorials.CETutorialx32.step05.05.png

Now click the change value button back on the tutorial.

The next button should become enabled, then click the next button to advance to the next step.


When entries in the advanced options list are replaced, they will show up with red text.

Tutorials.CETutorialx32.step05.06.png

The advanced options list can be viewed by clicking the advanced options button in the status bar on the bottom left corner of the Cheat Engine main form.

To restore the original code for an entry in the list, right click the entry and select restore with original code.

Tutorials.CETutorialx32.step05.07.png

Note that the text is black after restoring.

Tutorials.CETutorialx32.step05.08.png


Step 6

When you start step 6 you should see the form looking like this.

Tutorials.CETutorialx32.step06.01.png

So first find the value then add it to the address list.

After you have the address in the address list right click it then select find out what accesses this address.

Tutorials.CETutorialx32.step06.05.png

Then click the change value button, to have the process access the address.

When choosing the code to find the base address for the pointer, try to select an instruction that doesn't write to the same register as the base address.

Here we're interested in the value between the square brackets ('[' and ']'), so here we want the value of EDX.

Tutorials.CETutorialx32.step06.02.png

The offset here is 0, if the instruction had some thing like this:

mov [edx+12C],eax

Then the offset would be '12C' (0x12C), note that this is in hex.

Now set the scanner for 4 bytes, exact value, check the hex check box, then take the value found and put that as the value to scan for.

When ready click the first scan button.

Look in the found address list for address with green text, these are static addresses.

Tutorials.CETutorialx32.step06.03.png

Add one to the cheat table, double click the address of the memory record that was added to the address list, copy the address then check the pointer check box, and paste the address in the pointers base address.

If you are unsure how to do this look here: How to add addresses to the address list

So my pointer will look like this.

["Tutorial-i386.exe"+XXXXXX]+0

It should be setup some thing like this, remember to set the offset to the offset you found.

Tutorials.CETutorialx32.step06.04.png

Click the OK button when the pointer is setup.

Now freeze the value at 5000 and click the change pointer button, the next button should become enabled.

If the next button doesn't become enabled then select another address from the found list, look for a green one that had it's value changed, and set it up like the last one and see if it points to the right value, if so change the value freeze and click the change pointer button.

Click the next button to advance to the next step.


Step 7

When you start step 7 you should see the form looking like this.

Tutorials.CETutorialx32.step07.01.png

Here we'll follow the the same procedures as step 5, but instead of clicking replace click the show disassembler button.

Tutorials.CETutorialx32.step07.02.png

This will open the disassembler view form at the instruction's address.

Tutorials.CETutorialx32.step07.03.png

With the instruction selected press Crtl+A, to open an auto assembler form.

In the auto assembler form menu select template then select full injection.

Tutorials.CETutorialx32.step07.04.png

This will generate some script to start you out.

Tutorials.CETutorialx32.step07.05.png

Now we need to add some code that will increase the value by 2, then remove the original code that decreases the value.

For increasing the value we can use INC or ADD.

So let's try some thing like this.

... newmem: add [ebx+478],2 //// Here Cheat Engine will assume that the value size is 4 bytes (dword) code: //sub dword ptr [ebx+00000478],01 jmp return address: jmp newmem nop nop return: ...

Now add the script to the cheat table.

If you are unsure how to do that look here: How to add script to table

Then enable the script and click the hit me button.

This should enable the next button, so click the next button to go to the next step.


Step 8

When you start step 8 you should see the form looking like this.

Tutorials.CETutorialx32.step08.01.png

So here we will follow the same steps as step 6, except we'll see what accesses the base address we find, and we'll keep repeating this until a static base is found.

So here is my first debugger output.

00425EB2 - B8 A00F0000 - mov eax,00000FA0
00425EB7 - E8 3488FEFF - call Tutorial-i386.exe+XXXXXX
00425EBC - 89 46 18  - mov [esi+18],eax  <<<<<<
00425EBF - 8D 55 D4  - lea edx,[ebp-2C]
00425EC2 - E8 493E0100 - call Tutorial-i386.exe+XXXXXX

EAX=00000441
EBX=01869F80
ECX=00000000
EDX=00000441
ESI=01829F68  <<<<<<
EDI=005DF300
ESP=0160F6E4
EBP=0160F71C
EIP=00425EBF

I did find a static base on the first scan of the base address but I remember this being a false base. So here what we want is a base address in the form of 'process.exe+offset', you can try one of the others that look like 'module.dll+offset' but I want to say that here they will prove to be false pointers. And yes most newer games will have many false values and pointers.

And the debugger output from the address holding: 01829F68

00425E73 - E8 98270F00 - call Tutorial-i386.exe+XXXXXX
00425E78 - EB 5B - jmp Tutorial-i386.exe+XXXXXX
00425E7A - 83 3E 00 - cmp dword ptr [esi],00  <<<<<<
00425E7D - 74 56 - je Tutorial-i386.exe+XXXXXX
00425E7F - 8B 36  - mov esi,[esi]

EAX=000000CA
EBX=01869F80
ECX=7EFDD000
EDX=00006D0C
ESI=018332A0  <<<<<<
EDI=005DF300
ESP=0160F6E4
EBP=0160F71C
EIP=00425E7D

And the debugger output from the address holding: 018332A0

00425E31 - E8 DA270F00 - call Tutorial-i386.exe+XXXXXX
00425E36 - E9 9A000000 - jmp Tutorial-i386.exe+XXXXXX
00425E3B - 83 7E 14 00 - cmp dword ptr [esi+14],00  <<<<<<
00425E3F - 0F84 90000000 - je Tutorial-i386.exe+XXXXXX
00425E45 - 8B 76 14  - mov esi,[esi+14]

EAX=00006F01
EBX=01869F80
ECX=7EFDD000
EDX=0000AAB3
ESI=018BA4F8  <<<<<<
EDI=005DF300
ESP=0160F6E4
EBP=0160F71C
EIP=00425E3F

And the debugger output from the address holding: 018BA4F8

00425DF0 - E8 1B280F00 - call Tutorial-i386.exe+XXXXXX
00425DF5 - E9 DB000000 - jmp Tutorial-i386.exe+XXXXXX
00425DFA - 83 7E 0C 00 - cmp dword ptr [esi+0C],00  <<<<<<
00425DFE - 0F84 D1000000 - je Tutorial-i386.exe+XXXXXX
00425E04 - 8B 76 0C  - mov esi,[esi+0C]

EAX=00005FAA
EBX=01869F80
ECX=7EFDD000
EDX=00014D08
ESI=018CA6F0  <<<<<<
EDI=005DF300
ESP=0160F6E4
EBP=0160F71C
EIP=00425DFE


Now we scan for that base '018CA6F0' and you should find a static address, but in real games you would keep going until a static base is found.

With that static address as the base my pointer will look like this.

[[[["Tutorial-i386.exe"+XXXXXX]+C]+14]+0]+18

Tutorials.CETutorialx32.step08.02.png

After you have found the pointer, freeze it at 5000, then click the change pointer button. If you found the right base the next button should become enabled after about 2 seconds. So click the next button to go to the next step.

Step 9

When you start step 9 you should see the form looking like this.

Tutorials.CETutorialx32.step09.01.png

So here like the help text says there is far more then one solution.

First we need to find one of the addresses and add it to the table.

If you are having trouble finding an address, remember to try different value types, and don't forget to start new scans.

Then like in step 7 we want to see what accesses the address, to find the function that writes to the actor's health.

Go ahead and save the password if you want to try different ways, this is the last step in the tutorial.

So here it's good to understand what we're actually looking for to tell allies and combatants apart.

When the game or engine is written, actors and players mite be written like this.

//// Actor, base for all actors class Actor(object){ string Name = 'Actor'; Coord Coords = new Coord(0, 0, 0); float Health = 100.0; ... } //// Player class Player(Actor){ //// Player inherits form Actor string Name = 'Player'; int Team = 1; ... }

The team it self could be a structure, say if it's declared as an object class like the 'Coords' variable, which we would want to look for a pointer to the actor's team structure.

So one way we could do this is to find the team id or team structure in the player structure.

Find the team id in the player structure

After you have found the function that decreases health.

Right click the instruction in the disassembler view form, and select find out what addresses this instruction accesses.

Tutorials.CETutorialx32.step09.02.png

Then click the attack button for all 4 values.

You should have all 4 addresses in the debugger list.

Tutorials.CETutorialx32.step09.03.png

So go ahead and add them to the address list.

Tutorials.CETutorialx32.step09.04.png

Then let's open the dissect data structure form.

Tutorials.CETutorialx32.step09.05.png

You'll get some pop ups, after going thought them you should see a form like this. Note that I had to expand the width of the form to be able to move the columns.

Tutorials.CETutorialx32.step09.06.png

So here we can see that the team variable is at offset 0x10 of the structure.

Now we need to add some injection code to a script, then add some code that checks the team variable of the structure, to determine which actors are allies and which are combatants.

So we want some this like this.

Tutorials.CETutorialx32.step09.07.png


So with this script enabled, when the game writes to an actors health here is what will happen after the jump to the hook code:

  1. Save (PUSH) the EFLAGS register, not completely needed but still a good habit when comparing.
  2. Check if actor is on team 1.
    1. If actor is on team 1, then we set the new value to 5000 in a floating point format.
  3. Check if actor is on team 2.
    1. If actor is on team 2, then we set the new value to 0 in hex format. (float 0 == int 0 == hex 0)
  4. Restore (POP) the EFLAGS register, this is completely needed if the register was PUSHed.


With this script enabled, click the restart game and autoplay button, then you should see the form change and look like this.

Tutorials.CETutorialx32.step09.08.png

So click the next button to complete the tutorial.

Then you should see a form telling you that you have completed the tutorial.


Find a difference in the registers

After you have found the function that decreases health.

Right click the instruction in the disassembler view form, and select find out what addresses this instruction accesses.

Tutorials.CETutorialx32.step09.02.png

Then click the attack button for all 4 values.

You should have all 4 addresses in the debugger list.

Tutorials.CETutorialx32.step09.03.png

Now let's look at the registers to see if we can find a difference in the allies and combatants.

Select each address individually and press Ctrl+R.

Arrange the forms to make it easier to compare.

Tutorials.CETutorialx32.step09.b.01.png

So here we can see that ESI is 1 for the combatants.

So a script like this should work.

Tutorials.CETutorialx32.step09.b.02.png


So with this script enabled, when the game writes to an actors health here is what will happen after the jump to the hook code:

  1. Save (PUSH) the EFLAGS register, not completely needed but still a good habit when comparing.
  2. Check if ESI register is 1.
    1. If ESI register is 1, then we set the new value to 0 in hex format. (float 0 == int 0 == hex 0)
    2. If ESI register is not 1, then we assume the actor is an ally so we set the new value to 5000 in a floating point format.
  3. Restore (POP) the EFLAGS register, this is completely needed if the register was PUSHed.

With this script enabled, click the restart game and autoplay button, then you should see the form change and look like this.

Tutorials.CETutorialx32.step09.08.png

So click the next button to complete the tutorial.

Then you should see a form telling you that you have completed the tutorial.


See also

Syntax Highlighter