File tree Expand file tree Collapse file tree 2 files changed +64
-3
lines changed Expand file tree Collapse file tree 2 files changed +64
-3
lines changed Original file line number Diff line number Diff line change 22
33#include " ModuleLookup.hpp"
44
5- #define WIN32_LEAN_AND_MEAN
6- #include < windows.h>
7-
85namespace XRay
96{
7+ Module::Module () : handle(nullptr ) {}
8+
9+ Module::Module (pcstr moduleName, bool log /* = true*/ )
10+ {
11+ open (moduleName, log);
12+ }
13+
14+ Module::~Module ()
15+ {
16+ close ();
17+ }
18+
19+ void * Module::open (pcstr moduleName, bool log /* = true*/ )
20+ {
21+ if (exist ())
22+ close ();
23+
24+ if (log)
25+ Log (" Loading DLL:" , moduleName);
26+
27+ handle = ::LoadLibrary (moduleName);
28+ return handle;
29+ }
30+
31+ void Module::close ()
32+ {
33+ FreeLibrary (static_cast <HMODULE>(handle));
34+ handle = nullptr ;
35+ }
36+
37+ bool Module::exist () const
38+ {
39+ return handle != nullptr ;
40+ }
41+
42+ void * Module::operator ()() const
43+ {
44+ return handle;
45+ }
46+
47+ void * Module::getProcAddress (pcstr procName) const
48+ {
49+ return ::GetProcAddress (static_cast <HMODULE>(handle), procName);
50+ }
51+
1052HMODULE LoadLibrary (const char * libraryFileName, bool log)
1153{
1254 if (log)
Original file line number Diff line number Diff line change 44
55namespace XRay
66{
7+ class XRCORE_API Module
8+ {
9+ void * handle;
10+
11+ public:
12+ Module ();
13+ Module (pcstr moduleName, bool log = true );
14+ ~Module ();
15+
16+ void * open (pcstr moduleName, bool log = true );;
17+ void close ();
18+
19+ bool exist () const ;
20+
21+ void * operator ()() const ;
22+
23+ void * getProcAddress (pcstr procName) const ;
24+ };
25+
726XRCORE_API HMODULE LoadLibrary (const char * libraryFileName, bool log = true );
827XRCORE_API void UnloadLibrary (HMODULE libraryHandle);
928XRCORE_API void * GetProcAddress (HMODULE libraryHandle, const char * procName);
You can’t perform that action at this time.
0 commit comments