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 


Quick question about fild

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Mon Jul 20, 2015 2:47 pm    Post subject: Quick question about fild Reply with quote

I've been studying the FPU lately, but I can't quite pin down what's going on to cause my game to crash when trying to modify a particular fild instruction.

Take this bit of code (assume the referenced memory addresses are in a currently-running instance of the game):

Code:
fild dword ptr [007E562C] //1 is what resides in 007E562C
fadd qword ptr [007E5540]
fstp qword ptr [007E5540]


How am I using fild incorrectly by replacing fild dword ptr [007E562C] with my own code injection consisting of the following (using the same value as what already resides in [007E562C], just to try to keep everything the same value-wise for testing purposes):

Code:
push ebx
mov ebx,1
fild dword ptr [ebx]
pop ebx


If I keep the original fild instruction intact but simply add a mov [007E562C],1 before it, everything still works wonderfully, like so:


Code:
mov [007E562C],1 //I can place up to FF here and it works great
fild dword ptr [007E562C]
fadd qword ptr [007E5540]
fstp qword ptr [007E5540]


Thanks for any help! I know it's something stupidly simple, but I'm not finding it at the moment... Embarassed

_________________
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25828
Location: The netherlands

PostPosted: Mon Jul 20, 2015 3:44 pm    Post subject: Reply with quote

fild dword [address] will load a 4 byte signed integer from the address, and convert it internally to a floating point value (ext-double)

Code:

push ebx
mov ebx,1
fild dword ptr [ebx]
pop ebx


this code can be rewritten as:
Code:

fild dword ptr [1]

Which is very doubtful that's what you wish to do (address 1 isn't often readable)

Your second solution is the best solution (and you should be able to go to 7fffffff without issue)

alternatively, you can use an self allocated address with the value
Code:

alloc(myvalue,4)
myvalue:
dd (int)1000

...
fild dword ptr [myvalue]
...

_________________
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
View user's profile Send private message MSN Messenger
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Mon Jul 20, 2015 3:55 pm    Post subject: Reply with quote

OHHHHHH, so the issue is basically that I'm trying to load 1 from a CPU register instead of 1 from an address in RAM?
_________________
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25828
Location: The netherlands

PostPosted: Mon Jul 20, 2015 3:56 pm    Post subject: Reply with quote

Yes. FILD only takes addresses as parameter
_________________
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
View user's profile Send private message MSN Messenger
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Mon Jul 20, 2015 3:57 pm    Post subject: Reply with quote

Excellent stuff. That's all I needed for it to click. Thanks for replying, Dark Byte! Very Happy

EDIT: Good grief, it was right under my damn nose the whole time, lmao. From the very top of here:

Quote:
"Integer data cannot be transferred directly between the CPU and FPU registers."


Laughing

_________________
Back to top
View user's profile Send private message Visit poster's website
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Jul 20, 2015 4:07 pm    Post subject: Reply with quote

Just to clarify, your code was trying to read data from the address [00000001].
Back to top
View user's profile Send private message
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Mon Jul 20, 2015 4:20 pm    Post subject: Reply with quote

Zanzer wrote:
Just to clarify, your code was trying to read data from the address [00000001].


Yep, got it. Thanks for the additional feedback!

_________________
Back to top
View user's profile Send private message Visit poster's website
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