Changeset 73375 in vbox
- Timestamp:
- Jul 27, 2018 7:59:25 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/dbg.h
r73359 r73375 1089 1089 1090 1090 /** 1091 * Image size when mapped if segments are mapped adjacently.1092 *1093 * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and1094 * NE and such it's a bit odder and the answer may not make much sense for them.1095 *1096 * @returns Image mapped size.1097 * RTUINTPTR_MAX is returned if the handle is invalid.1098 *1099 * @param hDbgMod The module handle.1100 */1101 RTDECL(RTUINTPTR) RTDbgModImageSize(RTDBGMOD hDbgMod);1102 1103 /**1104 1091 * Gets the module tag value if any. 1105 1092 * … … 1124 1111 */ 1125 1112 RTDECL(int) RTDbgModSetTag(RTDBGMOD hDbgMod, uint64_t uTag); 1113 1114 1115 /** 1116 * Image size when mapped if segments are mapped adjacently. 1117 * 1118 * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and 1119 * NE and such it's a bit odder and the answer may not make much sense for them. 1120 * 1121 * @returns Image mapped size. 1122 * RTUINTPTR_MAX is returned if the handle is invalid. 1123 * 1124 * @param hDbgMod The module handle. 1125 */ 1126 RTDECL(RTUINTPTR) RTDbgModImageSize(RTDBGMOD hDbgMod); 1127 1128 /** 1129 * Gets the image format. 1130 * 1131 * @returns Image format. 1132 * @retval RTLDRFMT_INVALID if the handle is invalid or if the format isn't known. 1133 * @param hDbgMod The debug module handle. 1134 * @sa RTLdrGetFormat 1135 */ 1136 RTDECL(RTLDRFMT) RTDbgModImageGetFormat(RTDBGMOD hDbgMod); 1137 1138 /** 1139 * Gets the image architecture. 1140 * 1141 * @returns Image architecture. 1142 * @retval RTLDRARCH_INVALID if the handle is invalid. 1143 * @retval RTLDRARCH_WHATEVER if unknown. 1144 * @param hDbgMod The debug module handle. 1145 * @sa RTLdrGetArch 1146 */ 1147 RTDECL(RTLDRARCH) RTDbgModImageGetArch(RTDBGMOD hDbgMod); 1148 1149 /** 1150 * Generic method for querying image properties. 1151 * 1152 * @returns IPRT status code. 1153 * @retval VERR_NOT_SUPPORTED if the property query isn't supported (either all 1154 * or that specific property). The caller must handle this result. 1155 * @retval VERR_NOT_FOUND the property was not found in the module. The caller 1156 * must also normally deal with this. 1157 * @retval VERR_INVALID_FUNCTION if the function value is wrong. 1158 * @retval VERR_INVALID_PARAMETER if the fixed buffer size is wrong. Correct 1159 * size in @a *pcbRet. 1160 * @retval VERR_BUFFER_OVERFLOW if the function doesn't have a fixed size 1161 * buffer and the buffer isn't big enough. Correct size in @a *pcbRet. 1162 * @retval VERR_INVALID_HANDLE if the handle is invalid. 1163 * 1164 * @param hDbgMod The debug module handle. 1165 * @param enmProp The property to query. 1166 * @param pvBuf Pointer to the input / output buffer. In most cases 1167 * it's only used for returning data. 1168 * @param cbBuf The size of the buffer. 1169 * @param pcbRet Where to return the amount of data returned. On 1170 * buffer size errors, this is set to the correct size. 1171 * Optional. 1172 * @sa RTLdrQueryPropEx 1173 */ 1174 RTDECL(int) RTDbgModImageQueryProp(RTDBGMOD hDbgMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet); 1126 1175 1127 1176 -
trunk/include/iprt/ldr.h
r73150 r73375 1094 1094 * Returns zero terminated string. */ 1095 1095 RTLDRPROP_INTERNAL_NAME, 1096 /** The raw unwind info if available. 1097 * For PE this means IMAGE_DIRECTORY_ENTRY_EXCEPTION. Not implemented any 1098 * others yet. */ 1099 RTLDRPROP_UNWIND_INFO, 1096 1100 1097 1101 /** End of valid properties. */ -
trunk/include/iprt/mangling.h
r73334 r73375 721 721 # define RTDbgModCreateFromMachOImage RT_MANGLER(RTDbgModCreateFromMachOImage) 722 722 # define RTDbgModGetTag RT_MANGLER(RTDbgModGetTag) 723 # define RTDbgModImageGetArch RT_MANGLER(RTDbgModImageGetArch) 724 # define RTDbgModImageGetFormat RT_MANGLER(RTDbgModImageGetFormat) 723 725 # define RTDbgModImageSize RT_MANGLER(RTDbgModImageSize) 726 # define RTDbgModImageQueryProp RT_MANGLER(RTDbgModImageQueryProp) 724 727 # define RTDbgModIsDeferred RT_MANGLER(RTDbgModIsDeferred) 725 728 # define RTDbgModIsExports RT_MANGLER(RTDbgModIsExports) -
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r73365 r73375 746 746 RTUUID Uuid; 747 747 PRTUUID pUuid = &Uuid; 748 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, RTLDRPROP_UUID, &Uuid, sizeof(Uuid) );748 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, RTLDRPROP_UUID, &Uuid, sizeof(Uuid), NULL); 749 749 if (RT_FAILURE(rc)) 750 750 pUuid = NULL; … … 1269 1269 { 1270 1270 RTUUID UuidOpened; 1271 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, RTLDRPROP_UUID, &UuidOpened, sizeof(UuidOpened) );1271 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, RTLDRPROP_UUID, &UuidOpened, sizeof(UuidOpened), NULL); 1272 1272 if (RT_SUCCESS(rc)) 1273 1273 { … … 1648 1648 1649 1649 1650 RTDECL(uint64_t) RTDbgModGetTag(RTDBGMOD hDbgMod) 1651 { 1652 PRTDBGMODINT pDbgMod = hDbgMod; 1653 RTDBGMOD_VALID_RETURN_RC(pDbgMod, 0); 1654 return pDbgMod->uTag; 1655 } 1656 RT_EXPORT_SYMBOL(RTDbgModGetTag); 1657 1658 1659 RTDECL(int) RTDbgModSetTag(RTDBGMOD hDbgMod, uint64_t uTag) 1660 { 1661 PRTDBGMODINT pDbgMod = hDbgMod; 1662 RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE); 1663 RTDBGMOD_LOCK(pDbgMod); 1664 1665 pDbgMod->uTag = uTag; 1666 1667 RTDBGMOD_UNLOCK(pDbgMod); 1668 return VINF_SUCCESS; 1669 } 1670 RT_EXPORT_SYMBOL(RTDbgModSetTag); 1671 1672 1650 1673 RTDECL(RTUINTPTR) RTDbgModImageSize(RTDBGMOD hDbgMod) 1651 1674 { … … 1662 1685 1663 1686 1664 RTDECL(uint64_t) RTDbgModGetTag(RTDBGMOD hDbgMod) 1665 { 1666 PRTDBGMODINT pDbgMod = hDbgMod; 1667 RTDBGMOD_VALID_RETURN_RC(pDbgMod, 0); 1668 return pDbgMod->uTag; 1669 } 1670 RT_EXPORT_SYMBOL(RTDbgModGetTag); 1671 1672 1673 RTDECL(int) RTDbgModSetTag(RTDBGMOD hDbgMod, uint64_t uTag) 1687 RTDECL(RTLDRFMT) RTDbgModImageGetFormat(RTDBGMOD hDbgMod) 1688 { 1689 PRTDBGMODINT pDbgMod = hDbgMod; 1690 RTDBGMOD_VALID_RETURN_RC(pDbgMod, RTLDRFMT_INVALID); 1691 RTDBGMOD_LOCK(pDbgMod); 1692 1693 RTLDRFMT enmFmt; 1694 if ( pDbgMod->pImgVt 1695 && pDbgMod->pImgVt->pfnGetFormat) 1696 enmFmt = pDbgMod->pImgVt->pfnGetFormat(pDbgMod); 1697 else 1698 enmFmt = RTLDRFMT_INVALID; 1699 1700 RTDBGMOD_UNLOCK(pDbgMod); 1701 return enmFmt; 1702 } 1703 RT_EXPORT_SYMBOL(RTDbgModImageGetFormat); 1704 1705 1706 RTDECL(RTLDRARCH) RTDbgModImageGetArch(RTDBGMOD hDbgMod) 1707 { 1708 PRTDBGMODINT pDbgMod = hDbgMod; 1709 RTDBGMOD_VALID_RETURN_RC(pDbgMod, RTLDRARCH_INVALID); 1710 RTDBGMOD_LOCK(pDbgMod); 1711 1712 RTLDRARCH enmArch; 1713 if ( pDbgMod->pImgVt 1714 && pDbgMod->pImgVt->pfnGetArch) 1715 enmArch = pDbgMod->pImgVt->pfnGetArch(pDbgMod); 1716 else 1717 enmArch = RTLDRARCH_WHATEVER; 1718 1719 RTDBGMOD_UNLOCK(pDbgMod); 1720 return enmArch; 1721 } 1722 RT_EXPORT_SYMBOL(RTDbgModImageGetArch); 1723 1724 1725 RTDECL(int) RTDbgModImageQueryProp(RTDBGMOD hDbgMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet) 1674 1726 { 1675 1727 PRTDBGMODINT pDbgMod = hDbgMod; 1676 1728 RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE); 1729 AssertPtrNullReturn(pcbRet, VERR_INVALID_POINTER); 1677 1730 RTDBGMOD_LOCK(pDbgMod); 1678 1731 1679 pDbgMod->uTag = uTag; 1732 int rc; 1733 if ( pDbgMod->pImgVt 1734 && pDbgMod->pImgVt->pfnQueryProp) 1735 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, enmProp, pvBuf, cbBuf, pcbRet); 1736 else 1737 rc = VERR_NOT_FOUND; 1680 1738 1681 1739 RTDBGMOD_UNLOCK(pDbgMod); 1682 return VINF_SUCCESS;1683 } 1684 RT_EXPORT_SYMBOL(RTDbgMod SetTag);1740 return rc; 1741 } 1742 RT_EXPORT_SYMBOL(RTDbgModImageQueryProp); 1685 1743 1686 1744 -
trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp
r73359 r73375 445 445 446 446 /** @interface_method_impl{RTDBGMODVTIMG,pfnQueryProp} */ 447 static DECLCALLBACK(int ) rtDbgModDeferredImg_QueryProp(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf) 448 { 449 int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/); 450 if (RT_SUCCESS(rc)) 451 rc = pMod->pImgVt->pfnQueryProp(pMod, enmProp, pvBuf, cbBuf); 447 static DECLCALLBACK(int) 448 rtDbgModDeferredImg_QueryProp(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet) 449 { 450 int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/); 451 if (RT_SUCCESS(rc)) 452 rc = pMod->pImgVt->pfnQueryProp(pMod, enmProp, pvBuf, cbBuf, pcbRet); 452 453 return rc; 453 454 } -
trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
r69111 r73375 62 62 63 63 /** @interface_method_impl{RTDBGMODVTIMG,pfnQueryProp} */ 64 static DECLCALLBACK(int) rtDbgModLdr_QueryProp(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf )65 { 66 PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv; 67 return RTLdrQueryProp (pThis->hLdrMod, enmProp, pvBuf, cbBuf);64 static DECLCALLBACK(int) rtDbgModLdr_QueryProp(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet) 65 { 66 PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv; 67 return RTLdrQueryPropEx(pThis->hLdrMod, enmProp, NULL /*pvBits*/, pvBuf, cbBuf, pcbRet); 68 68 } 69 69 -
trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp
r73150 r73375 635 635 break; 636 636 case RTLDRPROP_INTERNAL_NAME: 637 case RTLDRPROP_UNWIND_INFO: 637 638 *pcbRet = 0; 638 639 break; -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r73150 r73375 122 122 /** The security directory entry. */ 123 123 IMAGE_DATA_DIRECTORY SecurityDir; 124 /** The exception data directory entry. */ 125 IMAGE_DATA_DIRECTORY ExceptionDir; 124 126 125 127 /** Offset of the first PKCS \#7 SignedData signature if present. */ … … 1917 1919 1918 1920 /** 1919 * Worker for rtLdrPE_QueryProp that retriev s the internal module name.1921 * Worker for rtLdrPE_QueryProp that retrieves the internal module name. 1920 1922 * 1921 1923 * @returns IPRT status code. If VERR_BUFFER_OVERFLOW, pcbBuf is required size. … … 1944 1946 } 1945 1947 1948 return rc; 1949 } 1950 1951 1952 /** 1953 * Worker for rtLdrPE_QueryProp that retrieves unwind information. 1954 * 1955 * @returns IPRT status code. If VERR_BUFFER_OVERFLOW, pcbBuf is required size. 1956 * @param pThis The PE module instance. 1957 * @param pvBits Image bits if the caller had them available, NULL if 1958 * not. Saves a couple of file accesses. 1959 * @param pvBuf The output buffer. 1960 * @param cbBuf The buffer size. 1961 * @param pcbRet Where to return the number of bytes we've returned 1962 * (or in case of VERR_BUFFER_OVERFLOW would have). 1963 */ 1964 static int rtLdrPE_QueryUnwindInfo(PRTLDRMODPE pThis, void const *pvBits, void *pvBuf, size_t cbBuf, size_t *pcbRet) 1965 { 1966 int rc; 1967 uint32_t const cbSrc = pThis->ExceptionDir.Size; 1968 if ( cbSrc > 0 1969 && pThis->ExceptionDir.VirtualAddress > 0) 1970 { 1971 *pcbRet = cbSrc; 1972 if (cbBuf >= cbSrc) 1973 { 1974 void const *pvSrc = NULL; 1975 rc = rtldrPEReadPartByRva(pThis, pvBits, pThis->ExceptionDir.VirtualAddress, cbSrc, &pvSrc); 1976 if (RT_SUCCESS(rc)) 1977 { 1978 memcpy(pvBuf, pvSrc, cbSrc); 1979 rtldrPEFreePart(pThis, pvBits, pvSrc); 1980 } 1981 } 1982 else 1983 rc = VERR_BUFFER_OVERFLOW; 1984 } 1985 else 1986 { 1987 *pcbRet = 0; 1988 rc = VERR_NOT_FOUND; 1989 } 1946 1990 return rc; 1947 1991 } … … 2017 2061 case RTLDRPROP_INTERNAL_NAME: 2018 2062 return rtLdrPE_QueryInternalName(pModPe, pvBits, pvBuf, cbBuf, pcbRet); 2063 2064 case RTLDRPROP_UNWIND_INFO: 2065 return rtLdrPE_QueryUnwindInfo(pModPe, pvBits, pvBuf, cbBuf, pcbRet); 2019 2066 2020 2067 default: … … 4033 4080 pModPe->DebugDir = OptHdr.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]; 4034 4081 pModPe->SecurityDir = OptHdr.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; 4082 pModPe->ExceptionDir = OptHdr.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION]; 4035 4083 pModPe->fDllCharacteristics = OptHdr.DllCharacteristics; 4036 4084 -
trunk/src/VBox/Runtime/include/internal/dbgmod.h
r69111 r73375 236 236 * @param pvBuf Pointer to the return buffer. 237 237 * @param cbBuf The size of the return buffer. 238 * @sa RTLdrQueryProp 239 */ 240 DECLCALLBACKMEMBER(int, pfnQueryProp)(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf); 238 * @param pcbRet How many bytes was actually returned. In the 239 * case of VERR_BUFFER_OVERFLOW this will contain 240 * the required buffer size. Optional. 241 * @sa RTLdrQueryPropEx 242 */ 243 DECLCALLBACKMEMBER(int, pfnQueryProp)(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet); 241 244 242 245 /** For catching initialization errors (RTDBGMODVTIMG_MAGIC). */
Note:
See TracChangeset
for help on using the changeset viewer.