Skip to content

Commit 1b4f363

Browse files
committed
Couple of PECompact things
1 parent 8abdaa4 commit 1b4f363

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

BinaryObjectScanner/Packer/PECompact.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ public class PECompact : IExecutableCheck<PortableExecutable>
1717
// TODO: Get more granular version detection. PiD is somehow able to detect version ranges based
1818
// on the data in the file. This may be related to information in other fields
1919

20+
// Investigate the ".pec" section, seemingly related to "pec1"
21+
2022
// Get the pec1 section, if it exists
2123
if (exe.ContainsSection("pec1", exact: true))
2224
return "PE Compact v1.x";
2325

24-
// Get the PEC2 section, if it exists -- TODO: Verify this comment since it's pulling the .text section
25-
var textSection = exe.GetFirstSection(".text", exact: true);
26-
if (textSection?.PointerToRelocations == 0x32434550)
26+
// TODO: The last 4 bytes of the PEC2 section name appear to be the version
27+
// For v2.20 - v3.02 this value is 0
28+
// For internal version v20240 this is [10 4F 00 00] (20240)
29+
30+
// Get the PEC2 section, if it exists
31+
var pec2Section = exe.GetFirstSection("PEC2", exact: false);
32+
if (pec2Section?.PointerToRelocations == 0x32434550)
2733
{
28-
if (textSection.PointerToLinenumbers != 0)
29-
return $"PE Compact v{textSection.PointerToLinenumbers} (internal version)";
34+
if (pec2Section.PointerToLinenumbers != 0)
35+
return $"PE Compact v{pec2Section.PointerToLinenumbers} (internal version)";
3036

3137
return "PE Compact v2.x (or newer)";
3238
}

0 commit comments

Comments
 (0)