From ea4c51b9f27380bfcacf92f54f30436789da5e29 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 14 Mar 2026 11:20:40 -0400 Subject: [PATCH] Use first nonzero-sized section as overlay address basis --- SabreTools.Serialization/Wrappers/PortableExecutable.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index fd3e8c47..0f1155a7 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -343,9 +343,9 @@ namespace SabreTools.Serialization.Wrappers } // Search through all sections and find the furthest a section goes - // OptionalHeader.SizeOfHeaders is inconsistent here so first section is used instead // TODO: Investigate cases where first section pointer does not work - long endOfSectionData = SectionTable[0].PointerToRawData; + var firstSection = Array.Find(SectionTable, s => s.SizeOfRawData != 0); + long endOfSectionData = firstSection.PointerToRawData; Array.ForEach(SectionTable, s => endOfSectionData += s.SizeOfRawData);