8 #ifndef _INC_cOSModule_H
9 #define _INC_cOSModule_H
10 #ifndef NO_PRAGMA_ONCE
19 #define MODULE_EXT MIME_EXT_dll
21 #elif defined(__linux__)
23 #define MODULE_EXT MIME_EXT_so
31 #define HMODULE_NULL ((HMODULE)nullptr)
48 #if defined(__linux__)
53 void FreeModuleLast();
58 #ifndef LOAD_LIBRARY_AS_IMAGE_RESOURCE
59 #define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x00000020
61 static const UINT k_Load_Normal = 0;
62 static const UINT k_Load_Preload = DONT_RESOLVE_DLL_REFERENCES;
63 static const UINT k_Load_Resource = LOAD_LIBRARY_AS_IMAGE_RESOURCE;
64 #elif defined(__linux__)
65 static const UINT k_Load_Normal = RTLD_NOW;
66 static const UINT k_Load_Preload = RTLD_LAZY;
67 static const UINT k_Load_Resource = RTLD_LAZY;
69 static const UINT k_Load_OSMask = 0x0FFFFFFF;
70 static const UINT k_Load_ByName = 0x40000000;
71 static const UINT k_Load_NoRefCount = 0x80000000;
80 static HMODULE
GRAYCALL GetModuleHandleForAddr(
const void* pAddr);
82 FARPROC GetSymbolAddress(
const char* pszSymbolName)
const;
88 operator HMODULE() const noexcept
99 return (UINT_PTR)m_hModule;
104 return ( m_uFlags & (k_Load_Preload | k_Load_Resource));
114 #elif defined(__linux__)
116 const char* pszError = ::dlerror();
131 m_uFlags = k_Load_Normal;
133 m_sModuleName.
Empty();
138 HMODULE hModule = m_hModule;
142 void FreeThisModule();
144 bool AttachModuleName(
const FILECHAR_t* pszModuleName, UINT32 uFlags = k_Load_NoRefCount);
145 HRESULT LoadModule(
const FILECHAR_t* pszModuleName, UINT32 uFlags = k_Load_Normal);
146 HRESULT LoadModuleWithSymbol(
const FILECHAR_t* pszModuleName,
const char* pszSymbolName);
154 template<
class TYPE = FARPROC>
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define TYPE
Definition: StrT.cpp:38
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define HMODULE_NULL
Definition: cOSModule.h:31
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
void Empty()
Definition: cString.h:193
static HRESULT GetLastDef(HRESULT hResDef=E_FAIL) noexcept
Definition: HResult.h:242
Definition: cOSModule.h:156
bool put_FuncAddress(TYPE pFunc)
Definition: cOSModule.h:174
TYPE m_pFunc
FARPROC to typedef int (FAR WINAPI *FARPROC)();.
Definition: cOSModule.h:161
bool isValidFunc() const
Definition: cOSModule.h:188
~cOSModuleFunc()
Definition: cOSModule.h:167
bool put_FuncGeneric(FARPROC pFunc)
Definition: cOSModule.h:181
cOSModuleFunc(TYPE pFunc=nullptr)
Definition: cOSModule.h:163
void ClearFuncAddress()
Definition: cOSModule.h:170
Definition: cOSModule.h:34
void AttachModule(HMODULE hModule=((HMODULE) nullptr), UINT32 uFlags=k_Load_Normal)
Definition: cOSModule.h:122
bool isResourceModule() const noexcept
Definition: cOSModule.h:101
HRESULT GetLastErrorDef(HRESULT hResDef=E_FAIL) const
Definition: cOSModule.h:110
HMODULE DetachModule() noexcept
Definition: cOSModule.h:136
void ClearModule() noexcept
Definition: cOSModule.h:128
bool isValidModule() const noexcept
Definition: cOSModule.h:84
HMODULE get_ModuleHandle() const noexcept
Definition: cOSModule.h:92
UINT_PTR get_ModuleInt() const noexcept
Definition: cOSModule.h:96
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
MIME_TYPE
Definition: cMime.h:79
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
cOSModuleFunc< FARPROC > cOSModuleFuncGeneric
Definition: cOSModule.h:198