The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CLibraryLoader Class Reference

Collaboration diagram for CLibraryLoader:

List of all members.


Detailed Description

A class which dynamically loads dlls.


Public Member Functions

 CLibraryLoader ()
 Creates a library loader that does not automatically load a dll.
 CLibraryLoader (const Core::_tstring &fileName, bool failWithException=true)
 Creates a library loader and loads the specified dll.
 CLibraryLoader (HMODULE hModule)
 Creates a library loader and attaches it to the supplied module handle.
 CLibraryLoader (const CLibraryLoader &rhs)
 ~CLibraryLoader ()
 Frees any resources.
CLibraryLoaderoperator= (const CLibraryLoader &rhs)
bool IsLoaded () const
 Returns false if no library is loaded.
HMODULE GetHMODULE () const
 Access the HMODULE...
void LoadLibrary (const Core::_tstring &fileName, bool run=true)
 Loads the supplied library. If run is false then the library is loaded with the DONT_RESOLVE_DLL_REFERENCES flag.
bool LoadIfPossible (const Core::_tstring &fileName, bool run=true)
 Loads the supplied library. If run is false then the library is loaded with the DONT_RESOLVE_DLL_REFERENCES flag. Returns false if the library cannot be loaded.
FARPROC GetOptionalProcAddress (const Core::_tstring &functionName) const
 Looks up a function by name in the loaded library and returns a pointer to it. Returns null if the function doesn't exist in the library.
FARPROC GetProcAddress (const Core::_tstring &functionName) const
 Looks up a function by name in the loaded library and returns a pointer to it. Throws an exception if the function doesn't exist in the library.
bool IsValidProcAddress (const Core::_tstring &functionName) const
 Returns true if the function exists in the library.
ULONG_PTR GetProcAddressOffset (const Core::_tstring &functionName) const
 Returns the function address as an offset relative to the library's base address.
FARPROC GetProcAddressInThisModule (const Core::_tstring &functionName, HMODULE hModule) const
 Returns the functions address from the loaded library as a pointer into the supplied hModule. Use this if you want to locate a function in a module that has been loaded at a different base address to the base address that the library loaded by the library loader was loaded at. Usually used for cross process library function location...
void FreeLibrary ()
 Frees the library.


Constructor & Destructor Documentation

CLibraryLoader (  ) 

Creates a library loader that does not automatically load a dll.

CLibraryLoader ( const Core::_tstring fileName,
bool  failWithException = true 
) [explicit]

Creates a library loader and loads the specified dll.

CLibraryLoader ( HMODULE  hModule  )  [explicit]

Creates a library loader and attaches it to the supplied module handle.

CLibraryLoader ( const CLibraryLoader rhs  ) 

~CLibraryLoader (  ) 

Frees any resources.


Member Function Documentation

CLibraryLoader& operator= ( const CLibraryLoader rhs  ) 

bool IsLoaded (  )  const

Returns false if no library is loaded.

HMODULE GetHMODULE (  )  const

Access the HMODULE...

void LoadLibrary ( const Core::_tstring fileName,
bool  run = true 
)

Loads the supplied library. If run is false then the library is loaded with the DONT_RESOLVE_DLL_REFERENCES flag.

bool LoadIfPossible ( const Core::_tstring fileName,
bool  run = true 
)

Loads the supplied library. If run is false then the library is loaded with the DONT_RESOLVE_DLL_REFERENCES flag. Returns false if the library cannot be loaded.

FARPROC GetOptionalProcAddress ( const Core::_tstring functionName  )  const

Looks up a function by name in the loaded library and returns a pointer to it. Returns null if the function doesn't exist in the library.

FARPROC GetProcAddress ( const Core::_tstring functionName  )  const

Looks up a function by name in the loaded library and returns a pointer to it. Throws an exception if the function doesn't exist in the library.

bool IsValidProcAddress ( const Core::_tstring functionName  )  const

Returns true if the function exists in the library.

ULONG_PTR GetProcAddressOffset ( const Core::_tstring functionName  )  const

Returns the function address as an offset relative to the library's base address.

FARPROC GetProcAddressInThisModule ( const Core::_tstring functionName,
HMODULE  hModule 
) const

Returns the functions address from the loaded library as a pointer into the supplied hModule. Use this if you want to locate a function in a module that has been loaded at a different base address to the base address that the library loaded by the library loader was loaded at. Usually used for cross process library function location...

void FreeLibrary (  ) 

Frees the library.


Generated on Sun Sep 12 19:11:36 2021 for The Server Framework - v7.4 by doxygen 1.5.3