From 5c4000df9d835f6a6593242d59161c8148f1044c Mon Sep 17 00:00:00 2001 From: Carl Corcoran Date: Thu, 17 Aug 2017 15:05:17 +0200 Subject: [PATCH] Bug 1361410: Don't hook BaseThreadInitThunk when WRusr.dll is loaded, mitigating a crash; r=dmajor MozReview-Commit-ID: KqWq2bHT0CE --HG-- extra : rebase_source : 54292be2efe4d50ec5806c1d066eb34ac97ecf14 --- mozglue/build/WindowsDllBlocklist.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mozglue/build/WindowsDllBlocklist.cpp b/mozglue/build/WindowsDllBlocklist.cpp index 4f608d70b422..753422a81251 100644 --- a/mozglue/build/WindowsDllBlocklist.cpp +++ b/mozglue/build/WindowsDllBlocklist.cpp @@ -866,17 +866,20 @@ DllBlocklist_Initialize(uint32_t aInitFlags) } #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(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