зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1734650 - Ensure that LoadLibrarySystem32 loads dependencies from System32. r=handyman
Use LOAD_LIBRARY_SEARCH_SYSTEM32 if available. Otherwise use LOAD_WITH_ALTERED_SEARCH_PATH. Removed an anonymous namespace to share static variables. This namespace was necessary in order to avoid ODR violation before [this changeset](https://searchfox.org/mozilla-central/diff/416d586a1420dd82094c0cac417ee01213eb9ad6/xpcom/base/nsWindowsHelpers.h#160). It is not required anymore. Differential Revision: https://phabricator.services.mozilla.com/D158832
This commit is contained in:
Родитель
4370a03ad7
Коммит
14a8eaf026
|
@ -253,8 +253,6 @@ typedef nsAutoRef<nsHGLOBAL> nsAutoGlobalMem;
|
|||
typedef nsAutoRef<nsHPRINTER> nsAutoPrinter;
|
||||
typedef nsAutoRef<MSIHANDLE> nsAutoMsiHandle;
|
||||
|
||||
namespace {
|
||||
|
||||
// Construct a path "<system32>\<aModule>". return false if the output buffer
|
||||
// is too small.
|
||||
// Note: If the system path cannot be found, or doesn't fit in the output buffer
|
||||
|
@ -300,15 +298,18 @@ bool inline ConstructSystem32Path(LPCWSTR aModule, WCHAR* aSystemPath,
|
|||
}
|
||||
|
||||
HMODULE inline LoadLibrarySystem32(LPCWSTR aModule) {
|
||||
static const auto setDefaultDllDirectories =
|
||||
GetProcAddress(GetModuleHandleW(L"kernel32"), "SetDefaultDllDirectories");
|
||||
if (setDefaultDllDirectories) {
|
||||
return LoadLibraryExW(aModule, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
}
|
||||
WCHAR systemPath[MAX_PATH + 1];
|
||||
if (!ConstructSystem32Path(aModule, systemPath, MAX_PATH + 1)) {
|
||||
return NULL;
|
||||
}
|
||||
return LoadLibraryW(systemPath);
|
||||
return LoadLibraryExW(systemPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// for UniquePtr
|
||||
struct LocalFreeDeleter {
|
||||
void operator()(void* aPtr) { ::LocalFree(aPtr); }
|
||||
|
|
Загрузка…
Ссылка в новой задаче