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 


Understanding stack and floating point instructions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
LykanthricAura
Advanced Cheater
Reputation: 0

Joined: 17 May 2010
Posts: 58
Location: India

PostPosted: Fri Jun 28, 2019 11:16 pm    Post subject: Understanding stack and floating point instructions Reply with quote

I am trying to make a game give me 2x the points it gives me at the end of each stage so stuff will get unlocked sooner.

Code:

Speed.exe+36A32 - E8 61DE2300           - call Speed.exe+274898
Speed.exe+36A37 - 89 44 24 10           - mov [esp+10],eax
Speed.exe+36A3B - DB 44 24 10           - fild dword ptr [esp+10]
Speed.exe+36A3F - D8 46 7C              - fadd dword ptr [esi+7C]
Speed.exe+36A42 - D9 5E 7C              - fstp dword ptr [esi+7C]
Speed.exe+36A45 - 43                    - inc ebx
Speed.exe+36A46 - 83 FB 1F              - cmp ebx,1F { 31 }
Speed.exe+36A49 - 0F8C 3BFFFFFF         - jl Speed.exe+3698A



The fstp instruction is the one that writes to the value.

I have read the man pages etc of fstp, fadd, fmul etc and I still can't seem to get this right.
I tried calling fadd twice. But it doesn't double the value ..makes it exponentially more.
I tried to do fmul [2x] where 2x is a variable with 2 in it.
Still makes the value grow tooo big.
I actually don't understand these floating point instructions very well.

I know they load, store, add value to the stack at st[01] but then how does one manipulate this value?

Where in this set of instructions can inject something to make the value 2 times..?

Also..is
Code:

2x:
 dd (float) 2


a valid operation? Or will I have to use fimul instead?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Jun 29, 2019 6:31 am    Post subject: Reply with quote

just got up but it sounds like it should have worked lol It's possible the code is being run more often than you think and that's causing it to get bigger than intended.

the i is only for store and load and means to store or load the value as an integer.

maybe try hooking and after the add convert to integer and double it then
Code:

fistp dword ptr [esp+7c] // store as int
mov eax, [esp+7c] // load into register
shl eax, 1 // double integer value with bit math
fild [esp+7c] // load int
fstp dword ptr [esp+7c] // store float


but yeah any of those sound like they should work, duplicating the fadd should double that part of the value or not popping it on store and then adding to itself and re-storing, or fmul [2x] before the store.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4708

PostPosted: Sat Jun 29, 2019 9:06 am    Post subject: Reply with quote

LykanthricAura wrote:
I tried calling fadd twice. But it doesn't double the value ..makes it exponentially more.
Yes, that's correct. You're not adding the difference to the value twice, but the value twice to the difference.
Code:
// what the game is doing:
x = dx + x

// what you want to do:
x = 2*dx + x

// what you're actually doing:
x = dx + 2*x

Since that function is returning an integer, you could just double that.
Code:
// code injection at Speed.exe+36A37
test eax,eax
js @f  // if it's negative, don't shift it
sal eax,1
@@:
mov [esp+10],eax
...

_________________
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
LykanthricAura
Advanced Cheater
Reputation: 0

Joined: 17 May 2010
Posts: 58
Location: India

PostPosted: Sun Jun 30, 2019 9:29 am    Post subject: Reply with quote

Thank you. I'll try that soon. And post again
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