|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sat Aug 12, 2017 9:24 pm Post subject: comparing signed qword |
|
|
Code: | {cmp - fcom - cmpsd - cmppd} qword ptr [reg+off],some signed qword bytes |
of course if its 64-bit process i would use comisd and matter finish, so any ideas?
all above instructions were tested.
_________________
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sat Aug 12, 2017 11:28 pm Post subject: |
|
|
I'm sure there are better methods but for something that'll work
https://stackoverflow.com/questions/12944690/working-with-qwords
mentions a way to add/subtract arbitrary length values. if A-B == 0 then they're equal, if A-B > 0 then A > B else A < B and A-B is negative
putting that together gives something like
Code: | <?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<ID>4</ID>
<Description>"Auto Assemble script"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>globalalloc(test,1024)
[ENABLE]
label(data)
label(strings)
label(equal)
label(greater)
label(less)
label(docall)
test:
// load first vlaue
mov eax, [data+4]
mov edx, [data]
// add second
sub edx, [data+8]
sbb eax, [data+C]
// save result
mov [data+10], edx
mov [data+14], eax
// check
mov ecx, edx
or ecx, eax
cmovz ecx, [strings+0] //equal
je docall
// if positive A greater
// positive if edx < 0x80000000
cmp eax,80000000
cmovb ecx, [strings+4] // positive, greater
cmovnb ecx, [strings+8] //negative, less
docall:
push 0 // uType OK
push 0 // caption
push ecx // text
push 0 // hwnd
call MessageBoxA
ret
data:
dq #55
dq #635
dq 1
equal:
db 'They are eq',0
greater:
db 'First is gtr, pos',0
less:
db 'First is les, neg',0
strings:
dd equal
dd greater
dd less
registerSymbol(data)
createThread(test)
[DISABLE]
unregisterSymbol(data)
</AssemblerScript>
<CheatEntries>
<CheatEntry>
<ID>5</ID>
<Description>"No description"</Description>
<LastState Value="55" RealAddress="00140053"/>
<ShowAsSigned>1</ShowAsSigned>
<VariableType>8 Bytes</VariableType>
<Address>data</Address>
</CheatEntry>
<CheatEntry>
<ID>7</ID>
<Description>"No description"</Description>
<LastState Value="635" RealAddress="0014005B"/>
<ShowAsSigned>1</ShowAsSigned>
<VariableType>8 Bytes</VariableType>
<Address>data+8</Address>
</CheatEntry>
<CheatEntry>
<ID>6</ID>
<Description>"No description"</Description>
<LastState Value="-580" RealAddress="00140063"/>
<ShowAsSigned>1</ShowAsSigned>
<VariableType>8 Bytes</VariableType>
<Address>data+10</Address>
</CheatEntry>
</CheatEntries>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sat Aug 12, 2017 11:47 pm Post subject: |
|
|
ops!
i apologize FreeER, forgot to mention its double data type.
a signed double value:
dec -32 hex 0xC040000000000000
OldCheatEngineUser wrote: | Code: | {cmp - fcom - cmpsd - cmppd} |
|
tried to compare it using these instructions, but CE gave me syntax error.
i dont know if its a bug or what.
seems i cant use any of:
Code: | {cmp - fcom - cmpsd - cmppd} |
with:
Code: | qword ptr [reg+off] |
of course i have a solution in my mind, but i dont want it.
which is converting qword to dword and then compare it.
i guess i should load it then convert it and then store it back to the original location and do my compare.
once again, i apologize.
_________________
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 |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4300
|
Posted: Sun Aug 13, 2017 7:36 am Post subject: |
|
|
Look at the example using fucomip in this post.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sun Aug 13, 2017 8:40 am Post subject: |
|
|
thanks PP.
ill test it now, and edit my post after testing.
EDIT AFTER 10 MINS
fucomip give me syntax error, changed it to fucomp.
but still this wont give me what i want, and what is unordered.
i need to compare to see if [register+offset] is equal to -32 as a double data type.
_________________
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sun Aug 13, 2017 9:44 am Post subject: |
|
|
This seems to work, without the st(1) for the fucomip instruction you do get a compile error.
Code: |
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<ID>217</ID>
<Description>"compare doubles using fpu"</Description>
<Options moHideChildren="1"/>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>// x86 signed qword compare
// https://stackoverflow.com/questions/12944690/working-with-qwords
// http://forum.cheatengine.org/viewtopic.php?p=5730174#5730174
globalalloc(test,1024)
[ENABLE]
label(data)
label(strings)
label(equal)
label(greater)
label(less)
label(docall)
test:
// load second value so that first is in ST(0)
fld qword ptr [data+8]
// load first into ST(0)
fld qword ptr [data]
// check
fucomip st(1)
cmovz ecx, [strings+0] //equal
je docall
cmova ecx, [strings+4] // positive, greater
cmovna ecx, [strings+8] //negative, less
docall:
push 0 // uType OK
push 0 // caption
push ecx // text
push 0 // hwnd
call MessageBoxA
ret
data:
dq (double)-55
dq (double)-353
equal:
db 'They are eq',0
greater:
db 'First is gtr',0
less:
db 'First is les',0
strings:
dd equal
dd greater
dd less
registerSymbol(data)
createThread(test)
[DISABLE]
unregisterSymbol(data)
</AssemblerScript>
<CheatEntries>
<CheatEntry>
<ID>218</ID>
<Description>"No description"</Description>
<LastState Value="-55" RealAddress="016F0036"/>
<VariableType>Double</VariableType>
<Address>data</Address>
</CheatEntry>
<CheatEntry>
<ID>220</ID>
<Description>"No description"</Description>
<LastState Value="-353" RealAddress="016F003E"/>
<VariableType>Double</VariableType>
<Address>data+8</Address>
</CheatEntry>
</CheatEntries>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
Though if you have to deal with rounding issues like -32.00002412 or whatever then I'm not sure if you'd need more code... I googled to get this lol
Of course if you don't have to deal with rounding and you just need to know if it is or isn't equal to 0xC040000000000000 (not greater/less) then you could just break that into the 2 dwords C0400000 and 0 and check that way.
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sun Aug 13, 2017 10:29 am Post subject: |
|
|
thanks FreeER, yes fucomip without st(1) gives some errors.
i didnt know that, at least i learned something.
oh and thanks for your googling, and its not rounded.
FreeER wrote: | Code: | // load second value so that first is in ST(0)
fld qword ptr [data+8]
// load first into ST(0)
fld qword ptr [data]
// check
fucomip st(1)
cmovz ecx, [strings+0] //equal |
|
btw im not much familiar with stack level st 0,1,2,..7.
i was digging into this thing while ago, but i couldnt get much concept.
_________________
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sun Aug 13, 2017 11:02 am Post subject: |
|
|
The FPU uses a "stack" much like the stack you push and pop registers to except that it's limited to, I believe 8, values.
ST(0) is the value at the top of the stack ST(1) is the value under ST(0), etc. Many instructions implicitly use the top of the stack and sometimes the top two instructions on the stack, while a few do allow you to specify one or two positions in the stack directly using the ST(x) syntax.
fld is equivalent to some thing like "FpuPush" (made up instruction but).
It's not something I've spent much time trying to understand but I've picked up a couple bits of knowledge about it lol. I find the SSE concept much easier to understand since it works more like registers, but it's just got so many different instructions that uses them in more advanced (packed) ways that it can still get confusing lol
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sun Aug 13, 2017 11:19 am Post subject: |
|
|
FreeER wrote: | I believe 8, values.
ST(0) is the value at the top of the stack ST(1) is the value under ST(0) |
yea that what learned too, st(0) - st(7) and what pushed first gonna be on the top level which 0.
stack is more complex along with heap than registers.
there is many instructions i seen, c3 c2 c1 m... idk what else every level have complex set of instructions.
the idea of your code is great, tried to implement it, but i cant understand why do we need strings!
Code: | fld qword ptr [data+08] // loading -1024
fld qword ptr [data] // loading -32
fucomip st(1) // comparing st(0),st(1) which is -1024, -32
jg code // -32 should jump because its greater tho
fld dword ptr [esi+000004C0] |
but it messed up my game idk why lol.
ill work on it more, if no luck then ill give up lol.
please tell me about the strings, thanks tho.
_________________
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sun Aug 13, 2017 11:39 am Post subject: |
|
|
OldCheatEngineUser wrote: | but i cant understand why do we need strings! | You don't, I just used a message box to have feedback Instead of loading strings you could jump to different instructions or whatever you want
I think fucomip ST(1) only pops one of the values, not both so try
Code: | fucomip st(1) // comparing st(0),st(1) which is -1024, -32
fstp st(0) // remove the top of the stack
|
You can open the fpu stack and watch it when you step through the code to be sure however. It's also theoretically possible that the stack is full at that point in the program and you're losing 1 or 2 values by loading 2 for the check, it's not usually an issue but again debugging would help you determine that for sure.
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Sun Aug 13, 2017 11:55 am Post subject: |
|
|
ah i see, i didnt use the string hehe.
FreeER wrote: | I think fucomip ST(1) only pops one of the values, not both so try |
maybe destination value st(0) because it was pushed and loaded first, this make sense to me.
FreeER wrote: | You can open the fpu stack and watch it when you step through the code to be sure however. It's also theoretically possible that the stack is full at that point in the program and you're losing 1 or 2 values by loading 2 for the check, it's not usually an issue but again debugging would help you determine that for sure. |
true, i might have to debug it or just to see fpu registers and what values are there.
but im not ready to step-thro using hareware BP, and i think you are right about "stack is full" because on that function i saw many values/addresses were loading and being pushed on the stack.
im losing hope.
_________________
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 |
|
|
|
|
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
|
|