Page 1 of 1

Compare (CMP) register with multiple offset

Posted: Sat Jan 02, 2021 9:59 am
by Almahdi
is it possible to compare registers with multilevel offsets ?

Re: Compare (CMP) register with multiple offset

Posted: Sat Jan 02, 2021 12:27 pm
by aSwedishMagyar
Yeah it is. You just have to make sure that each level is guaranteed to be a valid pointer.

Say you have something that has 3 levels at +54, +1AC, and +8 with the base being in rcx, you would need to navigate like so:

push rax
mov rax,[rcx+54]
mov rax,[rax+1AC]
cmp [rax+8],1B //Whatever you need to compare with
pop rax
je code //Whatever kind of jump you need to do


The issue with this is if for some cases the +1AC level is not a valid pointer you will crash the game. You can do things like try except blocks or use 'IsBadReadPtr' to get around it but typically it's best to just find another compare.

Re: Compare (CMP) register with multiple offset

Posted: Sat Jan 02, 2021 2:53 pm
by Almahdi
thanks for the help .... it worked, i never thought we have to use the STACK function :D