VirtualBox

Ignore:
Timestamp:
Aug 29, 2014 3:03:07 PM (10 years ago)
Author:
vboxsync
Message:

Extended avast cleanup kludge. Added build time option of supporting the application verifier / paged heaps.

Location:
trunk/src/VBox/HostDrivers/Support/win
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r52425 r52529  
    34933493        RTErrInfoInit(&ErrInfo, szErr, sizeof(szErr));
    34943494
    3495         rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_VERIFY_ONLY, &ErrInfo);
     3495        rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_VERIFY_ONLY,
     3496                                         NULL /*pcFixes*/, &ErrInfo);
    34963497        if (RT_FAILURE(rc))
    34973498            RTLogWriteDebugger(szErr, strlen(szErr));
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h

    r52406 r52529  
    5454    SUPHARDNTVPKIND_32BIT_HACK = 0x7fffffff
    5555} SUPHARDNTVPKIND;
    56 DECLHIDDEN(int)     supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind, PRTERRINFO pErrInfo);
     56DECLHIDDEN(int)     supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind,
     57                                                uint32_t *pcFixes, PRTERRINFO pErrInfo);
    5758
    5859DECLHIDDEN(bool)    supHardViUniStrPathStartsWithUniStr(UNICODE_STRING const *pUniStrLeft,
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r52500 r52529  
    734734        if (supHardViUtf16PathIsEqual(pwsz, "apphelp.dll"))
    735735            return uNtVer < SUP_MAKE_NT_VER_SIMPLE(6, 4) ? VINF_LDRVI_NOT_SIGNED : rc;
     736#ifdef VBOX_PERMIT_VERIFIER_DLL
     737        if (supHardViUtf16PathIsEqual(pwsz, "verifier.dll"))
     738            return uNtVer < SUP_NT_VER_W81 ? VINF_LDRVI_NOT_SIGNED : rc;
     739#endif
    736740#ifdef VBOX_PERMIT_MORE
    737741        if (uNtVer >= SUP_NT_VER_W70) /* hard limit: user32.dll is unwanted prior to w7. */
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp

    r52523 r52529  
    131131    /** The result. */
    132132    int                     rcResult;
     133    /** Number of fixes we've done.
     134     * Only applicable in the purification modes.  */
     135    uint32_t                cFixes;
    133136    /** Number of images in aImages. */
    134137    uint32_t                cImages;
     
    141144     * more so we can get the image name of the first unwanted DLL. */
    142145    SUPHNTVPIMAGE           aImages[1 + 6 + 1
     146#ifdef VBOX_PERMIT_VERIFIER_DLL
     147                                    + 1
     148#endif
    143149#ifdef VBOX_PERMIT_MORE
    144150                                    + 5
     
    175181    "apphelp.dll",
    176182    "apisetschema.dll",
     183#ifdef VBOX_PERMIT_VERIFIER_DLL
     184    "verifier.dll",
     185#endif
    177186#ifdef VBOX_PERMIT_MORE
    178187# define VBOX_PERMIT_MORE_FIRST_IDX 5
     
    351360            rcNt = rcNt2;
    352361    }
     362    pThis->cFixes++;
    353363    return rcNt;
    354364}
     
    12201230            if (NT_SUCCESS(rcNt))
    12211231                return VINF_OBJECT_DESTROYED;
     1232            pThis->cFixes++;
    12221233            SUP_DPRINTF(("supHardNtVpScanVirtualMemory: NtUnmapViewOfSection(,%p) failed: %#x\n", pMemInfo->AllocationBase, rcNt));
    12231234        }
     
    13621373    uintptr_t   cbAdvance = 0;
    13631374    uintptr_t   uPtrWhere = 0;
     1375#ifdef VBOX_PERMIT_VERIFIER_DLL
     1376    for (uint32_t i = 0; i < 10240; i++)
     1377#else
    13641378    for (uint32_t i = 0; i < 1024; i++)
     1379#endif
    13651380    {
    13661381        SIZE_T                      cbActual = 0;
     
    15111526                                        "Unknown executable memory type %#x at %p/%p LB %#zx",
    15121527                                        MemInfo.Type, MemInfo.AllocationBase, MemInfo.BaseAddress, MemInfo.RegionSize);
     1528                pThis->cFixes++;
    15131529            }
    15141530            else
     
    20572073 * @param   enmKind             The kind of process verification to perform.
    20582074 * @param   pErrInfo            Pointer to error info structure. Optional.
    2059  */
    2060 DECLHIDDEN(int) supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind, PRTERRINFO pErrInfo)
    2061 {
     2075 * @param   pcFixes             Where to return the number of fixes made during
     2076 *                              purification.  Optional.
     2077 */
     2078DECLHIDDEN(int) supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind,
     2079                                            uint32_t *pcFixes, PRTERRINFO pErrInfo)
     2080{
     2081    if (pcFixes)
     2082        *pcFixes = 0;
     2083
    20622084    /*
    20632085     * Some basic checks regarding threads and debuggers. We don't need
     
    20952117                rc = supHardNtVpCheckDlls(pThis, hProcess);
    20962118
     2119            if (pcFixes)
     2120                *pcFixes = pThis->cFixes;
     2121
    20972122            /*
    20982123             * Clean up the state.
  • trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp

    r52528 r52529  
    24142414    RTErrInfoInitStatic(&g_ErrInfoStatic);
    24152415    int rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(),
    2416                                          SUPHARDNTVPKIND_VERIFY_ONLY, &g_ErrInfoStatic.Core);
     2416                                         SUPHARDNTVPKIND_VERIFY_ONLY, NULL /*pcFixes*/, &g_ErrInfoStatic.Core);
    24172417    if (RT_FAILURE(rc))
    24182418        supR3HardenedFatalMsg("supR3HardenedWinVerifyProcess", kSupInitOp_Integrity, rc,
     
    33763376        rc = supR3HardNtPuChSanitizePeb(&This);
    33773377    if (RT_SUCCESS(rc))
    3378         rc = supHardenedWinVerifyProcess(hProcess, hThread, SUPHARDNTVPKIND_CHILD_PURIFICATION, pErrInfo);
     3378        rc = supHardenedWinVerifyProcess(hProcess, hThread, SUPHARDNTVPKIND_CHILD_PURIFICATION, NULL /*pcFixes*/, pErrInfo);
    33793379
    33803380    return rc;
     
    39283928         * We have to resort to kludge doing yield and sleep fudging for a
    39293929         * number of milliseconds and schedulings before we can hope that avast
    3930          * and similar products have done what they need to do.  Pretty fragile...
     3930         * and similar products have done what they need to do.  If we do any
     3931         * fixes, we wait for a while again and redo it until we're clean.
     3932         *
     3933         * This is unfortunately kind of fragile.
    39313934         */
    3932         uint32_t    cSleeps = 0;
    3933         DWORD       dwStart = GetTickCount();
     3935        uint32_t iLoop = 0;
     3936        uint32_t cFixes;
    39343937        do
    39353938        {
    3936             NtYieldExecution();
    3937             LARGE_INTEGER Time;
    3938             Time.QuadPart = -8000000 / 100; /* 8ms in 100ns units, relative time. */
    3939             NtDelayExecution(FALSE, &Time);
    3940             cSleeps++;
    3941         } while (   GetTickCount() - dwStart <= 80
    3942                  || cSleeps < 8);
    3943         SUP_DPRINTF(("supR3HardenedWinInit: Startup delay kludge #2: %u ms, %u sleeps\n", GetTickCount() - dwStart, cSleeps));
    3944 
    3945         supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_SELF_PURIFICATION, NULL);
     3939            uint32_t    cSleeps = 0;
     3940            DWORD       dwStart = GetTickCount();
     3941            do
     3942            {
     3943                NtYieldExecution();
     3944                LARGE_INTEGER Time;
     3945                Time.QuadPart = -8000000 / 100; /* 8ms in 100ns units, relative time. */
     3946                NtDelayExecution(FALSE, &Time);
     3947                cSleeps++;
     3948            } while (   GetTickCount() - dwStart <= 80
     3949                     || cSleeps < 8);
     3950            SUP_DPRINTF(("supR3HardenedWinInit: Startup delay kludge #2/%u: %u ms, %u sleeps\n",
     3951                         iLoop, GetTickCount() - dwStart, cSleeps));
     3952
     3953            cFixes = 0;
     3954            rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_SELF_PURIFICATION,
     3955                                             &cFixes, NULL /*pErrInfo*/);
     3956        } while (   RT_SUCCESS(rc)
     3957                 && cFixes > 0
     3958                 && ++iLoop < 8);
    39463959
    39473960        /*
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