Bug 1322554: don't block threads based on MEM_IMAGE; safer exiting thread; don't block null threadproc to allow crashfirefox.exe; r=dmajor
MozReview-Commit-ID: IrcdhIMk1CC
--- a/mozglue/build/WindowsDllBlocklist.cpp
+++ b/mozglue/build/WindowsDllBlocklist.cpp
@@ -701,35 +701,46 @@ continue_loading:
#ifdef DEBUG_very_verbose
printf_stderr("LdrLoadDll: continuing load... ('%S')\n", moduleFileName->Buffer);
#endif
return stub_LdrLoadDll(filePath, flags, moduleFileName, handle);
}
static bool
-ShouldBlockThread(void* aStartAddress, void* aThreadParam)
+ShouldBlockThread(void* aStartAddress)
{
+ // allows crashfirefox.exe to continue to work. also if your threadproc is null, this crash is intentional.
+ if(aStartAddress == 0)
+ return false;
+
bool shouldBlock = false;
MEMORY_BASIC_INFORMATION startAddressInfo;
if (VirtualQuery(aStartAddress, &startAddressInfo, sizeof(startAddressInfo))) {
shouldBlock |= startAddressInfo.State != MEM_COMMIT;
shouldBlock |= startAddressInfo.Protect != PAGE_EXECUTE_READ;
- shouldBlock |= !(startAddressInfo.Type & MEM_IMAGE);
+ //shouldBlock |= !(startAddressInfo.Type & MEM_IMAGE); in the future we may want to be stricter by adding this check. for now playing it safe.
}
return shouldBlock;
}
+// allows blocked threads to still run normally through BaseThreadInitThunk, in case there's any magic there that we shouldn't skip.
+DWORD WINAPI
+NopThreadProc(void* aThreadParam)
+{
+ return 0;
+}
+
static MOZ_NORETURN void __fastcall
patched_BaseThreadInitThunk(BOOL aIsInitialThread, void* aStartAddress,
void* aThreadParam)
{
- if (ShouldBlockThread(aStartAddress, aThreadParam)) {
- ExitThread(1);
+ if (ShouldBlockThread(aStartAddress)) {
+ aStartAddress = NopThreadProc;
}
stub_BaseThreadInitThunk(aIsInitialThread, aStartAddress, aThreadParam);
}
WindowsDllInterceptor NtDllIntercept;
WindowsDllInterceptor Kernel32DllIntercept;