Changeset 52529 in vbox for trunk/src/VBox/HostDrivers/Support/win
- Timestamp:
- Aug 29, 2014 3:03:07 PM (10 years ago)
- 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 3493 3493 RTErrInfoInit(&ErrInfo, szErr, sizeof(szErr)); 3494 3494 3495 rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_VERIFY_ONLY, &ErrInfo); 3495 rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), SUPHARDNTVPKIND_VERIFY_ONLY, 3496 NULL /*pcFixes*/, &ErrInfo); 3496 3497 if (RT_FAILURE(rc)) 3497 3498 RTLogWriteDebugger(szErr, strlen(szErr)); -
trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h
r52406 r52529 54 54 SUPHARDNTVPKIND_32BIT_HACK = 0x7fffffff 55 55 } SUPHARDNTVPKIND; 56 DECLHIDDEN(int) supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind, PRTERRINFO pErrInfo); 56 DECLHIDDEN(int) supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind, 57 uint32_t *pcFixes, PRTERRINFO pErrInfo); 57 58 58 59 DECLHIDDEN(bool) supHardViUniStrPathStartsWithUniStr(UNICODE_STRING const *pUniStrLeft, -
trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp
r52500 r52529 734 734 if (supHardViUtf16PathIsEqual(pwsz, "apphelp.dll")) 735 735 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 736 740 #ifdef VBOX_PERMIT_MORE 737 741 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 131 131 /** The result. */ 132 132 int rcResult; 133 /** Number of fixes we've done. 134 * Only applicable in the purification modes. */ 135 uint32_t cFixes; 133 136 /** Number of images in aImages. */ 134 137 uint32_t cImages; … … 141 144 * more so we can get the image name of the first unwanted DLL. */ 142 145 SUPHNTVPIMAGE aImages[1 + 6 + 1 146 #ifdef VBOX_PERMIT_VERIFIER_DLL 147 + 1 148 #endif 143 149 #ifdef VBOX_PERMIT_MORE 144 150 + 5 … … 175 181 "apphelp.dll", 176 182 "apisetschema.dll", 183 #ifdef VBOX_PERMIT_VERIFIER_DLL 184 "verifier.dll", 185 #endif 177 186 #ifdef VBOX_PERMIT_MORE 178 187 # define VBOX_PERMIT_MORE_FIRST_IDX 5 … … 351 360 rcNt = rcNt2; 352 361 } 362 pThis->cFixes++; 353 363 return rcNt; 354 364 } … … 1220 1230 if (NT_SUCCESS(rcNt)) 1221 1231 return VINF_OBJECT_DESTROYED; 1232 pThis->cFixes++; 1222 1233 SUP_DPRINTF(("supHardNtVpScanVirtualMemory: NtUnmapViewOfSection(,%p) failed: %#x\n", pMemInfo->AllocationBase, rcNt)); 1223 1234 } … … 1362 1373 uintptr_t cbAdvance = 0; 1363 1374 uintptr_t uPtrWhere = 0; 1375 #ifdef VBOX_PERMIT_VERIFIER_DLL 1376 for (uint32_t i = 0; i < 10240; i++) 1377 #else 1364 1378 for (uint32_t i = 0; i < 1024; i++) 1379 #endif 1365 1380 { 1366 1381 SIZE_T cbActual = 0; … … 1511 1526 "Unknown executable memory type %#x at %p/%p LB %#zx", 1512 1527 MemInfo.Type, MemInfo.AllocationBase, MemInfo.BaseAddress, MemInfo.RegionSize); 1528 pThis->cFixes++; 1513 1529 } 1514 1530 else … … 2057 2073 * @param enmKind The kind of process verification to perform. 2058 2074 * @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 */ 2078 DECLHIDDEN(int) supHardenedWinVerifyProcess(HANDLE hProcess, HANDLE hThread, SUPHARDNTVPKIND enmKind, 2079 uint32_t *pcFixes, PRTERRINFO pErrInfo) 2080 { 2081 if (pcFixes) 2082 *pcFixes = 0; 2083 2062 2084 /* 2063 2085 * Some basic checks regarding threads and debuggers. We don't need … … 2095 2117 rc = supHardNtVpCheckDlls(pThis, hProcess); 2096 2118 2119 if (pcFixes) 2120 *pcFixes = pThis->cFixes; 2121 2097 2122 /* 2098 2123 * Clean up the state. -
trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp
r52528 r52529 2414 2414 RTErrInfoInitStatic(&g_ErrInfoStatic); 2415 2415 int rc = supHardenedWinVerifyProcess(NtCurrentProcess(), NtCurrentThread(), 2416 SUPHARDNTVPKIND_VERIFY_ONLY, &g_ErrInfoStatic.Core);2416 SUPHARDNTVPKIND_VERIFY_ONLY, NULL /*pcFixes*/, &g_ErrInfoStatic.Core); 2417 2417 if (RT_FAILURE(rc)) 2418 2418 supR3HardenedFatalMsg("supR3HardenedWinVerifyProcess", kSupInitOp_Integrity, rc, … … 3376 3376 rc = supR3HardNtPuChSanitizePeb(&This); 3377 3377 if (RT_SUCCESS(rc)) 3378 rc = supHardenedWinVerifyProcess(hProcess, hThread, SUPHARDNTVPKIND_CHILD_PURIFICATION, pErrInfo);3378 rc = supHardenedWinVerifyProcess(hProcess, hThread, SUPHARDNTVPKIND_CHILD_PURIFICATION, NULL /*pcFixes*/, pErrInfo); 3379 3379 3380 3380 return rc; … … 3928 3928 * We have to resort to kludge doing yield and sleep fudging for a 3929 3929 * 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. 3931 3934 */ 3932 uint32_t cSleeps= 0;3933 DWORD dwStart = GetTickCount();3935 uint32_t iLoop = 0; 3936 uint32_t cFixes; 3934 3937 do 3935 3938 { 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); 3946 3959 3947 3960 /*
Note:
See TracChangeset
for help on using the changeset viewer.