summaryrefslogtreecommitdiff
path: root/shared/dllLoader.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:03:20 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:03:20 +0200
commit528635604eea1d8c679a3d038e2f00030ef72444 (patch)
tree9c3cbec29aa7d3e209939662e040b9342c9e7400 /shared/dllLoader.cpp
parent3.1 (diff)
downloadFreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.gz
FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.bz2
FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.zip
3.2
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