Bug 932100 - Part 1: Remove load-time dependency on user32. r=bsmedberg, a=bajaj
authorDavid Major <dmajor@mozilla.com>
Tue, 12 Nov 2013 08:31:32 -0500
changeset 167525 5ddfaf5ea4f73ba857f126139daf310fa434f88c
parent 167524 8e85dacac5dec38a75f47f868028553ce6768617
child 167526 5f97e043f2b80935d021b44a3f4bebc61d6cd0bb
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, bajaj
bugs932100
milestone27.0a2
Bug 932100 - Part 1: Remove load-time dependency on user32. r=bsmedberg, a=bajaj
browser/app/nsBrowserApp.cpp
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -73,19 +73,29 @@ static void Output(const char *fmt, ... 
                       0,
                       msg,
                       -1,
                       wide_msg,
                       _countof(wide_msg));
 #if MOZ_WINCONSOLE
   fwprintf_s(stderr, wide_msg);
 #else
-  MessageBoxW(nullptr, wide_msg, L"Firefox", MB_OK
-                                           | MB_ICONERROR
-                                           | MB_SETFOREGROUND);
+  // Linking user32 at load-time interferes with the DLL blocklist (bug 932100).
+  // This is a rare codepath, so we can load user32 at run-time instead.
+  HMODULE user32 = LoadLibraryW(L"user32.dll");
+  if (user32) {
+    typedef int (WINAPI * MessageBoxWFn)(HWND, LPCWSTR, LPCWSTR, UINT);
+    MessageBoxWFn messageBoxW = (MessageBoxWFn)GetProcAddress(user32, "MessageBoxW");
+    if (messageBoxW) {
+      messageBoxW(nullptr, wide_msg, L"Firefox", MB_OK
+                                               | MB_ICONERROR
+                                               | MB_SETFOREGROUND);
+    }
+    FreeLibrary(user32);
+  }
 #endif
 #endif
 
   va_end(ap);
 }
 
 /**
  * Return true if |arg| matches the given argument name.