Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions SabreTools.Serialization/Wrappers/PortableExecutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down