View previous topic :: View next topic |
Author |
Message |
Xblade Of Heaven Master Cheater
Reputation: 0
Joined: 16 Oct 2005 Posts: 395 Location: DEAD
|
Posted: Sun Oct 04, 2015 6:51 am Post subject: Get Fload value |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Oct 04, 2015 6:59 am Post subject: |
|
|
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 |
|
 |
Xblade Of Heaven Master Cheater
Reputation: 0
Joined: 16 Oct 2005 Posts: 395 Location: DEAD
|
Posted: Sun Oct 04, 2015 7:10 am Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25804 Location: The netherlands
|
Posted: Sun Oct 04, 2015 7:14 am Post subject: |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Oct 04, 2015 7:20 am Post subject: |
|
|
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 |
|
 |
Xblade Of Heaven Master Cheater
Reputation: 0
Joined: 16 Oct 2005 Posts: 395 Location: DEAD
|
Posted: Sun Oct 04, 2015 7:24 am Post subject: |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Oct 04, 2015 9:27 am Post subject: |
|
|
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 |
|
 |
Xblade Of Heaven Master Cheater
Reputation: 0
Joined: 16 Oct 2005 Posts: 395 Location: DEAD
|
Posted: Sun Oct 04, 2015 10:08 am Post subject: |
|
|
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 , thanks to all
_________________
Welcome to the Hell.
 |
|
Back to top |
|
 |
STN I post too much
Reputation: 43
Joined: 09 Nov 2005 Posts: 2676
|
Posted: Sun Oct 04, 2015 10:13 am Post subject: |
|
|
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.
_________________
|
|
Back to top |
|
 |
zerobyte How do I cheat?
Reputation: 0
Joined: 05 Jul 2015 Posts: 1 Location: Peru
|
Posted: Mon Oct 05, 2015 3:33 pm Post subject: hello |
|
|
hello xblade please use mail ? thanks
|
|
Back to top |
|
 |
|