Skip to content

Commit

Permalink
Remove current directory from DLL searching
Browse files Browse the repository at this point in the history
By removing the current directory from the search paths for dlls, the
loader is less vulnerable.
  • Loading branch information
charles-lunarg committed Feb 6, 2024
1 parent 1f18caf commit e0d594e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions loader/loader_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ void windows_initialization(void) {
loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "Using Vulkan Loader %s", dll_location);
}

SetDllDirectory(""); // Remove current directory from default DLL search order
// This is needed to ensure that newer APIs are available right away
// and not after the first call that has been statically linked
LoadLibrary("gdi32.dll");
SetDllDirectory(NULL); // Restores the default search order

wchar_t systemPath[MAX_PATH] = L"";
GetSystemDirectoryW(systemPath, MAX_PATH);
Expand Down

0 comments on commit e0d594e

Please sign in to comment.