- Timestamp:
- Oct 13, 2014 2:55:00 PM (10 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r53004 r53045 1018 1018 #ifdef RT_OS_WINDOWS 1019 1019 if ( g_hStartupLog != NULL 1020 && g_cbStartupLog < 1 28*_1M)1020 && g_cbStartupLog < 16*_1M) 1021 1021 { 1022 1022 char szBuf[5120]; -
trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp
r53036 r53045 138 138 /** The verification result. */ 139 139 int rc; 140 /** Used for shutting up errors after a while. */ 141 uint32_t volatile cErrorHits; 140 /** Used for shutting up load and error messages after a while so they don't 141 * flood the the log file and fill up the disk. */ 142 uint32_t volatile cHits; 142 143 /** The validation flags (for WinVerifyTrust retry). */ 143 144 uint32_t fFlags; … … 370 371 static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, PULONG pfAccess, PULONG pfProtect, 371 372 bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust, 372 bool *pfQuiet Failure);373 bool *pfQuiet); 373 374 static void supR3HardenedWinRegisterDllNotificationCallback(void); 374 375 static void supR3HardenedWinReInstallHooks(bool fFirst); … … 620 621 pEntry->rc = rc; 621 622 pEntry->fFlags = fFlags; 622 pEntry->c ErrorHits= 0;623 pEntry->cHits = 0; 623 624 pEntry->fWinVerifyTrust = fWinVerifyTrust; 624 625 pEntry->cbPath = pUniStr->Length; … … 1052 1053 bool fCallRealApi = false; 1053 1054 rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi, 1054 "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet Failure*/);1055 "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/); 1055 1056 NtClose(hFile); 1056 1057 } … … 1275 1276 1276 1277 static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, PULONG pfAccess, PULONG pfProtect, 1277 bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust, 1278 bool *pfQuietFailure) 1278 bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust, bool *pfQuiet) 1279 1279 { 1280 1280 *pfCallRealApi = false; 1281 if (pfQuiet Failure)1282 *pfQuiet Failure= false;1281 if (pfQuiet) 1282 *pfQuiet = false; 1283 1283 1284 1284 /* … … 1314 1314 if (pCacheHit) 1315 1315 { 1316 /* Do hit accounting and figure whether we need to be quiet or not. */ 1317 uint32_t cHits = ASMAtomicIncU32(&pCacheHit->cHits); 1318 bool const fQuiet = cHits >= 8 && !RT_IS_POWER_OF_TWO(cHits); 1319 if (pfQuiet) 1320 *pfQuiet = fQuiet; 1321 1316 1322 /* If we haven't done the WinVerifyTrust thing, do it if we can. */ 1317 1323 if ( !pCacheHit->fWinVerifyTrust … … 1342 1348 pszCaller, pCacheHit->rc, pCacheHit->wszPath)); 1343 1349 } 1344 else if ( pCacheHit->cErrorHits < 16)1350 else if (!fQuiet || !pCacheHit->fWinVerifyTrust) 1345 1351 SUP_DPRINTF(("supR3HardenedScreenImage/%s: cache hit (%Rrc) on %ls%s\n", 1346 1352 pszCaller, pCacheHit->rc, pCacheHit->wszPath, pCacheHit->fWinVerifyTrust ? "" : " [lacks WinVerifyTrust]")); … … 1353 1359 } 1354 1360 1355 uint32_t cErrorHits = ASMAtomicIncU32(&pCacheHit->cErrorHits); 1356 if ( cErrorHits < 8 1357 || RT_IS_POWER_OF_TWO(cErrorHits)) 1361 if (!fQuiet) 1358 1362 supR3HardenedError(VINF_SUCCESS, false, 1359 "supR3HardenedScreenImage/%s: cached rc=%Rrc fImage=%d fProtect=%#x fAccess=%#x cErrorHits=%u %ls\n", 1360 pszCaller, pCacheHit->rc, fImage, *pfProtect, *pfAccess, cErrorHits, uBuf.UniStr.Buffer); 1361 else if (pfQuietFailure) 1362 *pfQuietFailure = true; 1363 1363 "supR3HardenedScreenImage/%s: cached rc=%Rrc fImage=%d fProtect=%#x fAccess=%#x cHits=%u %ls\n", 1364 pszCaller, pCacheHit->rc, fImage, *pfProtect, *pfAccess, cHits, uBuf.UniStr.Buffer); 1364 1365 return STATUS_TRUST_FAILURE; 1365 1366 } … … 1610 1611 //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: scanning %ls\n", pwszName)); 1611 1612 supR3HardenedScreenImage(hFile, false, &fAccess, &fProtect, &fCallRealApi, "preload", false /*fAvoidWinVerifyTrust*/, 1612 NULL /*pfQuiet Failure*/);1613 NULL /*pfQuiet*/); 1613 1614 //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: done %ls\n", pwszName)); 1614 1615 … … 1648 1649 //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 1\n")); 1649 1650 NTSTATUS rcNt = supR3HardenedScreenImage(hFile, fImage, &fAccess, &fProtect, &fCallRealApi, 1650 "NtCreateSection", true /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet Failure*/);1651 "NtCreateSection", true /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/); 1651 1652 //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 2 rcNt=%#x fCallRealApi=%#x\n", rcNt, fCallRealApi)); 1652 1653 … … 1724 1725 { 1725 1726 DWORD dwSavedLastError = RtlGetLastWin32Error(); 1727 bool fQuiet = false; 1726 1728 NTSTATUS rcNt; 1727 1729 … … 1934 1936 ResolvedName.MaximumLength = ResolvedName.Length + sizeof(WCHAR); 1935 1937 1938 /** @todo need to cache the translation so we can get at fQuiet here! */ 1936 1939 SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: '%.*ls' -> '%.*ls' [rcNt=%#x]\n", 1937 1940 (unsigned)pName->Length / sizeof(WCHAR), pName->Buffer, … … 1982 1985 ULONG fProtect = 0; 1983 1986 bool fCallRealApi = false; 1984 bool fQuietFailure = false;1985 1987 rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi, 1986 "LdrLoadDll", false /*fAvoidWinVerifyTrust*/, &fQuiet Failure);1988 "LdrLoadDll", false /*fAvoidWinVerifyTrust*/, &fQuiet); 1987 1989 NtClose(hFile); 1988 1990 if (!NT_SUCCESS(rcNt)) 1989 1991 { 1990 if (!fQuiet Failure)1992 if (!fQuiet) 1991 1993 { 1992 1994 supR3HardenedError(VINF_SUCCESS, false, "supR3HardenedMonitor_LdrLoadDll: rejecting '%ls': rcNt=%#x\n", … … 2012 2014 * Screened successfully enough. Call the real thing. 2013 2015 */ 2014 SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: pName=%.*ls *pfFlags=%#x pwszSearchPath=%p:%ls [calling]\n", 2015 (unsigned)pName->Length / sizeof(WCHAR), pName->Buffer, pfFlags ? *pfFlags : UINT32_MAX, pwszSearchPath, 2016 !((uintptr_t)pwszSearchPath & 1) && (uintptr_t)pwszSearchPath >= 0x2000U ? pwszSearchPath : L"<flags>")); 2016 if (!fQuiet) 2017 SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: pName=%.*ls *pfFlags=%#x pwszSearchPath=%p:%ls [calling]\n", 2018 (unsigned)pName->Length / sizeof(WCHAR), pName->Buffer, pfFlags ? *pfFlags : UINT32_MAX, pwszSearchPath, 2019 !((uintptr_t)pwszSearchPath & 1) && (uintptr_t)pwszSearchPath >= 0x2000U ? pwszSearchPath : L"<flags>")); 2017 2020 RtlRestoreLastWin32Error(dwSavedLastError); 2018 2021 rcNt = g_pfnLdrLoadDllReal(pwszSearchPath, pfFlags, pName, phMod); … … 2025 2028 if (NT_SUCCESS(rcNt) && phMod) 2026 2029 SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: returns rcNt=%#x hMod=%p '%ls'\n", rcNt, *phMod, wszPath)); 2027 else 2030 else if (!NT_SUCCESS(rcNt) || !fQuiet) 2028 2031 SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: returns rcNt=%#x '%ls'\n", rcNt, wszPath)); 2029 2032
Note:
See TracChangeset
for help on using the changeset viewer.