Changeset 73387 in vbox for trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
- Timestamp:
- Jul 27, 2018 3:20:00 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124005
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r73375 r73387 472 472 RTMemFree((void *)pvMem); 473 473 } 474 475 476 /** 477 * Reads a section of a PE image given by RVA + size. 478 * 479 * @returns IPRT status code. 480 * @param pThis Pointer to the PE loader module structure. 481 * @param pvBits Read only bits if available. NULL if not. 482 * @param uRva The RVA to read at. 483 * @param cbMem The number of bytes to read. 484 * @param pvDst The destination buffer. 485 */ 486 static int rtldrPEReadPartByRvaInfoBuf(PRTLDRMODPE pThis, const void *pvBits, uint32_t uRva, uint32_t cbMem, void *pvDst) 487 { 488 /** @todo consider optimizing this. */ 489 const void *pvSrc = NULL; 490 int rc = rtldrPEReadPartByRva(pThis, pvBits, uRva, cbMem, &pvSrc); 491 if (RT_SUCCESS(rc)) 492 { 493 memcpy(pvDst, pvSrc, cbMem); 494 rtldrPEFreePart(pThis, NULL, pvSrc); 495 } 496 return rc; 497 } 498 499 500 474 501 475 502 … … 1962 1989 * (or in case of VERR_BUFFER_OVERFLOW would have). 1963 1990 */ 1964 static int rtLdrPE_QueryUnwind Info(PRTLDRMODPE pThis, void const *pvBits, void *pvBuf, size_t cbBuf, size_t *pcbRet)1991 static int rtLdrPE_QueryUnwindTable(PRTLDRMODPE pThis, void const *pvBits, void *pvBuf, size_t cbBuf, size_t *pcbRet) 1965 1992 { 1966 1993 int rc; … … 1971 1998 *pcbRet = cbSrc; 1972 1999 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 } 2000 rc = rtldrPEReadPartByRvaInfoBuf(pThis, pvBits, pThis->ExceptionDir.VirtualAddress, cbSrc, pvBuf); 1982 2001 else 1983 2002 rc = VERR_BUFFER_OVERFLOW; … … 2062 2081 return rtLdrPE_QueryInternalName(pModPe, pvBits, pvBuf, cbBuf, pcbRet); 2063 2082 2083 case RTLDRPROP_UNWIND_TABLE: 2084 return rtLdrPE_QueryUnwindTable(pModPe, pvBits, pvBuf, cbBuf, pcbRet); 2085 2064 2086 case RTLDRPROP_UNWIND_INFO: 2065 return rtLdrPE_QueryUnwindInfo(pModPe, pvBits, pvBuf, cbBuf, pcbRet); 2087 { 2088 uint32_t uRva = *(uint32_t const *)pvBuf; 2089 if (uRva < pModPe->cbImage) 2090 { 2091 uint32_t cbLeft = pModPe->cbImage - uRva; 2092 uint32_t cbToRead = (uint32_t)RT_MIN(cbLeft, cbBuf); 2093 *pcbRet = cbToRead; 2094 return rtldrPEReadPartByRvaInfoBuf(pModPe, pvBits, uRva, cbToRead, pvBuf); 2095 } 2096 *pcbRet = 0; 2097 return VINF_SUCCESS; 2098 } 2066 2099 2067 2100 default:
Note:
See TracChangeset
for help on using the changeset viewer.