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 


Cannot compare values

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

Joined: 10 Oct 2016
Posts: 10

PostPosted: Tue Aug 08, 2017 9:58 am    Post subject: Cannot compare values Reply with quote

Hi, I'm trying to compare the value to detect if the movement wasnt from player, I would let the program continue as normal. However, I cannot seem to make the cmp function to work as expected. Please help!

Doesn't work:
Code:
   
cmp [esi+22],h3hota.exe+29CCF4 //{ [00000006] }
jne NPCMove
db 90 90 90 90
jmp moveExit


Code:

cmp byte ptr [esi+22],h3hota.exe+29CCF4 //(It becomes -0C { 244 })
jne NPCMove
db 90 90 90 90
jmp moveExit


Works:
Code:

cmp byte ptr [esi+22], 6
jne NPCMove
db 90 90 90 90
jmp moveExit
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Tue Aug 08, 2017 10:11 am    Post subject: Reply with quote

program.exe+offset is an address for an instruction.

you cant compare [value vs instruction]
that doesnt make sense.


EDIT HERE: i made a mistake while typing:
what make sense is:
cmp value vs value. this is not valid, wrote it by mistake
cmp address vs value.
cmp address vs address.

in other words:

%reg% %mem%
%reg% %reg%

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
kiennguyen1101
Newbie cheater
Reputation: 0

Joined: 10 Oct 2016
Posts: 10

PostPosted: Tue Aug 08, 2017 7:16 pm    Post subject: Reply with quote

Thanks for the reply, the instruction h3hota.exe+29CCF4 is a pointer (green address on the search box) and it points to an address with byte value. I see on the forum people would write code like this so I think it could work for me.
When I use
Code:
cmp [esi+22],h3hota.exe+29CCF4
the assembly automatically recognizes the second value as [00000006] which is correct value. However, the comparison still fail and I think the reason is because I was comparing a byte to a qword.
Adding byte ptr to the code
Code:
cmp byte ptr [esi+22],h3hota.exe+29CCF4
and the second value becomes -0C { 244 }. Now I really don't understand why and what I need to do to use this comparison correctly.
I hope that clarifies my problem.
Thank you for your time and I appreciate your help.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Tue Aug 08, 2017 8:21 pm    Post subject: Reply with quote

EDIT: i think this means comparing the address,[module.exe+offset]
like:
compare value vs address
which is invalid if im correct.


kiennguyen1101 wrote:
I was comparing a byte to a qword.


ehmm, comparing byte to qword.
i cant say a word about comparing int-byte and int-qword, because im not that much sure about technical things that i know about this thing.

but comparing byte to qword (in case qword was double data type) can cause issues and the compare will give you wrong result.
make sure you compare two values of the same size and same data type.

about comparing module.name+offset i used and tried something like this, but i dont know why its not working with you.

and i think
Code:
"ModuleName.exe"+offset

you should use it with double quotes, but im not sure if it make any difference.

i think thats all what i got, but a question:
is esi+22 same as module+offset?
if so, then you dont need to do it this way.

are you sure module.exe+offset is not chaning the value each time when you play?

just make sure its not changing when its your turn or enemy.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
kiennguyen1101
Newbie cheater
Reputation: 0

Joined: 10 Oct 2016
Posts: 10

PostPosted: Wed Aug 09, 2017 12:35 am    Post subject: Reply with quote

Hi OldCheatEngineUser,
Quote:
you should use it with double quotes, but im not sure if it make any difference
it actually does not matter

Quote:
is esi+22 same as module+offset?

No, esi is a memory register and it holds whatever the value the instruction tells it to. Module+offset can either be an address (static variable in programming) or an instruction.

Quote:
are you sure module.exe+offset is not chaning the value each time when you play?

just make sure its not changing when its your turn or enemy.

It doesn't so that 's why im doing the cmp.

So do you have any idea on how I can solve this problem? Thank you.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Wed Aug 09, 2017 7:41 am    Post subject: Reply with quote

h3hota.exe+29CCF4 is an address. Normally, you should put it in square brackets if you want to compare the value at the address against something else, but there is no version of the cmp instruction that takes two r/m32 operands. If the value doesn't change, you can do this:
Code:
{$lua}
  return string.format('cmp dword ptr[esi+22],%d', readInteger('h3hota.exe+29CCF4'))
{$asm}

If the value can change during runtime:
Code:
push ebx
mov ebx,[esi+22]
cmp ebx,[h3hota.exe+29CCF4]
pop ebx
jcc whatever

PS: those db 90... are useless

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Wed Aug 09, 2017 8:17 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
EDIT: i think this means comparing the address,[module.exe+offset]
like:
compare value vs address
which is invalid if im correct.

so it was true
ParkourPenguin wrote:
h3hota.exe+29CCF4 is an address. Normally, you should put it in square brackets if you want to compare the value at the address against something else, but there is no version of the cmp instruction that takes two r/m32 operands.

awesome PP, that what i was missing square brackets, i know module+offset without brackets mean an address, and i know whatever instructions have an square brackets means values. but i didnt know that is possible to put module+offset into a bracket. so this is something new i learned now.

also putting to operands with square brackets will be invalid as i said earlier.

ParkourPenguin wrote:
Code:
push ebx
mov ebx,[esi+22]
cmp ebx,[h3hota.exe+29CCF4]
pop ebx
jcc whatever

i was thinking in something similar, but ... great one penguin Wink

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
kiennguyen1101
Newbie cheater
Reputation: 0

Joined: 10 Oct 2016
Posts: 10

PostPosted: Wed Aug 09, 2017 9:53 am    Post subject: Reply with quote

I changed the lua script a little but it worked! Thank you, ParkourPenguin.

Code:
{$lua}
  return string.format('cmp byte ptr[esi+22],%d', readBytes('h3hota.exe+29CCF4'))
{$asm}
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