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 


{Mini-Tut} Dynamic DLL Loading

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials
View previous topic :: View next topic  
Author Message
ZenX
Grandmaster Cheater Supreme
Reputation: 1

Joined: 26 May 2007
Posts: 1021
Location: ">>Pointer<<" : Address 00400560 Offset :1FE

PostPosted: Tue Aug 14, 2007 11:41 am    Post subject: {Mini-Tut} Dynamic DLL Loading Reply with quote

Complete Functionality - Implementation in the TDLLMODULE function.
There Are 2 Virtual Functions to this implementation.
Code:

{
Returns True when the DLL has been loaded SUCCESFULY!!
}
Create()


and

Code:

{
Simply unload the DLL's process from the memory
}
Destroy()


Example:
If something needed PSAPI(Process Status API)
Then you would need to Enumerate all running processes and display Executable process, you would need to create a TProcessStateusModule from TDllModule

Don't Forget your TypeDefs

Code:

//Create()
//It needs first to call the base class that loads the DLL into the process //memory and obtains a handle
//and second, to obtain pointers to functions in a DLL that are needed for //the current application. If this function returns FALSE, then the DLL is not //loaded correctly and cannot be used. Its implementation is the following:

typedef BOOL (WINAPI *TFEnumProcesses)(
   DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded
);
typedef BOOL (WINAPI *TFEnumProcessModules)(
   HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded
);
typedef DWORD (WINAPI *TFGetModuleBaseName)(
   HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize
);
typedef DWORD (WINAPI *TFGetModuleFileNameEx)(
   HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize
);
typedef BOOL (WINAPI *TFGetModuleInformation)(
   HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb
);

class TProcessStatusModule : public TDllModule {
private:
    TFEnumProcesses FEnumProcesses;
    TFEnumProcessModules FEnumProcessModules;
    TFGetModuleBaseName FGetModuleBaseName;
    TFGetModuleFileNameEx FGetModuleFileNameEx;
    TFGetModuleInformation FGetModuleInformation;

public:
    TProcessStatusModule();
    virtual ~TProcessStatusModule();

    virtual BOOL Create(void);
    virtual void Destroy(void);
   
    BOOL EnumProcesses(DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded);
    BOOL EnumProcessModules(HANDLE hProcess,HMODULE *lphModule,DWORD cb,
                            LPDWORD lpcbNeeded);
    DWORD GetModuleBaseName(HANDLE hProcess,HMODULE hModule,LPSTR lpBaseName,
                            DWORD nSize);
    DWORD GetModuleFileNameEx(HANDLE hProcess,HMODULE hModule,
                              LPSTR lpFilename,DWORD nSize);
    BOOL GetModuleInformation(HANDLE hProcess,HMODULE hModule,
                              LPMODULEINFO lpmodinfo,DWORD cb);
};


Code:

BOOL TProcessStatusModule::Create(void)
{
  if (TDllModule::Create()) {
    // DLL handle is valid (DLL is loaded)
    FEnumProcesses = (TFEnumProcesses)::GetProcAddress(m_hHandle,
                                                       _T("EnumProcesses"));
    FEnumProcessModules = (TFEnumProcessModules)::GetProcAddress(m_hHandle,
                                                       _T("EnumProcessModules"));
    // Load all other needed functions
    ...
    // Can also check if all pointers to functions are different from NULL.
    return TRUE;
  }
  return FALSE;
}


Now all that is left is the function execution of the DLL
Note:Each method has the same arguement as the DLL

The Returning code:
Code:

BOOL TProcessStatusModule::EnumProcesses(DWORD *lpidProcess, DWORD cb, DWORD *cbNeeded)
{
  ASSERT(FEnumProcesses != NULL);
  if (FEnumProcesses)
      return FEnumProcesses(lpidProcess,cb,cbNeeded);
  return FALSE;
}


Credits~
CODE WASNT DEVELOPED BY ME ONLY THE TUT!

_________________
CEF Moderator since 2007 ^_^
ZenX-Engine
Back to top
View user's profile Send private message Yahoo Messenger
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Sat Sep 22, 2007 8:26 am    Post subject: Reply with quote

nice tut, but how do u make a dll? in C++?
Back to top
View user's profile Send private message
h4ckz0r's twisted soul
Grandmaster Cheater Supreme
Reputation: 1

Joined: 24 Oct 2007
Posts: 1181
Location: Paradise city, where the grass is green and the girls are somwhat pretty~

PostPosted: Mon Oct 29, 2007 10:42 am    Post subject: Reply with quote

Nice tut and thx Smile
Back to top
View user's profile Send private message
lolhaha
Newbie cheater
Reputation: 0

Joined: 06 Nov 2007
Posts: 10

PostPosted: Tue Nov 06, 2007 7:28 am    Post subject: lol Reply with quote

lol nice
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 157

Joined: 25 Jan 2006
Posts: 8142
Location: 127.0.0.1

PostPosted: Tue Nov 06, 2007 10:57 am    Post subject: Reply with quote

Tut and code are from:
http://www.codeproject.com/dll/dynamicdllloading.asp

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6222
Location: /dev/null

PostPosted: Tue Nov 06, 2007 12:55 pm    Post subject: Reply with quote

Ok, now see if you can explain it all. Rolling Eyes
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Nov 14, 2007 8:30 am    Post subject: Reply with quote

noz3001 wrote:
Ok, now see if you can explain it all. Rolling Eyes


Ahaha Laughing i love you man Very Happy
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 Tutorials 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