diff --git a/mozglue/build/WindowsDllBlocklist.cpp b/mozglue/build/WindowsDllBlocklist.cpp index eab7531560b0..e003bc0fa423 100644 --- a/mozglue/build/WindowsDllBlocklist.cpp +++ b/mozglue/build/WindowsDllBlocklist.cpp @@ -303,8 +303,10 @@ printf_stderr(const char *fmt, ...) } +#ifdef _M_IX86 typedef MOZ_NORETURN_PTR void (__fastcall* BaseThreadInitThunk_func)(BOOL aIsInitialThread, void* aStartAddress, void* aThreadParam); static BaseThreadInitThunk_func stub_BaseThreadInitThunk = nullptr; +#endif typedef NTSTATUS (NTAPI *LdrLoadDll_func) (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle); static LdrLoadDll_func stub_LdrLoadDll; @@ -786,6 +788,7 @@ continue_loading: return stub_LdrLoadDll(filePath, flags, moduleFileName, handle); } +#ifdef _M_IX86 static bool ShouldBlockThread(void* aStartAddress) { @@ -821,6 +824,8 @@ patched_BaseThreadInitThunk(BOOL aIsInitialThread, void* aStartAddress, stub_BaseThreadInitThunk(aIsInitialThread, aStartAddress, aThreadParam); } +#endif // _M_IX86 + static WindowsDllInterceptor NtDllIntercept; static WindowsDllInterceptor Kernel32Intercept; @@ -870,6 +875,8 @@ DllBlocklist_Initialize(uint32_t aInitFlags) } #endif +#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")) { @@ -881,6 +888,7 @@ DllBlocklist_Initialize(uint32_t aInitFlags) #endif } } +#endif // _M_IX86 } MFBT_API void diff --git a/toolkit/xre/test/win/TestDllInterceptor.cpp b/toolkit/xre/test/win/TestDllInterceptor.cpp index 514404ac1dc6..2c1afa9ef773 100644 --- a/toolkit/xre/test/win/TestDllInterceptor.cpp +++ b/toolkit/xre/test/win/TestDllInterceptor.cpp @@ -548,7 +548,9 @@ int main() TestHook(TestSetCursorPos, "user32.dll", "SetCursorPos") && TestHook(TestTlsAlloc, "kernel32.dll", "TlsAlloc") && TestHook(TestTlsFree, "kernel32.dll", "TlsFree") && +#ifdef _M_IX86 TestDetour("kernel32.dll", "BaseThreadInitThunk") && +#endif TestDetour("ntdll.dll", "LdrLoadDll")) { printf("TEST-PASS | WindowsDllInterceptor | all checks passed\n"); return 0;