diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index 281909da..f1db2fe8 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -344,6 +344,12 @@ public long OverlayAddress // Search through all sections and find the furthest a section goes long endOfSectionData = OptionalHeader.SizeOfHeaders; + + // For UPX-packed executables, OptionalHeader.SizeOfHeaders is consistently 4096 and wrong, + // wheras PointerToRawData is consistently 1024 and correct. + if (SectionNames[0] == "UPX0") + endOfSectionData = SectionTable[0].PointerToRawData; + Array.ForEach(SectionTable, s => endOfSectionData += s.SizeOfRawData); // If we didn't find the end of section data