View previous topic :: View next topic |
Author |
Message |
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Mon May 16, 2022 7:49 pm Post subject: (solved)How can I compare my variable in AA? |
|
|
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 |
|
|
TsTg Master Cheater Reputation: 5
Joined: 12 Dec 2012 Posts: 334 Location: Somewhere....
|
Posted: Mon May 16, 2022 9:10 pm Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Mon May 16, 2022 11:28 pm Post subject: |
|
|
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 |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Tue May 17, 2022 8:51 am Post subject: |
|
|
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 |
|
|
TsTg Master Cheater Reputation: 5
Joined: 12 Dec 2012 Posts: 334 Location: Somewhere....
|
Posted: Tue May 17, 2022 11:09 pm Post subject: |
|
|
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
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 |
|
|
|