Bug 1751367: Delay loading winmm.dll, so it loads after COM initialization. r=cmartin,media-playback-reviewers,alwu

This is to prevent user32.dll from loading before COM initialization on earlier
version of windows.

Differential Revision: https://phabricator.services.mozilla.com/D136936
This commit is contained in:
Bob Owen 2022-02-01 13:31:33 +00:00
parent dd05abfc31
commit b9d6b5e60a
5 changed files with 12 additions and 1 deletions

View File

@ -212,6 +212,7 @@ mozilla::ipc::IPCResult GMPChild::RecvPreloadLibs(const nsCString& aLibs) {
u"ole32.dll", // required for OPM
u"psapi.dll", // For GetMappedFileNameW, see bug 1383611
u"softokn3.dll", // NSS for clearkey CDM
u"winmm.dll", // Dependency for widevine
};
constexpr static bool (*IsASCII)(const char16_t*) =
IsAsciiNullTerminated<char16_t>;

View File

@ -907,7 +907,7 @@ RefPtr<GenericPromise> GMPParent::ParseChromiumManifest(
#if XP_WIN
// psapi.dll added for GetMappedFileNameW, which could possibly be avoided
// in future versions, see bug 1383611 for details.
mLibs = "dxva2.dll, ole32.dll, psapi.dll"_ns;
mLibs = "dxva2.dll, ole32.dll, psapi.dll, winmm.dll"_ns;
#endif
} else if (mDisplayName.EqualsASCII("fake")) {
// The fake CDM just exposes a key system with id "fake".

View File

@ -23,6 +23,10 @@ UtilityProcessImpl::~UtilityProcessImpl() { mUtility = nullptr; }
bool UtilityProcessImpl::Init(int aArgc, char* aArgv[]) {
#if defined(MOZ_SANDBOX) && defined(OS_WIN)
// We delay load winmm.dll so that its dependencies don't interfere with COM
// initialization when win32k is locked down. We need to load it before we
// lower the sandbox in processes where the policy will prevent loading.
::LoadLibraryW(L"winmm.dll");
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif

View File

@ -145,6 +145,11 @@ if CONFIG["OS_TARGET"] == "WINNT":
if CONFIG["CPU_ARCH"] == "x86":
# This should really be the default.
sandbox_vars["ASFLAGS"] = ["-safeseh"]
DELAYLOAD_DLLS += [
"winmm.dll",
]
if CONFIG["OS_TARGET"] == "Android":
sandbox_vars["CFLAGS"] = [
"-include",

View File

@ -53,6 +53,7 @@ def Libxul(name, output_category=None):
"usp10.dll",
"uxtheme.dll",
"wininet.dll",
"winmm.dll",
"winspool.drv",
"wtsapi32.dll",
]