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 


[Code Injection] How do I change the float stack value?

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

Joined: 23 May 2009
Posts: 108
Location: United Kingdom

PostPosted: Fri May 22, 2015 4:45 pm    Post subject: [Code Injection] How do I change the float stack value? Reply with quote

Say, this is my assembly code.
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here
cmp [ebx+10],1
jne originalcode
fadd dword ptr [ebx+04]
fstp dword ptr [ebp-30]
jmp exit

originalcode:
fsubr dword ptr [ebx+04]
fstp dword ptr [ebp-30]

exit:
jmp returnhere

"Tutorial-i386.exe"+27D7D:
jmp newmem
nop
returnhere:



 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"Tutorial-i386.exe"+27D7D:
fsubr dword ptr [ebx+04]
fstp dword ptr [ebp-30]
//Alt: db D8 6B 04 D9 5D D0


Is there a way to change fstp and not use fadd, but physically changing the value of the stack value to make it permanently, say, 1000hp instead of adding every time or so?
EDIT: I tried commenting out both the fsubr and fstp, and put
Code:
mov [ebp-30],(float)1337
instead, but I get "Invalid floating point operation" or some shit.
_________________
Do not ask Dark Byte about online cheats. He doesn't know any and wont help finding them.[center]
[/center]
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri May 22, 2015 4:54 pm    Post subject: Reply with quote

Just use

mov [ebp-30],(float)1337

right after the fstp instruction and the value will be overwritten with 1337, whatever it was before. There is no need to comment out the fstp.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
rawgreaze
Expert Cheater
Reputation: 0

Joined: 23 May 2009
Posts: 108
Location: United Kingdom

PostPosted: Fri May 22, 2015 4:59 pm    Post subject: Reply with quote

Geri wrote:
Just use

mov [ebp-30],(float)1337

right after the fstp instruction and the value will be overwritten with 1337, whatever it was before. There is no need to comment out the fstp.

Huh. I never thought to leave the fstp instruction in.
How come it creates an error when it's left out, but when it's in it has no erros? Weird.
EDIT: Also, when do you use the square brackets, like in [ebp-30]?
I've seen mov instructions like: mov esp,[myvariable] or something, why?

_________________
Do not ask Dark Byte about online cheats. He doesn't know any and wont help finding them.[center]
[/center]
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri May 22, 2015 5:07 pm    Post subject: Reply with quote

Read up on what fstp does exactly and you will see. (HINT: You screw up the registers.)

If you really need to get rid of an fstp instruction, you should replace it with

fstp st(0)

Don't nop it, don't comment it.


Quote:
EDIT: Also, when do you use the square brackets, like in [ebp-30]?
I've seen mov instructions like: mov esp,[myvariable] or something, why?


The bracket means that you are working with the value on the address inside the bracket.

Eg eax = 44556600

mov ebx,eax //copy 44556600 to ebx
mov ebx,[eax] //copy the value on address 44556600 to ebx

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
rawgreaze
Expert Cheater
Reputation: 0

Joined: 23 May 2009
Posts: 108
Location: United Kingdom

PostPosted: Fri May 22, 2015 5:10 pm    Post subject: Reply with quote

Geri wrote:
Read up on what fstp does exactly and you will see. (HINT: You screw up the registers.)

If you really need to get rid of an fstp instruction, you should replace it with

fstp st(0)

Don't nop it, don't comment it.

I read that fstp pushes the float pointer on top of the stack or some shit.
& do all assembly scripts work on restart, or do some need an AoB scan? Like the CETutorial works evry tym, but in other games, does the address of the disassembly thing change?
EDIT: Ohh, shit!
Thanks for explaining the square bracket thing to me ;D

_________________
Do not ask Dark Byte about online cheats. He doesn't know any and wont help finding them.[center]
[/center]
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri May 22, 2015 5:20 pm    Post subject: Reply with quote

Floating point instructions are using st registers similarly to the stack.

fstp is actually an fst and a pop instruction in one package. And fld is the push instruction.

Quote:
& do all assembly scripts work on restart, or do some need an AoB scan? Like the CETutorial works evry tym, but in other games, does the address of the disassembly thing change?


Most games are using static codes, but some games are using JIT. In that case, the code's address will not be static. To make it more confusing, the codes will not be loaded until they are used. Eg the code which is decreasing your health will not be loaded until your health is decreased in the game.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
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