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 


[Delphi 7] Reading double pointers.

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

Joined: 08 Nov 2016
Posts: 16

PostPosted: Tue Nov 08, 2016 6:19 pm    Post subject: [Delphi 7] Reading double pointers. Reply with quote

Hello,

As I am trying to have some fun from programming and I am reading a lot, but I didn't find solution from my problems I am writing here.

Maybe from the beginning:
I am trying to make a something called "bot" to one of the privates server of Tibia. I did a quite nice job on normal client. By reading addresses and sending packets I am able to do things like auto heal, auto target, alarms etc.
After few weeks of working with normal Tibia Client I decided to learn little bit more about programming (delphi, cheat engine etc), so I am going to create a very similar bot, but on hmm.. converted client.
It is much bigger challenge, because in this client there are not a stable addresses. It means that addresses are getting change after every each time when I open client again.
The strange thing for me is that even integers in game (like health points) are not written in 4bytes value, but they are doubles.
On normal client it is very easy to read addresses by this method:

Code:
function MemReadInteger(Address: Cardinal): Cardinal;       //Read adress:value
var
ProcId: Cardinal;
tProc: THandle;
NBR: Cardinal;
value:integer;
begin
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcId);
    tProc:= OpenProcess(PROCESS_ALL_ACCESS, False, ProcId);
    ReadProcessMemory(tProc, Ptr(Address), @value, 4, NBR);
    CloseHandle(tProc);
    Result:=value;
end;


So lets say... when address of health points was:
Code:
Player_HP = $5C6858;

Whenever I wanted to read the value from this addres I made something like that (for example):

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(memreadinteger(player_Hp));
end;


or just simply use timer and made things like that:
Code:
if memreadinteger(player_hp) <= then something


Now as I said all values are written in "double" and I just don't know how to handle with them.
Can anyone help me?

Thanks.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Nov 08, 2016 6:34 pm    Post subject: Reply with quote

Change value to a double?
Code:
value:double;
and read 8 bytes instead?
Code:
ReadProcessMemory(tProc, Ptr(Address), @value, 8, NBR);
Back to top
View user's profile Send private message
Dracons
Newbie cheater
Reputation: 0

Joined: 08 Nov 2016
Posts: 16

PostPosted: Wed Nov 09, 2016 3:39 am    Post subject: Reply with quote

Okay, I tried how you said.
Code:
function MemReadDouble(Address: Integer): Double;       //Read adress:value
var
ProcId: Cardinal;
tProc: THandle;
NBR: Cardinal;
value:double;
begin
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcId);
    tProc:= OpenProcess(PROCESS_ALL_ACCESS, False, ProcId);
    ReadProcessMemory(tProc, Ptr(Address), @value, 8, NBR);
    CloseHandle(tProc);
    Result:=value;

end;


Still not working ;<
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Nov 09, 2016 4:36 am    Post subject: Reply with quote

stupid question, but you should be amazed by the things we see here:
do you call MemReadDouble instead of MemReadInteger?

also, change
Code:
 
ReadProcessMemory(tProc, Ptr(Address), @value, 8, NBR);

to
Code:
 
value:=87654321;
ReadProcessMemory(tProc, Ptr(Address), @value, 8, NBR);

if value is 87654321 then readprocessmemory has failed

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

Joined: 08 Nov 2016
Posts: 16

PostPosted: Wed Nov 09, 2016 4:56 am    Post subject: Reply with quote

Lets say it works...
How can I then write value of that byte in for example spinedit1?
Spinedit1.value := (memreaddouble(playerhp)) doesn't work for obvious reason - it's not an integer.

I heard about this:
Code:
var
 i:integer;
 d:Double;
begin
 d:= memreaddouble(playerhp);
 i:=round(d);
spinedit1.value := i;
end;
end.

But it reads value of that "double" as 0.

@Edit.
Fixed. It works now. But the problem is that the address is getting change everytime I restart TibiaClient. I heard about pointers, but I don't know exactly how to use them.

This is what writes on that address of "double" [img]s21.postimg.org/56yw64ktj/112.jpg[/img]
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 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