use ImageBase when loading dependency

Change-Id: I8033ffcc9391ea809964f3cd3cd60da0c01fe156
This commit is contained in:
Artur Harasimiuk
2018-03-07 09:11:53 +01:00
committed by sys_ocldev
parent 7cbc35a45a
commit a66a92af57

View File

@@ -39,9 +39,12 @@ namespace Windows {
decltype(&LoadLibraryExA) OsLibrary::loadLibraryExA = LoadLibraryExA;
decltype(&GetModuleFileNameA) OsLibrary::getModuleFileNameA = GetModuleFileNameA;
extern "C" IMAGE_DOS_HEADER __ImageBase;
__inline HINSTANCE GetModuleHINSTANCE() { return (HINSTANCE)&__ImageBase; }
HMODULE OsLibrary::loadDependency(const std::string &dependencyFileName) const {
char dllPath[MAX_PATH];
DWORD length = getModuleFileNameA(GetModuleHandle(NULL), dllPath, MAX_PATH);
DWORD length = getModuleFileNameA(GetModuleHINSTANCE(), dllPath, MAX_PATH);
for (DWORD idx = length; idx > 0; idx--) {
if (dllPath[idx - 1] == '\\') {
dllPath[idx] = '\0';