aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2017-05-16 07:03:56 -0600
committerMark Young <marky@lunarg.com>2017-05-16 11:40:14 -0600
commit6e28b4892df485ed9a4f7c97bb043e23b5e618b4 (patch)
treee62947cc9830a96f65d99d5b2f28e4ddcbf45e73
parent59d37cab759405842c9adf2c78d6fad7414f6270 (diff)
downloadusermoji-6e28b4892df485ed9a4f7c97bb043e23b5e618b4.tar.xz
loader: Expand lib search locations
Expand library search locations based on recommendations by Dustin. We still attempt to use the old LoadLibrary first, and then, only if that fails, do we attempt to use the new search. Change-Id: I4cf1358f9eb7e45ac61f36435e926aa89c212f83
-rw-r--r--loader/vk_loader_platform.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h
index 0f71d9a3..8b82fe80 100644
--- a/loader/vk_loader_platform.h
+++ b/loader/vk_loader_platform.h
@@ -242,7 +242,15 @@ static char *loader_platform_basename(char *pathname) {
// Dynamic Loading:
typedef HMODULE loader_platform_dl_handle;
-static loader_platform_dl_handle loader_platform_open_library(const char *libPath) { return LoadLibrary(libPath); }
+static loader_platform_dl_handle loader_platform_open_library(const char *lib_path) {
+ // Try loading the library the original way first.
+ loader_platform_dl_handle lib_handle = LoadLibrary(lib_path);
+ if (lib_handle == NULL && GetLastError() == ERROR_MOD_NOT_FOUND && PathFileExists(lib_path)) {
+ // If that failed, then try loading it with broarder search folders.
+ lib_handle = LoadLibraryEx(lib_path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
+ }
+ return lib_handle;
+}
static char *loader_platform_open_library_error(const char *libPath) {
static char errorMsg[164];
(void)snprintf(errorMsg, 163, "Failed to open dynamic library \"%s\"", libPath);