Skip to content
Permalink
Browse files

Merge PR #3113: mumble_exe: document LoadLibraryEx workaround for #2837.

  • Loading branch information...
mkrautz committed Jun 3, 2017
2 parents 7c77b8c + 8ba982f commit d3bacc5a348ef09a522eee38bd89b17d29fa831f
Showing with 32 additions and 0 deletions.
  1. +32 −0 src/mumble_exe/mumble_exe.cpp
@@ -75,6 +75,38 @@ static bool ConfigureEnvironment() {

// Set the versioned root as the working directory if one is available.
// If not, use the directory containing mumble.exe as the working directory.
//
// We use the versioned root as the working directory because of an odd
// interaction between the UCRT's forward exports and LoadLibraryEx.
// Most likely a bug in older Windows versions (Windows 10 is unaffected).
//
// In Mumble, mumble_app.dll is loaded via
//
// LoadLibraryEx(..., ..., LOAD_WITH_ALTERED_SEARCH_PATH).
//
// This works on Windows 10, but is broken on Windows 7. On Windows 7, it
// seems like the forward exports from api-win-ms*.dll to ucrtbase.dll cause
// ucrtbase.dll to be loaded WITHOUT LOAD_WITH_ALTERED_SEARCH_PATH, but instead
// using Standard Search Order For Desktop Applications.
//
// It looks for ucrtbase.dll in the following locations:
//
// 1. Next to the .exe
// 2. 32-bit system directory
// 3. 16-bit system directory
// 4. Windows folder
// 5. CWD
// 6. %PATH% (seemingly)...
//
// But the application doesn't run -- since it doesn't every try to load
// ucrtbase.dll in the directory containing mumble_app.dll -- as it should,
// because we've loaded mumble_app.dll with LOAD_WITH_ALTERED_SEARCH_PATH.
//
// Our workaround is to use the mumble_app.dll's directory as the working
// directory. This causes the program to successfully load, even when
// ucrtbase.dll is loaded using the Standard Search Order For Desktop.
//
// See https://github.com/mumble-voip/mumble/issues/2837 for more information.
std::wstring cwd = GetVersionedRootPath();
if (cwd.empty()) {
cwd = GetExecutableDirPath();

0 comments on commit d3bacc5

Please sign in to comment.
You can’t perform that action at this time.