How to make an assembly code run manually

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
Mr. Alien
Cheater
Cheater
Posts: 37
Joined: Mon Jul 08, 2019 8:31 am
Reputation: 0

How to make an assembly code run manually

Post by Mr. Alien »

So, I was thinking on making a code where with the press of a button, I'll transfer my character's max health value into their current health value. I already got the pointers for both values (involving quite the hellish AOB shenanigans, I might add).

Originally, I wanted to make it happen automatically after every battle, hijacking an opcode that seems to be active every time a battle ends (replacing the register's value in a mov function) But I tried fiddling with it and the game crashes as a result.

It's the same principle with multiplying a value with a button, I guess, which I always wanted since I hate opening calculator every time.

I know you can just tell CE to allocate some unused memory space for my code, but I don't know how the game will get to that code. Or rather, the game should have nothing to do with the code altogether to prevent crashes.

Maybe you have to use Lua to do it? I know nothing about that unfortunately.

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Re: How to make an assembly code run manually

Post by TimFun13 »

Sounds like you might have injected into shared code.

But to run code use "createThread".
[Link]

User avatar
SunBeam
Administration
Administration
Posts: 4704
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4287

Re: How to make an assembly code run manually

Post by SunBeam »

I have a feeling his game is created with Unity Engine, which then will bring into discussion other aspects/issues. Thus not that simple to find an injection spot to his understanding, let alone use a thread with Lua without attaching/detaching to the mono thread to avoid crashes. Could you name your game?

GreenHouse
Expert Cheater
Expert Cheater
Posts: 857
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 889

Re: How to make an assembly code run manually

Post by GreenHouse »

Mr. Alien wrote:
Fri Apr 30, 2021 5:20 pm
. . .
You don't even need to do any of that. The easiest thing that anyone with basic knowledge could do is to use the basic aobscan template to create a script in a function that constantly accesses the base address of the character. Inside it create another alloc/registersymbol (1 byte is enough), and add a cmp at the beginning to compare that alloc.
Add that alloc into the address list, and give it the hotkey that you want. Like change 0 to 1 when pressing F1. Really basic code example:

Code: Select all

alloc(run,1)
registersymbol(run)

newmem:
cmp byte ptr [run],01
jne code
mov byte ptr [run],00
DO HEALTH SHENANIGANS HERE. Like 'mov' max health to the current health.

code:
bla bla bla
Just add that into the basic script that the template creates.

Mr. Alien
Cheater
Cheater
Posts: 37
Joined: Mon Jul 08, 2019 8:31 am
Reputation: 0

Re: How to make an assembly code run manually

Post by Mr. Alien »

Thanks a lot! I never thought about that!

Though I tried the code and it didn't work. Probably because my hp switch code is faulty. You're supposed to do it like this, right?

Code: Select all

push ax
mov ax,[base]+123
mov [base]+234,ax
pop ax
The [base] being the base address that points to the values, plus the offset.

I think that might be wrong since the value of [base] is just the address it's pointing to (addresses of max and current health). Meanwhile, I want to move not that address, but the value it has.

So, maybe I should've made something like this instead?

Code: Select all

push ax
push bx
mov ax,[base]+123
mov bx,[ax]
mov [base]+234,bx
pop bx
pop ax
The value is just two byte so I use the 16 bit registers.

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Re: How to make an assembly code run manually

Post by TimFun13 »

Mr. Alien wrote:
Fri Apr 30, 2021 9:41 pm
Thanks a lot! I never thought about that!

Though I tried the code and it didn't work. Probably because my hp switch code is faulty. You're supposed to do it like this, right?

Code: Select all

push ax
mov ax,[base]+123
mov [base]+234,ax
pop ax
The [base] being the base address that points to the values, plus the offset.

I think that might be wrong since the value of [base] is just the address it's pointing to (addresses of max and current health). Meanwhile, I want to move not that address, but the value it has.

So, maybe I should've made something like this instead?

Code: Select all

push ax
push bx
mov ax,[base]+123
mov bx,[ax]
mov [base]+234,bx
pop bx
pop ax
The value is just two byte so I use the 16 bit registers.
You need to iterate through the pointer. So more like this:

Code: Select all

push rax
mov rax,[base]
test rax,rax
jz @f
	mov ax,[rax+123]
	mov [rax+234],ax
@@:
pop rax
If these were not just example offsets then you might look at the first one as I would expect a word value (2 bytes) to have an offset that's divisible by 2. And always push and pop the full registry, if you look at what CE actually assembles you'd see it does the full registry and not the sub registries.

User avatar
SunBeam
Administration
Administration
Posts: 4704
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4287

Re: How to make an assembly code run manually

Post by SunBeam »

So which game is this about, again?..

Eric
Hall of Famer
Hall of Famer
Posts: 174
Joined: Thu Mar 02, 2017 11:01 pm
Reputation: 90

Re: How to make an assembly code run manually

Post by Eric »

You don't need scripting for this
Since you have both pointers add them as memoryrecords to the table
then give currentHealth a hotkey that 'sets value' and give it as value

Code: Select all

(description of record with max value)
(make sure to include the round braces)

also, you can multiply a value by 8 by setting it's value to

Code: Select all

value*8

Post Reply

Who is online

Users browsing this forum: No registered users