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 targeted application's functions, via injection.

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

Joined: 24 Mar 2011
Posts: 15

PostPosted: Thu Mar 24, 2011 2:44 am    Post subject: Calling a targeted application's functions, via injection. Reply with quote

First and foremost since I am new to this forum I would like to thank Dark_byte for Cheat engine. I use this tool for anything and everything even just plain debugging.

Yesterday for the first time, I was able to inject code into a process (a dll) using the CreateRemoteThread/Loadlibrary technique. Not that I havent been capable of that, Ive just been taking my time learning as much as a I can and then slowly progressing into tougher things and my learning scope broadens.

Also I wanted a change from the old out of process methods such as WPM/RPM(read/writeprocessmemory)

My goal was to call an internal function inside of a test application, I used the __cdecl calling convention, GetModuleHandle(NULL) + functionoffset for the function pointer. It worked fine.

However with certain games I expirament with, it dosent work properly. It just ejects the library, I used the MessageBox api inside of DLLmain to let me know it was injected, and it pops up, but it still kicks out the library.

So I did some googling and read about looking over the assembly and making sure I have the function params correct. That is when I noticed cheat engine shows in the debugger the funtion params after a breakpoint is reached, but it seemed to me those parameters were totally incorrect.

Could someone tell me the best way to analyze and go about doing this?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Thu Mar 24, 2011 3:12 am    Post subject: Reply with quote

Not all functions will have the same calling convention. __cdecl will work on some, but not all functions depending on how they are compiled. You'll need to ensure that before creating a typedef of the function, that you know the proper calling convention it uses.

Here are some links to help you identify the proper calling convention:
http://en.wikipedia.org/wiki/X86_calling_conventions
http://www.codeproject.com/KB/cpp/calling_conventions_demystified.aspx
http://www.cs.cornell.edu/courses/cs412/2001sp/resources/microsoft-calling-conventions.html

If you need to, you can also handle converting __thiscall style class members to __stdcall typedefs and hooks. Check out this project:
http://www.gamedeception.net/threads/8375-Function-Detouring-and-Class-Detouring

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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