merge mozilla-central to mozilla-inbound. r=merge a=merge

This commit is contained in:
Sebastian Hengst 2017-09-21 17:30:38 +02:00
commit 51d0835ce7
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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;