Changeset 97875 in vbox
- Timestamp:
- Dec 27, 2022 10:08:00 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154965
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r96777 r97875 122 122 /** Size of the header (IMAGE_OPTIONAL_HEADER32::SizeOfHeaders). */ 123 123 uint32_t cbHeaders; 124 /** Section alignment (IMAGE_OPTIONAL_HEADER32::SectionAlignment). */ 125 uint32_t uSectionAlign; 124 126 /** The image timestamp. */ 125 127 uint32_t uTimestamp; … … 1672 1674 SegInfo.cbFile = pModPe->cbHeaders; 1673 1675 SegInfo.cbMapped = pModPe->cbHeaders; 1674 if ( (pModPe->paSections[0].Characteristics & IMAGE_SCN_TYPE_NOLOAD))1676 if (!(pModPe->paSections[0].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 1675 1677 SegInfo.cbMapped = pModPe->paSections[0].VirtualAddress; 1676 1678 int rc = pfnCallback(pMod, &SegInfo, pvUser); … … 1709 1711 if (SegInfo.Alignment > 0) 1710 1712 SegInfo.Alignment = RT_BIT_64(SegInfo.Alignment - 1); 1713 else 1714 SegInfo.Alignment = pModPe->uSectionAlign; 1711 1715 if (pSh->Characteristics & IMAGE_SCN_TYPE_NOLOAD) 1712 1716 { 1713 1717 SegInfo.LinkAddress = NIL_RTLDRADDR; 1714 1718 SegInfo.RVA = NIL_RTLDRADDR; 1715 SegInfo.cbMapped = pSh->Misc.VirtualSize;1719 SegInfo.cbMapped = 0; 1716 1720 } 1717 1721 else … … 1719 1723 SegInfo.LinkAddress = pSh->VirtualAddress + pModPe->uImageBase; 1720 1724 SegInfo.RVA = pSh->VirtualAddress; 1721 SegInfo.cbMapped = RT_ALIGN( SegInfo.cb, SegInfo.Alignment);1725 SegInfo.cbMapped = RT_ALIGN(pSh->Misc.VirtualSize, SegInfo.Alignment); 1722 1726 if (i + 1 < pModPe->cSections && !(pSh[1].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 1723 1727 SegInfo.cbMapped = pSh[1].VirtualAddress - pSh->VirtualAddress; … … 1808 1812 if (iSeg == 0) 1809 1813 *pRva = offSeg; 1810 else if (pModPe->paSections[iSeg].Characteristics & IMAGE_SCN_TYPE_NOLOAD) 1814 else if (!(pModPe->paSections[iSeg - 1].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 1815 *pRva = offSeg + pModPe->paSections[iSeg - 1].VirtualAddress; 1816 else 1811 1817 return VERR_LDR_INVALID_SEG_OFFSET; 1812 else1813 *pRva = offSeg + pModPe->paSections[iSeg - 1].VirtualAddress;1814 1818 return VINF_SUCCESS; 1815 1819 } … … 4297 4301 } 4298 4302 #endif 4303 if (!RT_IS_POWER_OF_TWO(pOptHdr->SectionAlignment)) 4304 return RTERRINFO_LOG_SET_F(pErrInfo, VERR_BAD_EXE_FORMAT, 4305 "SectionAlignment=%#x - not a power of two", pOptHdr->SectionAlignment); 4306 if (pOptHdr->SectionAlignment < 16 || pOptHdr->SectionAlignment > _128K) 4307 return RTERRINFO_LOG_SET_F(pErrInfo, VERR_BAD_EXE_FORMAT, 4308 "SectionAlignment=%#x - unsupported value, not between 16 and 128KB", pOptHdr->SectionAlignment); 4299 4309 if (pOptHdr->SizeOfHeaders >= cbImage) 4300 4310 { … … 5115 5125 pModPe->cbImage = OptHdr.SizeOfImage; 5116 5126 pModPe->cbHeaders = OptHdr.SizeOfHeaders; 5127 pModPe->uSectionAlign = OptHdr.SectionAlignment; 5117 5128 pModPe->uTimestamp = FileHdr.TimeDateStamp; 5118 5129 pModPe->cImports = UINT32_MAX;
Note:
See TracChangeset
for help on using the changeset viewer.