Bug 792541 - Block sprotector.dll on Windows 8 and up. Add support in the windows blocklist for flags and add a flag for "win8 and up only", r=ehsan

--HG--
rename : build/valgrind/cross-architecture.sup => build/valgrind/x86_64-redhat-linux-gnu.sup
extra : rebase_source : e7f5420fd981d467f109e2dc9a7408f32cc18394
This commit is contained in:
Benjamin Smedberg 2012-09-25 22:25:51 -07:00
parent 06e7cc23e4
commit a4f76fb27d

View File

@ -54,6 +54,11 @@ struct DllBlockInfo {
// encoded as 0x AAAA BBBB CCCC DDDD ULL (spaces added for clarity),
// but it's not required to be of that format.
unsigned long long maxVersion;
enum {
FLAGS_DEFAULT = 0,
BLOCK_WIN8PLUS_ONLY = 1
} flags;
};
static DllBlockInfo sWindowsDllBlocklist[] = {
@ -108,6 +113,8 @@ static DllBlockInfo sWindowsDllBlocklist[] = {
// Topcrash with Babylon Toolbar on FF16+ (bug 721264)
{"babyfox.dll", ALL_VERSIONS},
{"sprotector.dll", ALL_VERSIONS, DllBlockInfo::BLOCK_WIN8PLUS_ONLY },
// leave these two in always for tests
{ "mozdllblockingtest.dll", ALL_VERSIONS },
{ "mozdllblockingtest_versioned.dll", 0x0000000400000000ULL },
@ -275,6 +282,16 @@ wchar_t* getFullPath (PWCHAR filePath, wchar_t* fname)
return full_fname;
}
static bool
IsWin8OrLater()
{
OSVERSIONINFOW osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
GetVersionExW(&osInfo);
return (osInfo.dwMajorVersion > 6) ||
(osInfo.dwMajorVersion >= 6 && osInfo.dwMinorVersion >= 2);
}
static NTSTATUS NTAPI
patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle)
{
@ -362,6 +379,11 @@ patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileNam
printf_stderr("LdrLoadDll: info->name: '%s'\n", info->name);
#endif
if ((info->flags == DllBlockInfo::BLOCK_WIN8PLUS_ONLY) &&
!IsWin8OrLater()) {
goto continue_loading;
}
if (info->maxVersion != ALL_VERSIONS) {
ReentrancySentinel sentinel(dllName);
if (sentinel.BailOut()) {