Overlay address in PE should be long, fix caching

This commit is contained in:
Matt Nadareski
2025-09-25 13:55:44 -04:00
parent 4577311432
commit 265789ea84
2 changed files with 17 additions and 5 deletions

View File

@@ -43,11 +43,17 @@ namespace SabreTools.Serialization.Wrappers
// Get the available source length, if possible
long dataLength = Length;
if (dataLength == -1)
return -1;
{
_overlayAddress = -1;
return _overlayAddress.Value;
}
// If a required property is missing
if (Header == null || SegmentTable == null || ResourceTable?.ResourceTypes == null)
return -1;
{
_overlayAddress = -1;
return _overlayAddress.Value;
}
// Search through the segments table to find the furthest
long endOfSectionData = -1;

View File

@@ -292,7 +292,7 @@ namespace SabreTools.Serialization.Wrappers
/// Address of the overlay, if it exists
/// </summary>
/// <see href="https://www.autoitscript.com/forum/topic/153277-pe-file-overlay-extraction/"/>
public int OverlayAddress
public long OverlayAddress
{
get
{
@@ -305,11 +305,17 @@ namespace SabreTools.Serialization.Wrappers
// Get the available source length, if possible
long dataLength = Length;
if (dataLength == -1)
return -1;
{
_overlayAddress = -1;
return _overlayAddress.Value;
}
// If the section table is missing
if (SectionTable == null)
return -1;
{
_overlayAddress = -1;
return _overlayAddress.Value;
}
// If we have certificate data, use that as the end
if (OptionalHeader?.CertificateTable != null)