зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1742692 - Add some modules to mozglue's delayload list. r=mhowell
Differential Revision: https://phabricator.services.mozilla.com/D131968
This commit is contained in:
Родитель
f79e555648
Коммит
bdceca20fa
|
@ -79,6 +79,7 @@ if CONFIG["OS_ARCH"] == "WINNT":
|
|||
"/browser/app/winlauncher",
|
||||
]
|
||||
DELAYLOAD_DLLS += [
|
||||
"advapi32.dll",
|
||||
"oleaut32.dll",
|
||||
"ole32.dll",
|
||||
"rpcrt4.dll",
|
||||
|
|
|
@ -42,9 +42,12 @@ if CONFIG["OS_TARGET"] == "WINNT":
|
|||
# For the same reason, we delayload these other DLLs to avoid eager
|
||||
# dependencies on user32.dll.
|
||||
DELAYLOAD_DLLS += [
|
||||
"advapi32.dll",
|
||||
"dbghelp.dll",
|
||||
"oleaut32.dll",
|
||||
"ole32.dll",
|
||||
"user32.dll",
|
||||
"version.dll",
|
||||
"winmm.dll",
|
||||
]
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include <libloaderapi.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE aInstDll, DWORD aReason, LPVOID) {
|
||||
if (aReason == DLL_PROCESS_ATTACH) {
|
||||
::DisableThreadLibraryCalls(aInstDll);
|
||||
|
||||
// mozglue.dll imports RtlGenRandom from advapi32.dll as SystemFunction036,
|
||||
// but the actual function is implemented in cryptbase.dll. To avoid
|
||||
// loading a fake cryptbase.dll from the installation directory, we preload
|
||||
// cryptbase.dll from the system directory.
|
||||
::LoadLibraryExW(L"cryptbase.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -65,6 +65,7 @@ if CONFIG["OS_ARCH"] == "WINNT":
|
|||
SOURCES += [
|
||||
"GetKnownFolderPath.cpp",
|
||||
"TimeStamp_windows.cpp",
|
||||
"WindowsDllMain.cpp",
|
||||
"WindowsDpiInitialization.cpp",
|
||||
"WindowsMapRemoteView.cpp",
|
||||
"WindowsProcessMitigations.cpp",
|
||||
|
|
|
@ -166,6 +166,13 @@ bool SignedBinary::QueryObject(const wchar_t* aFilePath) {
|
|||
*/
|
||||
/* static */
|
||||
bool SignedBinary::VerifySignatureInternal(WINTRUST_DATA& aTrustData) {
|
||||
static const mozilla::StaticDynamicallyLinkedFunctionPtr<
|
||||
decltype(&::WinVerifyTrust)>
|
||||
pWinVerifyTrust(L"wintrust.dll", "WinVerifyTrust");
|
||||
if (!pWinVerifyTrust) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aTrustData.dwUIChoice = WTD_UI_NONE;
|
||||
aTrustData.fdwRevocationChecks = WTD_REVOKE_NONE;
|
||||
aTrustData.dwStateAction = WTD_STATEACTION_VERIFY;
|
||||
|
@ -173,10 +180,10 @@ bool SignedBinary::VerifySignatureInternal(WINTRUST_DATA& aTrustData) {
|
|||
|
||||
const HWND hwnd = (HWND)INVALID_HANDLE_VALUE;
|
||||
GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
|
||||
LONG result = ::WinVerifyTrust(hwnd, &policyGUID, &aTrustData);
|
||||
LONG result = pWinVerifyTrust(hwnd, &policyGUID, &aTrustData);
|
||||
|
||||
aTrustData.dwStateAction = WTD_STATEACTION_CLOSE;
|
||||
::WinVerifyTrust(hwnd, &policyGUID, &aTrustData);
|
||||
pWinVerifyTrust(hwnd, &policyGUID, &aTrustData);
|
||||
|
||||
return result == ERROR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -189,6 +189,12 @@ bool TestFindRegion() {
|
|||
}
|
||||
|
||||
extern "C" int wmain(int argc, wchar_t* argv[]) {
|
||||
// Preload delayload modules (e.g. advapi32.dll, bcryptPrimitives.dll, etc.)
|
||||
// by calling rand_s(), which is used in MMPolicy::FindRegion, before
|
||||
// depleting the process memory during the test.
|
||||
unsigned int rnd = 0;
|
||||
rand_s(&rnd);
|
||||
|
||||
if (!TestFindRegion()) {
|
||||
return 1;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче