Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mumble_exe: document LoadLibraryEx workaround for mumble-voip/mumble#2837. #3113

Merged
merged 1 commit into from Jun 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/mumble_exe/mumble_exe.cpp
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'-- since it doesn't every try to load'

type-o here, perhaps you meant 'even' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks!

// 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();
Expand Down