Bug 1361410 - Don't hook BaseThreadInitThunk when WRusr.dll is loaded, mitigating a crash. r=dmajor, a=lizzard
authorCarl Corcoran <carlco@gmail.com>
Thu, 17 Aug 2017 15:05:17 +0200
changeset 421353 ccd625c4e5f1001a96dc74bc4ee1e8956ad02ea7
parent 421352 b08da0b322263480e2a53e78c07bc2845b3d0193
child 421354 9ea3c346233617a6f769a6bd2e07130d7db9d89f
push id7658
push userryanvm@gmail.com
push dateWed, 23 Aug 2017 21:11:31 +0000
treeherdermozilla-beta@d51bedb9d492 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor, lizzard
bugs1361410
milestone56.0
Bug 1361410 - Don't hook BaseThreadInitThunk when WRusr.dll is loaded, mitigating a crash. r=dmajor, a=lizzard 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);