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 


[solved] Assembler Question - Check if float is an integer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
MarcRené
Newbie cheater
Reputation: 0

Joined: 20 Mar 2017
Posts: 15

PostPosted: Mon Apr 09, 2018 1:45 pm    Post subject: [solved] Assembler Question - Check if float is an integer? Reply with quote

Hi all,

funny problem: I have found a nice point in the sourcecode of a game where the gold-value is being read. But sometimes the same source jumps into reading the mana, too.

Original code:
Code:

520C07C1: 00 00              -  add [eax],al
520C07C3: 00 00              -  add [eax],al
520C07C5: 00 00              -  add [eax],al
520C07C7: 00 55 8B           -  add [ebp-75],dl
520C07CA: EC                 -  in al,dx
520C07CB: 83 EC 18           -  sub esp,18
520C07CE: D9 EE              -  fldz
520C07D0: D9 5D FC           -  fstp dword ptr [ebp-04]
520C07D3: 8B 45 08           -  mov eax,[ebp+08]
// ---------- INJECTING HERE ----------
520C07D6: D9 40 2C           -  fld dword ptr [eax+2C]
520C07D9: D9 5D FC           -  fstp dword ptr [ebp-04]
// ---------- DONE INJECTING  ----------
520C07DC: D9 45 FC           -  fld dword ptr [ebp-04]
520C07DF: C9                 -  leave
520C07E0: C3                 -  ret


Current injection is:
Code:

newmem:
  push eax
  add eax,2c
  mov [goldaddress],eax
  pop eax


So what I need is a way to decide: is [eax+2c] actually pointing to gold or mana? I found out: gold is always a plain integer number, stored as float, wheres mana is always a "real" float number.

Any ideas? Shocked

best regards,
Marc


Last edited by MarcRené on Tue Apr 10, 2018 8:44 am; edited 1 time in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Apr 09, 2018 6:49 pm    Post subject: Reply with quote

Code:
label(code)
label(gold)
label(exit)

code:
  //...
  // st(0) contains floating point value being tested
  fld st(0)
  frndint
  fucomip st(1)
  jz gold
    // mana
    // code for mana here
    jmp exit
  gold:
    // code for gold here
  exit:
  //...

This probably isn't a good way of checking which address is being accessed, but I hope you learn something regardless.

_________________
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
MarcRené
Newbie cheater
Reputation: 0

Joined: 20 Mar 2017
Posts: 15

PostPosted: Tue Apr 10, 2018 8:44 am    Post subject: Reply with quote

Many thanks!

You're right, it is definitively not the best way. Your code works, of course, but this only reduces the "switching" of addresses.

Tried the other code-sections which read the amount of gold, but guess what.... they are used for multiple values, too.

Have to find another way Smile
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