summaryrefslogtreecommitdiff
path: root/shared/dllLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared/dllLoader.cpp')
-rw-r--r--shared/dllLoader.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/shared/dllLoader.cpp b/shared/dllLoader.cpp
new file mode 100644
index 00000000..e37ded54
--- /dev/null
+++ b/shared/dllLoader.cpp
@@ -0,0 +1,44 @@
+#include "dllLoader.h"
+#include <wx/msw/wrapwin.h> //includes "windows.h"
+
+namespace
+{
+class KernelDllHandler //dynamically load "kernel32.dll"
+{
+public:
+ static const KernelDllHandler& getInstance()
+ {
+ static KernelDllHandler instance;
+ return instance;
+ }
+
+ HINSTANCE getHandle() const
+ {
+ return hKernel;
+ }
+
+private:
+ KernelDllHandler() :
+ hKernel(NULL)
+ {
+ //get a handle to the DLL module containing required functionality
+ hKernel = ::LoadLibrary(L"kernel32.dll");
+ }
+
+ ~KernelDllHandler()
+ {
+ if (hKernel) ::FreeLibrary(hKernel);
+ }
+
+ HINSTANCE hKernel;
+};
+}
+
+
+void* Utility::loadSymbolKernel(const std::string& functionName)
+{
+ if (KernelDllHandler::getInstance().getHandle() != NULL)
+ return reinterpret_cast<void*>(::GetProcAddress(KernelDllHandler::getInstance().getHandle(), functionName.c_str()));
+ else
+ return NULL;
+}
bgstack15