Skip to content

Commit

Permalink
Bug 792541 - Block sprotector.dll on Windows 8 and up. Add support in…
Browse files Browse the repository at this point in the history
… the windows blocklist for flags and add a flag for "win8 and up only", r=ehsan a=akeybl
  • Loading branch information
bsmedberg committed Sep 26, 2012
1 parent d7dad06 commit 4d9d851
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions toolkit/xre/nsWindowsDllBlocklist.cpp
Expand Up @@ -53,6 +53,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[] = {
Expand Down Expand Up @@ -107,6 +112,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 },
Expand Down Expand Up @@ -286,6 +293,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)
{
Expand Down Expand Up @@ -373,6 +390,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()) {
Expand Down

0 comments on commit 4d9d851

Please sign in to comment.