Partially revert and clarify

This commit is contained in:
Matt Nadareski
2025-09-26 21:45:01 -04:00
parent 1b4f363b08
commit d6a89c8905

View File

@@ -23,16 +23,14 @@ namespace BinaryObjectScanner.Packer
if (exe.ContainsSection("pec1", exact: true))
return "PE Compact v1.x";
// TODO: The last 4 bytes of the PEC2 section name appear to be the version
// For v2.20 - v3.02 this value is 0
// For internal version v20240 this is [10 4F 00 00] (20240)
// Get the .text section, if it exists
var textSection = exe.GetFirstSection(".text", exact: true);
// Get the PEC2 section, if it exists
var pec2Section = exe.GetFirstSection("PEC2", exact: false);
if (pec2Section?.PointerToRelocations == 0x32434550)
// Check for "PEC2" in the pointer to relocations
if (textSection?.PointerToRelocations == 0x32434550)
{
if (pec2Section.PointerToLinenumbers != 0)
return $"PE Compact v{pec2Section.PointerToLinenumbers} (internal version)";
if (textSection.PointerToLinenumbers != 0)
return $"PE Compact v{textSection.PointerToLinenumbers} (internal version)";
return "PE Compact v2.x (or newer)";
}