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
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 25 Sep 2012 22:25:51 -0700
changeset 108029 ca4af4af53340933f582dcb808db90ee2b4357ad
parent 108028 acd23e460291f32a881c994ec6d0374df3e00cb0
child 108030 afaa6863bff4ca8f4eeb8071500d1b061d9e2bb0
child 110966 01f2340b9b03595b11719e719de5fbcd16ac6e16
push id23529
push userbsmedberg@mozilla.com
push dateWed, 26 Sep 2012 05:27:15 +0000
treeherdermozilla-central@ca4af4af5334 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs792541
milestone18.0a1
first release with
nightly linux32
ca4af4af5334 / 18.0a1 / 20120926030625 / files
nightly linux64
ca4af4af5334 / 18.0a1 / 20120926030625 / files
nightly mac
ca4af4af5334 / 18.0a1 / 20120926030625 / files
nightly win32
ca4af4af5334 / 18.0a1 / 20120926030625 / files
nightly win64
ca4af4af5334 / 18.0a1 / 20120926030625 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
build/valgrind/x86_64-redhat-linux-gnu.sup
toolkit/xre/nsWindowsDllBlocklist.cpp
--- a/toolkit/xre/nsWindowsDllBlocklist.cpp
+++ b/toolkit/xre/nsWindowsDllBlocklist.cpp
@@ -49,16 +49,21 @@ struct DllBlockInfo {
   // dll.  Otherwise, we'll block all versions less than or equal to
   // the given version, as queried by GetFileVersionInfo and
   // VS_FIXEDFILEINFO's dwFileVersionMS and dwFileVersionLS fields.
   //
   // Note that the version is usually 4 components, which is A.B.C.D
   // 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[] = {
   // EXAMPLE:
   // { "uxtheme.dll", ALL_VERSIONS },
   // { "uxtheme.dll", 0x0000123400000000ULL },
   // The DLL name must be in lowercase!
   
@@ -103,16 +108,18 @@ static DllBlockInfo sWindowsDllBlocklist
 
   // Topcrash with Roboform in Firefox 8 (bug 699134)
   {"rf-firefox.dll", MAKE_VERSION(7,6,1,0)},
   {"roboform.dll", MAKE_VERSION(7,6,1,0)},
 
   // 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 },
 
   { NULL, 0 }
 };
 
 #ifndef STATUS_DLL_NOT_FOUND
@@ -270,16 +277,26 @@ wchar_t* getFullPath (PWCHAR filePath, w
     return nullptr;
   }
 
   // now actually grab it
   SearchPathW(sanitizedFilePath, fname, L".dll", pathlen+1, full_fname, NULL);
   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)
 {
   // We have UCS2 (UTF16?), we want ASCII, but we also just want the filename portion
 #define DLLNAME_MAX 128
   char dllName[DLLNAME_MAX+1];
   wchar_t *dll_part;
   DllBlockInfo *info;
@@ -357,16 +374,21 @@ patched_LdrLoadDll (PWCHAR filePath, PUL
 
   if (info->name) {
     bool load_ok = false;
 
 #ifdef DEBUG_very_verbose
     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()) {
         goto continue_loading;
       }
 
       full_fname = getFullPath(filePath, fname);
       if (!full_fname) {