Changeset 52947 in vbox for trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp
- Timestamp:
- Oct 5, 2014 4:48:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp
r52940 r52947 810 810 */ 811 811 uint8_t *pbBits; 812 rc = supHardNtLdrCacheEntryAllocBits(pImage->pCacheEntry, &pbBits, pThis->pErrInfo); 812 if (pThis->enmKind == SUPHARDNTVPKIND_CHILD_PURIFICATION) 813 rc = supHardNtLdrCacheEntryGetBits(pImage->pCacheEntry, &pbBits, pImage->uImageBase, NULL /*pfnGetImport*/, pThis, 814 pThis->pErrInfo); 815 else 816 rc = supHardNtLdrCacheEntryGetBits(pImage->pCacheEntry, &pbBits, pImage->uImageBase, supHardNtVpGetImport, pThis, 817 pThis->pErrInfo); 813 818 if (RT_FAILURE(rc)) 814 819 return rc; 815 if (pThis->enmKind == SUPHARDNTVPKIND_CHILD_PURIFICATION)816 rc = RTLdrGetBits(pImage->pCacheEntry->hLdrMod, pbBits, pImage->uImageBase, NULL /*pfnGetImport*/, pThis);817 else818 rc = RTLdrGetBits(pImage->pCacheEntry->hLdrMod, pbBits, pImage->uImageBase, supHardNtVpGetImport, pThis);819 if (RT_FAILURE(rc))820 return supHardNtVpSetInfo2(pThis, rc, "%s: RTLdrGetBits failed: %Rrc", pImage->pszName, rc);821 820 822 821 /* XP SP3 does not set ImageBase to load address. It fixes up the image on load time though. */ … … 862 861 return supHardNtVpSetInfo2(pThis, rc, "%s: Failed to find 'LdrInitializeThunk': %Rrc", pImage->pszName, rc); 863 862 aSkipAreas[cSkipAreas].uRva = (uint32_t)uValue; 864 aSkipAreas[cSkipAreas++].cb = 1 0;863 aSkipAreas[cSkipAreas++].cb = 14; 865 864 } 866 865 … … 1586 1585 1587 1586 /** 1588 * Allocates a image bits buffer for use with RTLdrGetBits.1587 * Allocates a image bits buffer and calls RTLdrGetBits on them. 1589 1588 * 1590 1589 * An assumption here is that there won't ever be concurrent use of the cache. … … 1595 1594 * @param pEntry The loader cache entry. 1596 1595 * @param ppbBits Where to return the pointer to the allocation. 1597 * @param pErRInfo Where to return extened error information. 1598 */ 1599 DECLHIDDEN(int) supHardNtLdrCacheEntryAllocBits(PSUPHNTLDRCACHEENTRY pEntry, uint8_t **ppbBits, PRTERRINFO pErrInfo) 1600 { 1596 * @param uBaseAddress The image base address, see RTLdrGetBits. 1597 * @param pfnGetImport Import getter, see RTLdrGetBits. 1598 * @param pvUser The user argument for @a pfnGetImport. 1599 * @param pErrInfo Where to return extened error information. 1600 */ 1601 DECLHIDDEN(int) supHardNtLdrCacheEntryGetBits(PSUPHNTLDRCACHEENTRY pEntry, uint8_t **ppbBits, 1602 RTLDRADDR uBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser, 1603 PRTERRINFO pErrInfo) 1604 { 1605 int rc; 1606 1607 /* 1608 * First time around we have to allocate memory before we can get the image bits. 1609 */ 1601 1610 if (!pEntry->pbBits) 1602 1611 { … … 1610 1619 return supHardNtVpSetInfo1(pErrInfo, VERR_SUP_VP_NO_MEMORY, "Failed to allocate %zu bytes for image %s.", 1611 1620 cbBits, pEntry->pszName); 1612 } 1613 1614 /** @todo Try cache RTLdrGetBits calls too. */ 1621 1622 pEntry->fValidBits = false; /* paranoia */ 1623 1624 rc = RTLdrGetBits(pEntry->hLdrMod, pEntry->pbBits, uBaseAddress, pfnGetImport, pvUser); 1625 if (RT_FAILURE(rc)) 1626 return supHardNtVpSetInfo1(pErrInfo, VERR_SUP_VP_NO_MEMORY, "RTLdrGetBits failed on image %s: %Rrc", 1627 pEntry->pszName, rc); 1628 pEntry->uImageBase = uBaseAddress; 1629 pEntry->fValidBits = pfnGetImport == NULL; 1630 1631 } 1632 /* 1633 * Cache hit? No? 1634 * 1635 * Note! We cannot currently cache image bits for images with imports as we 1636 * don't control the way they're resolved. Fortunately, NTDLL and 1637 * the VM process images all have no imports. 1638 */ 1639 else if ( !pEntry->fValidBits 1640 || pEntry->uImageBase != uBaseAddress 1641 || pfnGetImport) 1642 { 1643 pEntry->fValidBits = false; 1644 1645 rc = RTLdrGetBits(pEntry->hLdrMod, pEntry->pbBits, uBaseAddress, pfnGetImport, pvUser); 1646 if (RT_FAILURE(rc)) 1647 return supHardNtVpSetInfo1(pErrInfo, VERR_SUP_VP_NO_MEMORY, "RTLdrGetBits failed on image %s: %Rrc", 1648 pEntry->pszName, rc); 1649 pEntry->uImageBase = uBaseAddress; 1650 pEntry->fValidBits = pfnGetImport == NULL; 1651 } 1615 1652 1616 1653 *ppbBits = pEntry->pbBits; … … 1651 1688 } 1652 1689 1653 pEntry->pszName = NULL; 1654 pEntry->fVerified = false; 1690 pEntry->pszName = NULL; 1691 pEntry->fVerified = false; 1692 pEntry->fValidBits = false; 1693 pEntry->uImageBase = 0; 1655 1694 } 1656 1695 … … 1760 1799 * Fill in the cache entry. 1761 1800 */ 1762 pEntry->pszName = pszName; 1763 pEntry->hLdrMod = hLdrMod; 1764 pEntry->pNtViRdr = pNtViRdr; 1765 pEntry->hFile = hFile; 1766 pEntry->pbBits = NULL; 1767 pEntry->fVerified = false; 1801 pEntry->pszName = pszName; 1802 pEntry->hLdrMod = hLdrMod; 1803 pEntry->pNtViRdr = pNtViRdr; 1804 pEntry->hFile = hFile; 1805 pEntry->pbBits = NULL; 1806 pEntry->fVerified = false; 1807 pEntry->fValidBits = false; 1808 pEntry->uImageBase = ~(uintptr_t)0; 1768 1809 1769 1810 #ifdef IN_SUP_HARDENED_R3 … … 2042 2083 return supHardNtVpSetInfo2(pThis, VERR_SUP_VP_NO_NTDLL_MAPPING, 2043 2084 "The process has no NTDLL.DLL."); 2044 if (iKernel32 == UINT32_MAX && pThis->enmKind != SUPHARDNTVPKIND_CHILD_PURIFICATION)2085 if (iKernel32 == UINT32_MAX && pThis->enmKind == SUPHARDNTVPKIND_SELF_PURIFICATION) 2045 2086 return supHardNtVpSetInfo2(pThis, VERR_SUP_VP_NO_KERNEL32_MAPPING, 2046 2087 "The process has no KERNEL32.DLL.");
Note:
See TracChangeset
for help on using the changeset viewer.