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] GetMemoryAddress of Delphi Function

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

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Wed Mar 04, 2009 1:03 pm    Post subject: [Delphi] GetMemoryAddress of Delphi Function Reply with quote

procedure TForm1.Button1Click(Sender: TObject);
var
h:integer;
begin
h:=pointer(Application.Terminate);
showmessage(inttohex(h,1));
end;

It will not let me compile:

Code:
Build
  [Error] Unit1.pas(30): Invalid typecast
  [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'


I assume Application has a "baseaddress" and Terminate is the offset. How can i get that address+offset for example?

_________________



Last edited by h4c0r-BG on Thu Mar 05, 2009 6:18 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Mar 04, 2009 1:18 pm    Post subject: Reply with quote

try
h:=integer(@Application.Terminate)

_________________
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
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Mar 04, 2009 8:27 pm    Post subject: Reply with quote

Dark Byte wrote:
try
h:=integer(@Application.Terminate)


I don't think this will work because you can't find out the pointer to something in a class like directx.

What I do is insert alot of nops before and after it then call Application.Terminate. Compile then look it up in a disassembler.
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Thu Mar 05, 2009 6:17 am    Post subject: Reply with quote

Dark Byte wrote:
try
h:=integer(@Application.Terminate)


[Error] Unit1.pas(30): Variable required

Friend said wrote:

so, how do you get a variable's memory address in delphi? in C is with "&"....


If i am not mistaken he is talking about "@" in Delphi?

_________________

Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Mar 05, 2009 8:11 am    Post subject: Reply with quote

I told you what to do on Messenger -_-

(Add procedure lol; to private dec)

Code:
Procedure TForm1.lol;
Begin
Application.Terminate;
End;

Button1.Click:
ShowMessageFmt( '%x', [ @TForm1.lol ] );


will raise an exception error, try doing what dark byte did (typecast it as Integer)

I'm not sure that THAT function itself is even a standalone, it's just a wrapper so it won't give you .Terminate (Application is the class and Ter is a member of it) address -_-
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Thu Mar 05, 2009 9:51 am    Post subject: Reply with quote

Thank you Rot1, but i wanted to get the address of:

Application.Terminate not procedure TForm1.lol

Wink

_________________

Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Mar 05, 2009 10:54 am    Post subject: Reply with quote

h4c0r-BG wrote:
Thank you Rot1, but i wanted to get the address of:

Application.Terminate not procedure TForm1.lol

Wink


as i said, when you compile and run your program, it doesn't really call Application.Terminate, as it's just a freakin' wrapper, example:

Procedure lol(text: string);
begin
ShowMessage(text);
end;

lets say you wanna get the address of lol, you can't because in the compiled program it's just regulary calling ShowMessage from your compiled wrapper.
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Thu Mar 05, 2009 11:21 am    Post subject: Reply with quote

Rot1, i am using this code within a dll file, it will get the address of the procedure ... and ... the returned value will be from my DLL, but the thing which i call is in the executable.

So the address will be not what i wanted.

_________________

Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Thu Mar 05, 2009 12:05 pm    Post subject: Reply with quote

I don't think you can get the address of a function from another module unless it's exported.
_________________
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Mar 05, 2009 12:25 pm    Post subject: Reply with quote

dnsi0 wrote:
Dark Byte wrote:
try
h:=integer(@Application.Terminate)


I don't think this will work because you can't find out the pointer to something in a class like directx.

What I do is insert alot of nops before and after it then call Application.Terminate. Compile then look it up in a disassembler.


Dude....i'm amazed of this comment.
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