Changeset 89969 in vbox
- Timestamp:
- Jun 30, 2021 9:33:48 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/ldr.h
r86552 r89969 1130 1130 * This is only implemented for PE. */ 1131 1131 RTLDRPROP_UNWIND_INFO, 1132 /** The image build-id (ELF/GNU). 1133 * Returns usually a SHA1 checksum in the buffer. */ 1134 RTLDRPROP_BUILDID, 1132 1135 1133 1136 /** End of valid properties. */ -
trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h
r85556 r89969 1698 1698 rc = VINF_SUCCESS; 1699 1699 return rc; 1700 } 1701 1702 1703 /** @interface_method_impl{RTLDROPS,pfnQueryProp} */ 1704 static DECLCALLBACK(int) RTLDRELF_NAME(QueryProp)(PRTLDRMODINTERNAL pMod, RTLDRPROP enmProp, void const *pvBits, 1705 void *pvBuf, size_t cbBuf, size_t *pcbRet) 1706 { 1707 PRTLDRMODELF pThis = (PRTLDRMODELF)pMod; 1708 1709 if (enmProp != RTLDRPROP_BUILDID) 1710 return VERR_NOT_FOUND; 1711 1712 /* 1713 * Map the image bits if not already done and setup pointer into it. 1714 */ 1715 int rc = RTLDRELF_NAME(MapBits)(pThis, true); 1716 if (RT_FAILURE(rc)) 1717 return rc; 1718 1719 /* 1720 * Search for the build ID. 1721 */ 1722 const Elf_Shdr *paShdrs = pThis->paOrgShdrs; 1723 for (unsigned iShdr = 0; iShdr < pThis->Ehdr.e_shnum; iShdr++) 1724 { 1725 const char *pszSectName = ELF_SH_STR(pThis, paShdrs[iShdr].sh_name); 1726 1727 if (!strcmp(pszSectName, ".note.gnu.build-id")) 1728 { 1729 if ((paShdrs[iShdr].sh_size & 3) || paShdrs[iShdr].sh_size < sizeof(Elf_Nhdr)) 1730 return VERR_BAD_EXE_FORMAT; 1731 1732 Elf_Nhdr *pNHdr = (Elf_Nhdr *)((uintptr_t)pThis->pvBits + (uintptr_t)paShdrs[iShdr].sh_offset); 1733 if ( pNHdr->n_namesz > paShdrs[iShdr].sh_size 1734 || pNHdr->n_descsz > paShdrs[iShdr].sh_size 1735 || (paShdrs[iShdr].sh_size - pNHdr->n_descsz) < pNHdr->n_namesz 1736 || pNHdr->n_type != NT_GNU_BUILD_ID) 1737 return VERR_BAD_EXE_FORMAT; 1738 1739 const char *pszOwner = (const char *)(pNHdr + 1); 1740 if ( !RTStrEnd(pszOwner, pNHdr->n_namesz) 1741 || strcmp(pszOwner, "GNU")) 1742 return VERR_BAD_EXE_FORMAT; 1743 1744 if (cbBuf < pNHdr->n_descsz) 1745 return VERR_BUFFER_OVERFLOW; 1746 1747 memcpy(pvBuf, pszOwner + pNHdr->n_namesz, pNHdr->n_descsz); 1748 *pcbRet = pNHdr->n_descsz; 1749 return VINF_SUCCESS; 1750 } 1751 } 1752 1753 NOREF(cbBuf); 1754 RT_NOREF_PV(pvBits); 1755 return VERR_NOT_FOUND; 1700 1756 } 1701 1757 … … 1809 1865 RTLDRELF_NAME(RvaToSegOffset), 1810 1866 RTLDRELF_NAME(ReadDbgInfo), 1811 NULL /*pfnQueryProp*/,1867 RTLDRELF_NAME(QueryProp), 1812 1868 NULL /*pfnVerifySignature*/, 1813 1869 NULL /*pfnHashImage*/, -
trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp
r82968 r89969 658 658 break; 659 659 660 case RTLDRPROP_BUILDID: 661 *pcbRet = 0; 662 break; 663 660 664 default: 661 665 AssertFailedReturn(VERR_INVALID_FUNCTION);
Note:
See TracChangeset
for help on using the changeset viewer.