Bug 1724749: Consolidate all dllservices code; r=tkikuchi

Per the discussion on governance, the new DLL services module will live in
`toolkit/xre/dllservices`.

Mozglue code will live in `toolkit/xre/dllservices/mozglue` and will be linked
in with `mozglue.dll`.

Differential Revision: https://phabricator.services.mozilla.com/D122384
This commit is contained in:
Aaron Klotz 2021-08-11 23:08:52 +00:00
Родитель bed8fb35ca
Коммит cdc3b69555
69 изменённых файлов: 82 добавлений и 42 удалений

Просмотреть файл

@ -39,9 +39,10 @@ if CONFIG["OS_TARGET"] == "WINNT":
if CONFIG["MOZ_MEMORY"]:
DEFFILE = "mozglue.def"
# We'll break the DLL blocklist if we immediately load user32.dll.
# For the same reason, we delayload winmm.dll and ole32.dll which
# statically link user32.dll.
# For the same reason, we delayload these other DLLs to avoid eager
# dependencies on user32.dll.
DELAYLOAD_DLLS += [
"oleaut32.dll",
"ole32.dll",
"user32.dll",
"winmm.dll",

Просмотреть файл

@ -50,12 +50,6 @@ SOURCES += [
OS_LIBS += CONFIG["REALTIME_LIBS"]
if CONFIG["OS_ARCH"] == "WINNT":
DIRS += [
"interceptor",
]
EXPORTS += [
"nsWindowsDllInterceptor.h",
]
EXPORTS.mozilla += [
"DynamicallyLinkedFunctionPtr.h",
"ImportDir.h",

Просмотреть файл

@ -13,9 +13,6 @@ if CONFIG["MOZ_LINKER"] or CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
DIRS += ["android"]
if CONFIG["OS_TARGET"] == "WINNT":
DIRS += ["dllservices"]
DIRS += [
"baseprofiler",
"build",

Просмотреть файл

@ -4,17 +4,9 @@
if CONFIG["OS_ARCH"] == "WINNT":
SOURCES += [
"TestDLLBlocklist.cpp",
"TestNativeNtGTest.cpp",
]
TEST_DIRS += [
"TestDllBlocklist_AllowByVersion",
"TestDllBlocklist_MatchByName",
"TestDllBlocklist_MatchByVersion",
"TestDllBlocklist_NoOpEntryPoint",
]
SOURCES += [
"TestStackWalk.cpp",
]

Просмотреть файл

@ -36,9 +36,6 @@ if CONFIG["OS_ARCH"] == "WINNT":
],
linkage=None,
)
TEST_DIRS += [
"interceptor",
]
OS_LIBS += [
"ntdll",
"version",

Просмотреть файл

@ -22,6 +22,8 @@
#include "nsWindowsHelpers.h"
#include "nsXULAppAPI.h"
namespace mozilla {
// Fills a Vector with keyboard layout DLLs found in the registry.
// These are leaf names only, not full paths. Here we will convert them to
// lowercase before returning, to facilitate case-insensitive searches.
@ -61,8 +63,6 @@ static Vector<nsString> GetKeyboardLayoutDlls() {
return result;
}
namespace mozilla {
/* static */
bool ModuleEvaluator::ResolveKnownFolder(REFKNOWNFOLDERID aFolderId,
nsIFile** aOutFile) {

Просмотреть файл

@ -16,6 +16,8 @@
#include "nsIFile.h"
#include "nsString.h"
#include <shtypes.h>
namespace mozilla {
class ModuleRecord;

Просмотреть файл

@ -62,6 +62,8 @@ static LONGLONG TimeUnitsToQPC(const LONGLONG aTimeStamp,
return result;
}
namespace mozilla {
static Maybe<double> QPCLoadDurationToMilliseconds(
const ModuleLoadInfo& aNtInfo) {
if (aNtInfo.IsBare()) {
@ -71,8 +73,6 @@ static Maybe<double> QPCLoadDurationToMilliseconds(
return Some(QPCToMilliseconds<double>(aNtInfo.mLoadTimeInfo.QuadPart));
}
namespace mozilla {
ModuleRecord::ModuleRecord() : mTrustFlags(ModuleTrustFlags::None) {}
ModuleRecord::ModuleRecord(const nsAString& aResolvedNtPath)

Просмотреть файл

@ -688,12 +688,12 @@ UntrustedModulesProcessor::SendGetModulesTrust(ModulePaths&& aModules,
switch (XRE_GetProcessType()) {
case GeckoProcessType_Content: {
return ::SendGetModulesTrust(dom::ContentChild::GetSingleton(),
std::move(aModules), runNormal);
return ::mozilla::SendGetModulesTrust(dom::ContentChild::GetSingleton(),
std::move(aModules), runNormal);
}
case GeckoProcessType_RDD: {
return ::SendGetModulesTrust(RDDParent::GetSingleton(),
std::move(aModules), runNormal);
return ::mozilla::SendGetModulesTrust(RDDParent::GetSingleton(),
std::move(aModules), runNormal);
}
default: {
MOZ_ASSERT_UNREACHABLE("Unsupported process type");

Просмотреть файл

Просмотреть файл

@ -0,0 +1,35 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files("**"):
BUG_COMPONENT = ("Core", "DLL Services")
FINAL_LIBRARY = "xul"
EXPORTS.mozilla += [
"ModuleVersionInfo.h",
"UntrustedModulesData.h",
"UntrustedModulesProcessor.h",
"WinDllServices.h",
]
DIRS += [
"mozglue",
]
UNIFIED_SOURCES += [
"ModuleEvaluator.cpp",
"ModuleVersionInfo.cpp",
"UntrustedModulesData.cpp",
"UntrustedModulesProcessor.cpp",
"WinDllServices.cpp",
]
TEST_DIRS += [
"tests",
]
include("/ipc/chromium/chromium-config.mozbuild")

Просмотреть файл

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG["MOZ_WIDGET_TOOLKIT"]:
SOURCES += [
# This file contains a |using namespace mozilla;| statement
"WindowsDllBlocklist.cpp",
@ -35,6 +34,10 @@ DELAYLOAD_DLLS += [
"wintrust.dll",
]
EXPORTS += [
"nsWindowsDllInterceptor.h",
]
EXPORTS.mozilla += [
"Authenticode.h",
"CacheNtDllThunk.h",
@ -61,6 +64,11 @@ GeneratedFile(
entry_point="gen_blocklists",
inputs=["WindowsDllBlocklistDefs.in"]
)
EXPORTS.mozilla += ["!" + hdr for hdr in blocklist_files]
DIRS += [
"interceptor",
]
FINAL_LIBRARY = "mozglue"

Просмотреть файл

@ -0,0 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SOURCES += [
"TestDLLBlocklist.cpp",
]
TEST_DIRS += [
"TestDllBlocklist_AllowByVersion",
"TestDllBlocklist_MatchByName",
"TestDllBlocklist_MatchByVersion",
"TestDllBlocklist_NoOpEntryPoint",
]
FINAL_LIBRARY = "xul-gtest"

Просмотреть файл

@ -13,7 +13,7 @@ GeckoCppUnitTests(
linkage=None,
)
if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["CPU_ARCH"] in ("x86", "x86_64"):
if CONFIG["CPU_ARCH"] in ("x86", "x86_64"):
# Cross-process interceptors not yet supported on aarch64
GeckoCppUnitTests(
[
@ -33,8 +33,12 @@ DELAYLOAD_DLLS += [
"shlwapi.dll",
]
if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["CC_TYPE"] in ("gcc", "clang"):
if CONFIG["CC_TYPE"] in ("gcc", "clang"):
# This allows us to use wmain as the entry point on mingw
LDFLAGS += [
"-municode",
]
TEST_DIRS += [
"gtest",
]

Просмотреть файл

@ -40,7 +40,6 @@ EXPORTS.mozilla += [
"CmdLineAndEnvUtils.h",
"MultiInstanceLock.h",
"SafeMode.h",
"UntrustedModulesData.h",
]
if CONFIG["MOZ_INSTRUMENT_EVENT_LOOP"]:
@ -50,22 +49,14 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
EXPORTS.mozilla += [
"AssembleCmdLine.h",
"DllPrefetchExperimentRegistryInfo.h",
"ModuleVersionInfo.h",
"PolicyChecks.h",
"UntrustedModulesProcessor.h",
"WinDllServices.h",
"WinTokenUtils.h",
]
UNIFIED_SOURCES += [
"/toolkit/mozapps/update/common/pathhash.cpp",
"/toolkit/mozapps/update/common/updateutils_win.cpp",
"DllPrefetchExperimentRegistryInfo.cpp",
"ModuleEvaluator.cpp",
"ModuleVersionInfo.cpp",
"nsNativeAppSupportWin.cpp",
"UntrustedModulesData.cpp",
"UntrustedModulesProcessor.cpp",
"WinDllServices.cpp",
"WinTokenUtils.cpp",
]
DEFINES["PROXY_PRINTING"] = 1
@ -79,6 +70,9 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
UNIFIED_SOURCES += [
"LauncherRegistryInfo.cpp",
]
DIRS += [
"dllservices",
]
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
EXPORTS.mozilla += [
"MacRunFromDmgUtils.h",