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 


Need help with storing/loading of values for script

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

Joined: 03 Jan 2016
Posts: 5

PostPosted: Tue May 09, 2017 1:57 pm    Post subject: Need help with storing/loading of values for script Reply with quote

So I'm making a script to save and load spatial coordinates for the player in a first person game. The player should be able to save the coordinates by pressing a hotkey and restoring them with another hotkey.

The way I tackled the problem is by creating 3 scripts: the first performs aobscan and saves the address to the player structure while also allocating global variables for the other two scripts. The "saving" script should locate the current coordinates by looking at playerBase + various offsets I already found and save those values in global variables. The "loading" script should replace the current coordinates with the saved coordinates.

I already found the pattern for aobscan to get to the player structure and the offset of the coordinates. This is what the "enable" script looks like

Code:
[ENABLE]
aobscan(player,20 42 ?? 41 01 00 00 00 48 00 04 00)
globalalloc(_x,4)
globalalloc(_y,4)
globalalloc(_z,4)
label(_player)
registersymbol(_player)

player:
_player:

[DISABLE]
unregistersymbol(_player)


This seems to work as I can successfully reference the coordinates by typing _player+offset.

I have problems with the other two scripts.

The first problem is that what you usually do with scripts is toggling them: you either activate it to inject some assembly and then deactivate it to remove the injected assembly. Code is not executed when the script is activated but when the game naturally goes over the newly injected code.

What I need is something which is not toggled but rather just executed. I tried with the createthread command and sure enough it actually worked (in that it successfully copied the value from one address to another) but resulted in the executable crashing (i guess since i create a new thread and manipulate a register, even with backing up the value there are concurrency issues as the same register is being used on other threads, or maybe register values are thread based and this is not actually a problem?)

This is what the "saving" script looks like

Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(buffer,$4)
alloc(newmem, 2048)
registersymbol(buffer)

globalalloc(_x,4)

createthread(newmem)

newmem:
mov [buffer], eax
mov eax, [_player+1A0]
mov [_x], eax
mov eax, [buffer]

 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat

unregistersymbol(buffer)
dealloc(newmem)
dealloc(buffer)


This is the first time I mess with cheat engine's auto assembler so I need help in either making this mess work or thinking a whole different strategy to solve this problem Smile Maybe there is something very simple I'm missing.

Thanks
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 119

Joined: 09 Jun 2013
Posts: 3220

PostPosted: Tue May 09, 2017 5:34 pm    Post subject: Reply with quote

Code:
[ENABLE]
_x:
readmem(_player+1A0,4)
[DISABLE]
_x:
readmem(_player+1A0,4)

Code:
[ENABLE]
_player+1A0:
readmem(_x,4)
[DISABLE]
_player+1A0:
readmem(_x,4)
Back to top
View user's profile Send private message
inner_fears
How do I cheat?
Reputation: 0

Joined: 03 Jan 2016
Posts: 5

PostPosted: Tue May 09, 2017 7:06 pm    Post subject: Reply with quote

That worked like a charm. I had the feeling the solution would be incredibly simple but well Laughing Laughing

Thanks
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