Bug 1657208 - Dynamic-load urlmon.dll for x86 system. r=freddyb,mhowell

Our data indicates a few users of x86 system hit failure to load urlmon.dll
for unknown reasons.  Since we don't always require urlmon.dll,
we delay-load it, which causes a crash if loading urlmon.dll fails.

A proposed fix is to dynamically load urlmon.dll on x86.

Differential Revision: https://phabricator.services.mozilla.com/D88534
This commit is contained in:
Toshihito Kikuchi 2020-08-28 21:27:22 +00:00
Родитель c6ee293115
Коммит 3b8a3fad8f
3 изменённых файлов: 22 добавлений и 4 удалений

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

@ -303,9 +303,9 @@ FilenameTypeAndDetails nsContentSecurityUtils::FilenameToFilenameType(
if (widget::WinUtils::PreparePathForTelemetry(strSanitizedPath, flags)) {
DWORD cchDecodedUrl = INTERNET_MAX_URL_LENGTH;
WCHAR szOut[INTERNET_MAX_URL_LENGTH];
HRESULT hr =
::CoInternetParseUrl(fileName.get(), PARSE_SCHEMA, 0, szOut,
INTERNET_MAX_URL_LENGTH, &cchDecodedUrl, 0);
HRESULT hr;
SAFECALL_URLMON_FUNC(CoInternetParseUrl, fileName.get(), PARSE_SCHEMA, 0,
szOut, INTERNET_MAX_URL_LENGTH, &cchDecodedUrl, 0);
if (hr == S_OK && cchDecodedUrl) {
nsAutoString sanitizedPathAndScheme;
sanitizedPathAndScheme.Append(szOut);

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

@ -48,7 +48,8 @@ inline LauncherResult<_bstr_t> UrlmonValidateUri(const wchar_t* aUri) {
Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_PRE_PROCESS_HTML_URI |
Uri_CREATE_IE_SETTINGS;
RefPtr<IUri> uri;
HRESULT hr = CreateUri(aUri, flags, 0, getter_AddRefs(uri));
HRESULT hr;
SAFECALL_URLMON_FUNC(CreateUri, aUri, flags, 0, getter_AddRefs(uri));
if (FAILED(hr)) {
return LAUNCHER_ERROR_FROM_HRESULT(hr);
}

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

@ -51,6 +51,23 @@ typedef struct _FILE_ID_INFO {
# define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
#endif // !defined(STATUS_SUCCESS)
// Our data indicates a few users of Win7 x86 hit failure to load urlmon.dll
// for unknown reasons. Since we don't always require urlmon.dll on Win7,
// we delay-load it, which causes a crash if loading urlmon.dll fails. This
// macro is to safely load and call urlmon's API graciously without crash.
#if defined(_X86_)
# define SAFECALL_URLMON_FUNC(FuncName, ...) \
do { \
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype( \
&::FuncName)> \
func(L"urlmon.dll", #FuncName); \
hr = \
func ? func(__VA_ARGS__) : HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND); \
} while (0)
#else
# define SAFECALL_URLMON_FUNC(FuncName, ...) hr = ::FuncName(__VA_ARGS__)
#endif
namespace mozilla {
class WindowsError final {