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 


Get Fload value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Xblade Of Heaven
Master Cheater
Reputation: 0

Joined: 16 Oct 2005
Posts: 395
Location: DEAD

PostPosted: Sun Oct 04, 2015 6:51 am    Post subject: Get Fload value Reply with quote

Hi all guys, i try explain my problem. Triying show in a edit text the float value always show a wrong value.

My code:

Code:
procedure TForm1.batteryTimer(Sender: TObject);
var
  hProc, Read, hwnd: THandle;
  Pid: Cardinal;
  Offset:Integer;
  Estamina: single;
begin
  Offset:=$10cc;

  hwnd:=FindWindow(WINDOWS_CLASS,nil);
  GetWindowThreadProcessId(hwnd, Pid);
  ADDR_BASE:= GetModuleBaseAddress(Pid, GAME_MODULE);
  hProc := OpenProcess(PROCESS_ALL_ACCESS, False, Pid);
  if hProc > 0 then
  begin
    //ESTAMINA
    ReadProcessMemory(hProc ,Pointer(DWORD(GetModuleBaseAddress(Pid, GAME_MODULE))+$633AFC), @Estamina, SizeOf(Estamina), Read);
    Estamina:= Estamina+Offset;
    ReadProcessMemory(hProc ,pointer(Estamina), @Estamina, SizeOf(Estamina), Read);
    Edit1.Text := FloatToStr(Estamina);
  end;
end;


the real value is 100 (float) but i can see 4300 :S in the (Edit1.Text := FloatToStr(Estamina);)

anyone can help me?, thanks!

_________________
Welcome to the Hell.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Oct 04, 2015 6:59 am    Post subject: Reply with quote

Not a language I use, but I believe your problem is that you're using Estamina as your pointer.
It is declared as a single, so when you do:
Code:
Estamina:= Estamina+Offset;

It is converting that to the float representation of that address value.
So my guess is you're reading the wrong address next.
Back to top
View user's profile Send private message
Xblade Of Heaven
Master Cheater
Reputation: 0

Joined: 16 Oct 2005
Posts: 395
Location: DEAD

PostPosted: Sun Oct 04, 2015 7:10 am    Post subject: Reply with quote

Zanzer wrote:
Not a language I use, but I believe your problem is that you're using Estamina as your pointer.
It is declared as a single, so when you do:
Code:
Estamina:= Estamina+Offset;

It is converting that to the float representation of that address value.
So my guess is you're reading the wrong address next.


Using a dword value is correct but using a float value no.

Show the image:



offset is 10cc and value float and changing single to dword i can see: 1120403456 no 100

_________________
Welcome to the Hell.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Oct 04, 2015 7:14 am    Post subject: Reply with quote

The first rpm call must read the value into a 4 byte integer type
The second call you must use that value+offset as address and output it into a float

_________________
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
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Oct 04, 2015 7:20 am    Post subject: Reply with quote

No, I mean you are reading the address into a float variable type.
So your first read may find the bytes 25B4AC1C and read it into Estamina.
However, Estamina is declared as a float, which means it now equals 3.134164842E-16.
You are then adding 10CC (Offset) to that God awful number, creating a worse number.
Now it is trying to read that float value as an address and it's pointing to some "random" place.
Back to top
View user's profile Send private message
Xblade Of Heaven
Master Cheater
Reputation: 0

Joined: 16 Oct 2005
Posts: 395
Location: DEAD

PostPosted: Sun Oct 04, 2015 7:24 am    Post subject: Reply with quote

Zanzer wrote:
No, I mean you are reading the address into a float variable type.
So your first read may find the bytes 25B4AC1C and read it into Estamina.
However, Estamina is declared as a float, which means it now equals 3.134164842E-16.
You are then adding 10CC (Offset) to that God awful number, creating a worse number.
Now it is trying to read that float value as an address and it's pointing to some "random" place.


no, the adress+offset is now correct i can see 1120403456 is 100 on 4 bytes and i can see this changing but now i need change 1120403456 to 100 for see 100 no 1120403456.

regards

_________________
Welcome to the Hell.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Oct 04, 2015 9:27 am    Post subject: Reply with quote

Print the value of Estamina before the second ReadProcessMemory.
At this point, it should contain the address of whatever value you found.
I'm telling you that it does not. This is because your variable is defined as a float.

Create another variable and use that to retrieve your address, as Dark Byte said.
Code:
var
  ...
  Address:Integer;
begin
  ...
  ReadProcessMemory(hProc ,Pointer(DWORD(GetModuleBaseAddress(Pid, GAME_MODULE))+$633AFC), @Address, SizeOf(Address), Read);
  Address:= Address+Offset;
  ReadProcessMemory(hProc ,pointer(Address), @Estamina, SizeOf(Estamina), Read);
Back to top
View user's profile Send private message
Xblade Of Heaven
Master Cheater
Reputation: 0

Joined: 16 Oct 2005
Posts: 395
Location: DEAD

PostPosted: Sun Oct 04, 2015 10:08 am    Post subject: Reply with quote

Zanzer wrote:
Print the value of Estamina before the second ReadProcessMemory.
At this point, it should contain the address of whatever value you found.
I'm telling you that it does not. This is because your variable is defined as a float.

Create another variable and use that to retrieve your address, as Dark Byte said.
Code:
var
  ...
  Address:Integer;
begin
  ...
  ReadProcessMemory(hProc ,Pointer(DWORD(GetModuleBaseAddress(Pid, GAME_MODULE))+$633AFC), @Address, SizeOf(Address), Read);
  Address:= Address+Offset;
  ReadProcessMemory(hProc ,pointer(Address), @Estamina, SizeOf(Estamina), Read);


Solved Very Happy, thanks to all

_________________
Welcome to the Hell.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Sun Oct 04, 2015 10:13 am    Post subject: Reply with quote

Debug it and see what is being read at each call.

Quote:
no, the adress+offset is now correct i can see 1120403456 is 100 on 4 bytes and i can see this changing but now i need change 1120403456 to 100 for see 100 no 1120403456.


If you have got the value as integer type then what is the issue ? Just convert it to float, either assign it to another float variable or typecast then show it in Editbox.

http://stackoverflow.com/questions/3934392/how-to-convert-a-integer-to-float-in-delphi

I think your programming style is pretty lazy, you are defining Read as THandle which is technically correct (nativeuint type in delphi) but it will confuse someone without seeing how you used it in a RPM or WPM call (with big functions it can be a problem). You could just use an integer type for reading the values, do your calculation and finally read into a float type instead of just using single type for everything. Sure it will take defining two vars but it avoids headaches like you are experiencing right now when a value you are not expecting gets assigned to it.

Hope this helps, though

EDIT: The forum needs some sort of notification to tell you new replies have been posted.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
zerobyte
How do I cheat?
Reputation: 0

Joined: 05 Jul 2015
Posts: 1
Location: Peru

PostPosted: Mon Oct 05, 2015 3:33 pm    Post subject: hello Reply with quote

hello xblade please use mail ? thanks Very Happy
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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