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 


Calling a function pointer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Rectangle
Advanced Cheater
Reputation: 1

Joined: 23 Feb 2013
Posts: 73

PostPosted: Tue Mar 26, 2013 3:44 pm    Post subject: Calling a function pointer? Reply with quote

Is it possible to find the starting offset of a function (i.e, using AOBScan)and then use that address as a function pointer?
How would you call that function?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Mar 26, 2013 3:52 pm    Post subject: Reply with quote

Find an often called function in the thread that usually calls that function and do a code injection there. (preferably a injected dll)

In that injected code you can call the function one time(set the proper class object in ecx, stack parameters, etc...) and set a variable to 1 indicating it has been called, so it won't call it again. (set to 0 if you want to call it again)
Using a critical section is recommended in case the code you picked is called by multiple threads

_________________
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
Rectangle
Advanced Cheater
Reputation: 1

Joined: 23 Feb 2013
Posts: 73

PostPosted: Wed Mar 27, 2013 12:19 pm    Post subject: Reply with quote

Sweet! Is there a way of programmatically finding the size (in bytes) of it's parameters? I'd hate to get the func pointer code right, but think it's wrong due to an access violation, page fault, etc.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Mar 27, 2013 12:37 pm    Post subject: Reply with quote

make sure you have the calling method correct.

if it's a normal stdcall then the "ret xxx" will contain the bytesize of the parameters

if it's cdecl then you need to step through the function with a debugger and find the caller. That one will be responsible for popping off the variables of the stack

_________________
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
Rectangle
Advanced Cheater
Reputation: 1

Joined: 23 Feb 2013
Posts: 73

PostPosted: Wed Mar 27, 2013 5:41 pm    Post subject: Reply with quote

Alternatively, I suppose an easy way of distinguishing between the two would be to switch the function declaration to each decl type and see which call gives that "the value of esp was not properly saved across a function call" error.
Thanks again, DB!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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