Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Making pointer using auto assemble

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Beginner999
Newbie cheater
Reputation: 0

Joined: 27 Jul 2018
Posts: 21

PostPosted: Sun Dec 19, 2021 1:27 pm    Post subject: Making pointer using auto assemble Reply with quote

So I'm following the tutorial in the video to find a pointer for gil (final fantasy 7): Lua Tutorial: Coding a Trainer from Scratch in Cheat Engine! [Terraria]


And I could not make the pointer work like it should be. What could be wrong? :?

[code]
alloc(newmem,$1000,INJECT)
registersymbol(newmem)
define(pgil,newmem+100)
registersymbol(pgil)

label(code)
label(return)

newmem:

pgil:
dd 0

code:
mov [rdx+0C],ebx
mov rbx,[rsp+30]
mov [pgil],rdx //storing address to pgil
jmp return

INJECT:
jmp newmem
nop 3
return:
registersymbol(INJECT)
[/code]
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Dec 19, 2021 2:59 pm    Post subject: Reply with quote

Instructions in the auto assembler are written sequentially to a specified address. For example:
Code:
alloc(newmem,1024)

newmem:
  sub ecx,3
  mov [edi],ecx
"newmem" is a symbol defined to be the address of some memory CE allocated in the target process. The sub and mov instructions get written into this memory: the sub instruction gets written to the address newmem, and the mov instruction gets written after it at newmem+3 (because that sub instruction takes up 3 bytes).

In your script:
Code:
label(code)
This declares the symbol "code" is a label. This does not define an address for the symbol- it only declares that this symbol will be used in your script.
You can define an address for labels by specifying them under a symbol that does have a defined address:
Code:
alloc(newmem,1024)
label(label1)
label(label2)

newmem:
label1:
  sub ecx,3
label2:
  mov [edi],ecx
Here, label1 is defined to be the same address as newmem, and label2 is defined to be the address newmem+3 (again, that sub instruction takes up 3 bytes).

In your script:
Code:
newmem:

pgil:
dd 0

code:
  mov [rdx+0C],ebx
  ...
newmem is some allocated memory, pgil is defined to be newmem+100, and code is a label that is defined to be pgil+4 or equivalently newmem+104 (dd takes up 4 bytes).

At the injection point, you jump to newmem. However, the code you wanted to execute was written to newmem+104. Nothing was written to newmem. This means a jump to newmem jumps to a bunch of 0 bytes, crashing the game.

TLDR: put code directly under newmem.
Also, nothing defines INJECT. You probably forgot the aobscan.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Beginner999
Newbie cheater
Reputation: 0

Joined: 27 Jul 2018
Posts: 21

PostPosted: Sun Dec 19, 2021 3:58 pm    Post subject: Reply with quote

understood, thank you. :D
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites