|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Alphasoldier Advanced Cheater Reputation: 1
Joined: 07 Apr 2009 Posts: 95
|
Posted: Fri Aug 11, 2017 8:10 pm Post subject: Assembly Double comparison (Negate if negative) |
|
|
Been working on this for hours on end, learned a ridiculous amount, but still not enough to get this working.
I've been trying to simply check if a double amount is negative or positive, and then either add or subtract it from another double.
A ridiculously easy function that I'd easily get working with integers, but with these doubles I'm at a loss.
What I had so far looked like this:
Code: | newmem:
fld qword ptr [ebp-08] //Code that has the addition/subtraction that needs to be checked.
fldz
fcompp
jb goldRem
fld qword ptr [ebp-08]
fld qword ptr [eax+90] //Code that contains the value that gets changed
faddp
jmp code
goldRem:
fld qword ptr [ebp-08]
fld qword ptr [eax+90]
fsubp
code:
fstp qword ptr [eax+90]
jmp return
GameGold:
jmp newmem
nop
return:
registersymbol(GameGold)
|
This doesn't remotely work, and I found some things like:
fnstsw ax
test ah,41
But putting it after fcompp crashed things, and I don't even know why there's 41 right there.
Any help would be much appreciated.
Additionally, I know I could use fcomp, but I don't know if I'd have to use a value on the same line, or if it'll compare it by 0 if left blank, or if it does the last 2 floats in the register by default.
I'm frustrated how little you can figure out by simply watching code and the values they change.
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Fri Aug 11, 2017 8:37 pm Post subject: |
|
|
you can use:
Code: | JNS // jump if not sign |
_________________
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
|
|
Back to top |
|
|
Alphasoldier Advanced Cheater Reputation: 1
Joined: 07 Apr 2009 Posts: 95
|
Posted: Sat Aug 12, 2017 6:01 am Post subject: |
|
|
Ah, thank you so much. If I had known there was an instrution that set the eflags, I would've tried that immediately.
I'm still at a loss as to how to use the FPU status word register, but I suppose I'll figure it out in time.
The snippet that it became:
Code: | fld qword ptr [ebp-08]
fldz
fucomip st(0),st(1)
jna goldAdd | Ridiculously simple, and probably not even optimal, but it works.
Quote: | That's what documentation is for. See Intel's software developer manuals for more information. Volume 2 has information about instructions themselves, and volume 1 has information about the fpu in general. |
I'm a really poor learner when it comes to simply reading how things work. I'm a much more visceral learner than that. I need examples and direct documentation on what parameters go with which functions.
Yours were perfect, thank you again.
EDIT:
Now that this is working, I'd like to be able to add a permanent symbol to the address that contains the value I'm altering.
Is there any way to do this through auto assembly?
My google-fu is letting me down.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4300
|
Posted: Sat Aug 12, 2017 8:35 am Post subject: |
|
|
Alphasoldier wrote: | I'm still at a loss as to how to use the FPU status word register, but I suppose I'll figure it out in time. |
See the section titled "x87 FPU Status Register" in volume 1 of Intel's software developer manuals. There is a chart in that section which shows the condition codes are located at bits 8, 9, 10, and 14 (C0, C1, C2, and C3 respectively).
In volume 2, look at the ftst instruction. It has a very nice chart that shows what the condition code flags are set to based on the input. In this scenario, it looked like C0 would be enough to test for, so I tested the status word register in ax against a word with only bit 8 set (i.e. 0x0100). If the result is 0, then C0 wasn't set, and if it is a non-zero value, then C0 was set.
Alphasoldier wrote: | I'd like to be able to add a permanent symbol to the address that contains the value I'm altering. |
You could do it indirectly. Assuming the instruction addresses the memory location via eax+90:
Code: | [ENABLE]
...
alloc(myAddress,4)
registersymbol(myAddress)
code:
mov [myAddress],eax
...
[DISABLE]
dealloc(myAddress)
unregistersymbol(myAddress)
... |
Add the address "myAddress" to the address list as a L1 pointer whose first offset is 90.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Alphasoldier Advanced Cheater Reputation: 1
Joined: 07 Apr 2009 Posts: 95
|
Posted: Sat Aug 12, 2017 9:11 am Post subject: |
|
|
ParkourPenguin wrote: | You could do it indirectly. Assuming the instruction addresses the memory location via eax+90:
Code: | [ENABLE]
...
alloc(myAddress,4)
registersymbol(myAddress)
code:
mov [myAddress],eax
...
[DISABLE]
dealloc(myAddress)
unregistersymbol(myAddress)
... |
Add the address "myAddress" to the address list as a L1 pointer whose first offset is 90. |
This is more or less what I already have. Thing is, I want to keep the symbol even when the script is deactivated. Which means I can't deallocate or unregister the symbol.
Is there another way around this? Or am I stuck to the script? I don't particularly mind, but I'd like to know if it's possible.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4300
|
Posted: Sat Aug 12, 2017 9:16 am Post subject: |
|
|
Use globalalloc.
Code: | [ENABLE]
...
globalalloc(myAddress,4)
code:
mov [myAddress],eax
...
[DISABLE]
... |
It registers the symbol automatically and will only allocate the memory for a particular symbol once.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Alphasoldier Advanced Cheater Reputation: 1
Joined: 07 Apr 2009 Posts: 95
|
Posted: Sat Aug 12, 2017 12:12 pm Post subject: |
|
|
Absolutely perfect, all questions answered. This'll definitely help me in future endeavors.
Thanks again!
|
|
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
|
|