Bug 1361410: Don't hook BaseThreadInitThunk when WRusr.dll is loaded, mitigating a crash; r=dmajor
authorCarl Corcoran <carlco@gmail.com>
Thu, 17 Aug 2017 15:05:17 +0200
changeset 375933 89585e8d8a5bc2047b8d89bd06bc5d45b9ec8754
parent 375932 58db74bca66e1b6d274b0c56fa1c811a5aaa47a0
child 375934 8209aae88ad983b3699dce90fb8189f1e8b62763
push id49247
push userryanvm@gmail.com
push dateMon, 21 Aug 2017 16:00:16 +0000
treeherderautoland@89585e8d8a5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1361410
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1361410: Don't hook BaseThreadInitThunk when WRusr.dll is loaded, mitigating a crash; r=dmajor MozReview-Commit-ID: KqWq2bHT0CE
mozglue/build/WindowsDllBlocklist.cpp
--- a/mozglue/build/WindowsDllBlocklist.cpp
+++ b/mozglue/build/WindowsDllBlocklist.cpp
@@ -861,27 +861,30 @@ DllBlocklist_Initialize(uint32_t aInitFl
   if (!IsWin8OrLater()) {
     // The crash that this hook works around is only seen on Win7.
     Kernel32Intercept.AddHook("RtlInstallFunctionTableCallback",
                               reinterpret_cast<intptr_t>(patched_RtlInstallFunctionTableCallback),
                               (void**)&stub_RtlInstallFunctionTableCallback);
   }
 #endif
 
-#ifdef _M_IX86 // Minimize impact; crashes in BaseThreadInitThunk are vastly more frequent on x86
-  if(!Kernel32Intercept.AddDetour("BaseThreadInitThunk",
+#ifdef _M_IX86 // Minimize impact. Crashes in BaseThreadInitThunk are more frequent on x86
+
+  // Bug 1361410: WRusr.dll will overwrite our hook and cause a crash.
+  // Workaround: If we detect WRusr.dll, don't hook.
+  if (!GetModuleHandleW(L"WRusr.dll")) {
+    if(!Kernel32Intercept.AddDetour("BaseThreadInitThunk",
                                     reinterpret_cast<intptr_t>(patched_BaseThreadInitThunk),
                                     (void**) &stub_BaseThreadInitThunk)) {
 #ifdef DEBUG
-    printf_stderr("BaseThreadInitThunk hook failed\n");
+      printf_stderr("BaseThreadInitThunk hook failed\n");
 #endif
+    }
   }
 #endif // _M_IX86
-
-
 }
 
 MFBT_API void
 DllBlocklist_WriteNotes(HANDLE file)
 {
   DWORD nBytes;
 
   WriteFile(file, kBlockedDllsParameter, kBlockedDllsParameterLen, &nBytes, nullptr);