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 


(solved)How can I compare my variable in AA?

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

Joined: 03 May 2022
Posts: 23

PostPosted: Mon May 16, 2022 7:49 pm    Post subject: (solved)How can I compare my variable in AA? Reply with quote

If I do something like this, it crashes. Tried many similar variants too.

cmp [cnt],0
ja exit
inc [cnt]

I'm setting a variable to single byte with 0 value to start and naming it cnt. Example,

cnt:
db 0

When the script runs the first time it should change my variable to a 1 so it knows to JA each time after that. I have the variable also declared up top with registersymbol and label, but also tried other things like globalalloc to no avail.

I never have trouble comparing other things like registers and addresses. Seems to be a problem when I'm creating the variable myself?


Last edited by Devon999 on Tue May 17, 2022 1:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 334
Location: Somewhere....

PostPosted: Mon May 16, 2022 9:10 pm    Post subject: Reply with quote

in order to use a custom variable, it has to belong to an area in memory, usually a simple alloc() call like this should work
Code:

[ENABLE]
alloc(mem,$1000)
label(cnt)
label(GoExit)
registersymbol(cnt)

mem:
cmp byte [cnt],0
ja GoExit
inc byte [cnt]

GoExit:
//put the jump back to game code, etc
//jmp return_address

//define variable here with initial value of zero, and one byte of size
cnt:
db 0

//finally redirect your game code to the mem
//game_address:
//jmp mem


[DISABLE]

//restore game address
//game_address:
//.......

unregistersymbol(cnt)
dealloc(mem)

unless there is a game-specific issue, this should not crash


Last edited by TsTg on Tue May 17, 2022 11:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon May 16, 2022 11:28 pm    Post subject: Reply with quote

fyi, that script will likely crash as you didn't add label(exit)

exit is a system export and je exit will jump to that fuction

and exit: will change the write pointer to the address of that function, then cnt will get the address of exit, and write a 0 there

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Tue May 17, 2022 8:51 am    Post subject: Reply with quote

I got it working and it seems like the difference maker was adding the "byte" reference for the compares and inc. Unless I'm missing something, that was the fix. Thank you.
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 334
Location: Somewhere....

PostPosted: Tue May 17, 2022 11:09 pm    Post subject: Reply with quote

Dark Byte wrote:
fyi, that script will likely crash as you didn't add label(exit)

exit is a system export and je exit will jump to that fuction

and exit: will change the write pointer to the address of that function, then cnt will get the address of exit, and write a 0 there

thanks DB, i missed the exit label, was a bit in a hurry Razz
i fixed the script and changed 'exit' for safety, as for the overwriting part, i have commented the sample //jmp return_address , so he could replace that by the actual return jump.
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