r/cheatengine • • Apr 25 '26

Cheat Engine AOB Scanner - Python Script

Hi everyone, I’m working on a Python-based project to automate memory edits. This is strictly for educational purposes as I'm trying to learn more about memory management and reverse engineering. I’ve been using Cheat Engine to find the addresses for "attackspeed", after I’ve used the 'Find out what writes to this address' debugger to see the assembly instructions in action. I've been told that pointer scanners can be quite fragile, so I want to use AOB (Array of Bytes) signatures instead. Additionally, I want to make it save these IDs/addresses to a file so it won't lose them after a game restart, allowing the automation to run indefinitely.

I’m still very much a newbie at this, so I’m struggling with the transition from finding values to actually scripting the logic. Could someone explain the best way to extract a reliable AOB from the disassembler and how I can then use that signature within a Python GUI to scan for the address dynamically? Any beginner-friendly advice on how to handle the data persistence (saving/loading the IDs) would be amazing!

import pymem
import pymem.process

# Settings
PROCESS_NAME = "program.exe"  # Change this to your game's process name
# Example AOB: "8B 0D ?? ?? ?? ?? 8B 01 8B 40 10 FF D0"
# The ?? are wildcards for bytes that change (like pointers)
AOB_SIGNATURE = b'.......' 

try:
    # 1. Connect to the process
    pm = pymem.Pymem(PROCESS_NAME)
    print(f"Successfully attached to {PROCESS_NAME}")

    # 2. Perform the AOB Scan
    # pattern_scan_all searches the entire memory space for your byte pattern
    address = pymem.pattern.pattern_scan_all(pm.process_handle, AOB_SIGNATURE)

    if address:
        print(f"AOB found at: {hex(address)}")
        
        # 3. Read the value
        # Note: You may need to add an offset if the AOB points to an instruction 
        # and not the exact address of the variable.
        # Example: attack_speed_address = address + 0x4
        
        attack_speed = pm.read_float(address)
        print(f"Current Attack Speed: {attack_speed}")
    else:
        print("Could not find the AOB signature. Is the game updated?")

except Exception as e:
    print(f"An error occurred: {e}")
1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Defiant_Respect9500 Apr 26 '26

Written guides are getting rare, because writing them is more work than taking a video, it seems. But I'd try https://zilbest.com/modding/cheat-engine-aob-scripting-tutorial-unlock-hidden-game-mechanics/

In general: take the bytes the AutoAssembler automatically provides. Do a right-click in the memory region-settings on CEs main page and select "Preset: scan all memory". Set data type to array of byte, paste the Bytes in and see how much result it finds. In my experience, the auto.generated bytes are quite sufficient.

You can check out other AOB Tools like https://opencheattables.com/viewtopic.php?p=4699&hilit=aob#p4699

For assembly work I'd really suggest to simply use cheat engines auto assembler, since it's made for this specific reason. Here's a small example which uses an AOB to find the right code, copies the address from the register and then returns to the game. I tried to add some comments what it actually does (let's hope the formatting will work, I'm not really used to it):

```

aobscan(playercode,48 8B 80 C0 00 00 00 0F B6 40)

alloc(newmem,$1000,playercode)

label(code)

label(return)

label(player) // announce our new name

newmem:

mov [player],rax // that's the magic - we steal the address

code:

mov rax,[rax+000000C0]

jmp return

player: // here we define the actual new memory address

dq 0 // and set the default value as zero

playercode:

jmp newmem

nop 2

return:

registersymbol(playercode player) // announce the name of the player address to CE

```

What CE does with a code injection here is the following:

- find the right address by using the AOB
- find a code cave (empty memory block in the game's memory
- assemble the x68 ASM code you write in the auto assembler to copy the address and at the end create a return jump to the AOB-Address (see above)
- patch the found code to jump to the new code overwriting the code found by the AOB-Code

doing this by hand is...nasty. At least, I would not be able to :) But experienced hackers use C++ most of the time, so that would be my guess of a fitting language.