VirtualBox

Changeset 53045 in vbox for trunk


Ignore:
Timestamp:
Oct 13, 2014 2:55:00 PM (10 years ago)
Author:
vboxsync
Message:

SUP: Reduce LdrLoadDll logging. Still one log statement needing suppressing...

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r53004 r53045  
    10181018#ifdef RT_OS_WINDOWS
    10191019    if (   g_hStartupLog != NULL
    1020         && g_cbStartupLog < 128*_1M)
     1020        && g_cbStartupLog < 16*_1M)
    10211021    {
    10221022        char szBuf[5120];
  • trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp

    r53036 r53045  
    138138    /** The verification result. */
    139139    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;
    142143    /** The validation flags (for WinVerifyTrust retry). */
    143144    uint32_t                fFlags;
     
    370371static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, PULONG pfAccess, PULONG pfProtect,
    371372                                         bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust,
    372                                          bool *pfQuietFailure);
     373                                         bool *pfQuiet);
    373374static void     supR3HardenedWinRegisterDllNotificationCallback(void);
    374375static void     supR3HardenedWinReInstallHooks(bool fFirst);
     
    620621        pEntry->rc              = rc;
    621622        pEntry->fFlags          = fFlags;
    622         pEntry->cErrorHits      = 0;
     623        pEntry->cHits           = 0;
    623624        pEntry->fWinVerifyTrust = fWinVerifyTrust;
    624625        pEntry->cbPath          = pUniStr->Length;
     
    10521053                    bool  fCallRealApi = false;
    10531054                    rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi,
    1054                                                     "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuietFailure*/);
     1055                                                    "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
    10551056                    NtClose(hFile);
    10561057                }
     
    12751276
    12761277static 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)
    12791279{
    12801280    *pfCallRealApi = false;
    1281     if (pfQuietFailure)
    1282         *pfQuietFailure = false;
     1281    if (pfQuiet)
     1282        *pfQuiet = false;
    12831283
    12841284    /*
     
    13141314    if (pCacheHit)
    13151315    {
     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
    13161322        /* If we haven't done the WinVerifyTrust thing, do it if we can. */
    13171323        if (   !pCacheHit->fWinVerifyTrust
     
    13421348                             pszCaller, pCacheHit->rc, pCacheHit->wszPath));
    13431349        }
    1344         else if (pCacheHit->cErrorHits < 16)
     1350        else if (!fQuiet || !pCacheHit->fWinVerifyTrust)
    13451351            SUP_DPRINTF(("supR3HardenedScreenImage/%s: cache hit (%Rrc) on %ls%s\n",
    13461352                         pszCaller, pCacheHit->rc, pCacheHit->wszPath, pCacheHit->fWinVerifyTrust ? "" : " [lacks WinVerifyTrust]"));
     
    13531359        }
    13541360
    1355         uint32_t cErrorHits = ASMAtomicIncU32(&pCacheHit->cErrorHits);
    1356         if (   cErrorHits < 8
    1357             || RT_IS_POWER_OF_TWO(cErrorHits))
     1361        if (!fQuiet)
    13581362            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);
    13641365        return STATUS_TRUST_FAILURE;
    13651366    }
     
    16101611    //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: scanning %ls\n", pwszName));
    16111612    supR3HardenedScreenImage(hFile, false, &fAccess, &fProtect, &fCallRealApi, "preload", false /*fAvoidWinVerifyTrust*/,
    1612                              NULL /*pfQuietFailure*/);
     1613                             NULL /*pfQuiet*/);
    16131614    //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: done %ls\n", pwszName));
    16141615
     
    16481649            //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 1\n"));
    16491650            NTSTATUS rcNt = supR3HardenedScreenImage(hFile, fImage, &fAccess, &fProtect, &fCallRealApi,
    1650                                                      "NtCreateSection", true /*fAvoidWinVerifyTrust*/, NULL /*pfQuietFailure*/);
     1651                                                     "NtCreateSection", true /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
    16511652            //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 2 rcNt=%#x fCallRealApi=%#x\n", rcNt, fCallRealApi));
    16521653
     
    17241725{
    17251726    DWORD    dwSavedLastError = RtlGetLastWin32Error();
     1727    bool     fQuiet = false;
    17261728    NTSTATUS rcNt;
    17271729
     
    19341936        ResolvedName.MaximumLength = ResolvedName.Length + sizeof(WCHAR);
    19351937
     1938/** @todo need to cache the translation so we can get at fQuiet here! */
    19361939        SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: '%.*ls' -> '%.*ls' [rcNt=%#x]\n",
    19371940                     (unsigned)pName->Length / sizeof(WCHAR), pName->Buffer,
     
    19821985            ULONG fProtect = 0;
    19831986            bool  fCallRealApi = false;
    1984             bool  fQuietFailure = false;
    19851987            rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi,
    1986                                             "LdrLoadDll", false /*fAvoidWinVerifyTrust*/, &fQuietFailure);
     1988                                            "LdrLoadDll", false /*fAvoidWinVerifyTrust*/, &fQuiet);
    19871989            NtClose(hFile);
    19881990            if (!NT_SUCCESS(rcNt))
    19891991            {
    1990                 if (!fQuietFailure)
     1992                if (!fQuiet)
    19911993                {
    19921994                    supR3HardenedError(VINF_SUCCESS, false, "supR3HardenedMonitor_LdrLoadDll: rejecting '%ls': rcNt=%#x\n",
     
    20122014     * Screened successfully enough.  Call the real thing.
    20132015     */
    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>"));
    20172020    RtlRestoreLastWin32Error(dwSavedLastError);
    20182021    rcNt = g_pfnLdrLoadDllReal(pwszSearchPath, pfFlags, pName, phMod);
     
    20252028    if (NT_SUCCESS(rcNt) && phMod)
    20262029        SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: returns rcNt=%#x hMod=%p '%ls'\n", rcNt, *phMod, wszPath));
    2027     else
     2030    else if (!NT_SUCCESS(rcNt) || !fQuiet)
    20282031        SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: returns rcNt=%#x '%ls'\n", rcNt, wszPath));
    20292032
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette