cefclient: win: Fix delayload of user32.dll

The WinSboxNoFakeGdiInit feature requires delayload of all DLLs that
might load user32.dll in the renderer process. It's enabled as a field
trial for all non-Official builds, but appears to only work with
non-component Release builds. See https://crbug.com/326277735
This commit is contained in:
Marshall Greenblatt 2024-05-24 10:54:37 -04:00
parent bd1e188c77
commit 5fe6382906
4 changed files with 46 additions and 16 deletions

View File

@ -1127,12 +1127,6 @@ source_set("libcef_static") {
deps += [ "//content:sandbox_helper_win" ]
}
libs = [
"comctl32.lib",
# For D3D11_DECODER_PROFILE_H264_VLD_NOFGT.
"dxguid.lib",
]
data_deps = [
"//chrome/elevation_service",
]
@ -1752,6 +1746,12 @@ if (is_mac) {
# Delay-load as many DLLs as possible for sandbox and startup perf
# improvements.
configs += [ "//build/config/win:delayloads" ]
libs = [
"comctl32.lib",
# For D3D11_DECODER_PROFILE_H264_VLD_NOFGT.
"dxguid.lib",
]
}
if (is_linux && !is_debug && !use_partition_alloc_as_malloc) {
@ -2266,8 +2266,13 @@ if (is_mac) {
if (target_cpu != "arm64") {
libs += [
"glu32.lib",
"opengl32.lib",
"glu32.lib"
]
ldflags = [
"/DELAYLOAD:glu32.dll",
"/DELAYLOAD:oleaut32.dll",
"/DELAYLOAD:opengl32.dll",
]
}
}

View File

@ -324,10 +324,11 @@ std::optional<int> ChromeMainDelegateCef::BasicStartupComplete() {
disable_features.push_back(base::kEnableHangWatcher.name);
}
#if BUILDFLAG(IS_WIN) && !defined(OFFICIAL_BUILD)
// Disable WinSboxNoFakeGdiInit which causes the renderer processes to crash
// with STATUS_DLL_INIT_FAILED. This is currently enabled via a field trial
// for non-Official builds. See https://crbug.com/326277735#comment23.
#if BUILDFLAG(IS_WIN) && (defined(COMPONENT_BUILD) || !defined(NDEBUG))
// Disable WinSboxNoFakeGdiInit for component and Debug builds. It causes
// renderer processes to crash with STATUS_DLL_INIT_FAILED. This is
// currently enabled via a field trial for non-Official builds.
// See https://crbug.com/326277735#comment37.
disable_features.push_back(
sandbox::policy::features::kWinSboxNoFakeGdiInit.name);
#endif

View File

@ -296,6 +296,8 @@ if(OS_WINDOWS)
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} d3d11.lib glu32.lib imm32.lib opengl32.lib)
# Add additional /DELAYLOADs that are missing from CEF_EXE_LINKER_FLAGS.
set_property(TARGET ${CEF_TARGET} PROPERTY LINK_FLAGS "/DELAYLOAD:glu32.dll /DELAYLOAD:oleaut32.dll /DELAYLOAD:opengl32.dll")
if(USE_ATL)
# Required by VS2013 to link accessibility API functions.

View File

@ -217,14 +217,34 @@ void CFHtmlToHtml(const std::string& cf_html,
}
}
const DWORD moz_url_format = ::RegisterClipboardFormat(L"text/x-moz-url");
const DWORD html_format = ::RegisterClipboardFormat(L"HTML Format");
const DWORD file_desc_format = ::RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
const DWORD file_contents_format =
::RegisterClipboardFormat(CFSTR_FILECONTENTS);
DWORD GetMozUrlFormat() {
static DWORD moz_url_format = ::RegisterClipboardFormat(L"text/x-moz-url");
return moz_url_format;
}
DWORD GetHtmlFormat() {
static DWORD html_format = ::RegisterClipboardFormat(L"HTML Format");
return html_format;
}
DWORD GetFileDescFormat() {
static DWORD file_desc_format =
::RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
return file_desc_format;
}
DWORD GetFileContentsFormat() {
static DWORD file_contents_format =
::RegisterClipboardFormat(CFSTR_FILECONTENTS);
return file_contents_format;
}
bool DragDataToDataObject(CefRefPtr<CefDragData> drag_data,
IDataObject** data_object) {
const DWORD moz_url_format = GetMozUrlFormat();
const DWORD html_format = GetHtmlFormat();
const DWORD file_desc_format = GetFileDescFormat();
const DWORD file_contents_format = GetFileContentsFormat();
const int kMaxDataObjects = 10;
FORMATETC fmtetcs[kMaxDataObjects];
STGMEDIUM stgmeds[kMaxDataObjects];
@ -283,6 +303,8 @@ bool DragDataToDataObject(CefRefPtr<CefDragData> drag_data,
}
CefRefPtr<CefDragData> DataObjectToDragData(IDataObject* data_object) {
const DWORD moz_url_format = GetMozUrlFormat();
const DWORD html_format = GetHtmlFormat();
CefRefPtr<CefDragData> drag_data = CefDragData::Create();
IEnumFORMATETC* enumFormats = nullptr;
HRESULT res = data_object->EnumFormatEtc(DATADIR_GET, &enumFormats);