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 


How do I automatically get the Current Address of a pointer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
RegretNeedsHelp
How do I cheat?
Reputation: 0

Joined: 08 May 2023
Posts: 5

PostPosted: Mon May 08, 2023 4:59 pm    Post subject: How do I automatically get the Current Address of a pointer? Reply with quote

I have this script here for my trainer

RewardBox = getAddressList().getMemoryRecordByDescription("RewardBoxBitfield").CurrentAddress

and it works with bitfields to toggle on and off certain flags, essentially I can open the reward box whenever. When the reward box is unloaded/reloaded by me leaving the map and entering to spawn it again, my trainer doesn't get the new address. Toggling a flag brings back a larger number than usual. How would I automatically get the new address without executing the trainer script again? by the way I am using pointers

_________________
To make bread one must make thyself - Sun Tzu
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Mon May 08, 2023 10:19 pm    Post subject: Reply with quote

You could register a symbol based on the final address in the pointer chain and then use that as a reference to the address. The other option is to use a copy injection script to pull the address from a register and assign the address to an allocated section of memory.
Code:

aobscan(aob_symbol, process, aob_bytes)
alloc(newmem,$1000,aob_symbol
alloc(my_symbol,4/8) -- delete as appropriate. 4 is for 32-bit, 8 for 64-bit
...
newmem:
  push rax                                              // Store value in rax
  mov rax,my_symbol                                     // Move address of my_symbol into rax
  mov [rax],register_which_holds_pointer_address        // Move value of register into rax
  pop rax                                               // Restore rax
...
registersymbol(aob_symbol)
registersymbol(my_symbol)
...


Of course, a lot of code here has been omitted, but this will give you an idea of how to achieve it.
Back to top
View user's profile Send private message
RegretNeedsHelp
How do I cheat?
Reputation: 0

Joined: 08 May 2023
Posts: 5

PostPosted: Tue May 09, 2023 3:11 pm    Post subject: Reply with quote

LeFiXER wrote:
You could register a symbol based on the final address in the pointer chain and then use that as a reference to the address. The other option is to use a copy injection script to pull the address from a register and assign the address to an allocated section of memory.
Code:

aobscan(aob_symbol, process, aob_bytes)
alloc(newmem,$1000,aob_symbol
alloc(my_symbol,4/8) -- delete as appropriate. 4 is for 32-bit, 8 for 64-bit
...
newmem:
  push rax                                              // Store value in rax
  mov rax,my_symbol                                     // Move address of my_symbol into rax
  mov [rax],register_which_holds_pointer_address        // Move value of register into rax
  pop rax                                               // Restore rax
...
registersymbol(aob_symbol)
registersymbol(my_symbol)
...


Of course, a lot of code here has been omitted, but this will give you an idea of how to achieve it.


Thank you for the help but I also seemed to have unironically solved my own issue in a shorter manner, I couldn't reply to myself yet, but I made that RewardBox a local variable, and put it inside the checkbox(sender) function where I would check if the ToggleScript were activated. This also fixed my problems with "performing a bitwise operation on a nil value" where half the time I launch the trainer it connects all the values, and the other half of the time I get an error.

TLDR: I put made all the variables to the addresses local, and moved them to their proper function call, so their value is only read and updated when I click the specific boxes.

_________________
To make bread one must make thyself - Sun Tzu
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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