From 0afd189fe0db207beb2bdf5996885ba650344eba Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 20 Sep 2025 18:55:05 -0400 Subject: [PATCH] Align ContainsSection checks --- BinaryObjectScanner/Packer/MPRESS.cs | 11 ++++++----- BinaryObjectScanner/Packer/PKLite.cs | 2 +- BinaryObjectScanner/Packer/Shrinker.cs | 11 ++++++----- BinaryObjectScanner/Protection/NEACProtect.cs | 4 +++- BinaryObjectScanner/Protection/SecuROM.cs | 4 +++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/BinaryObjectScanner/Packer/MPRESS.cs b/BinaryObjectScanner/Packer/MPRESS.cs index eab33990..d657c7ef 100644 --- a/BinaryObjectScanner/Packer/MPRESS.cs +++ b/BinaryObjectScanner/Packer/MPRESS.cs @@ -10,12 +10,13 @@ namespace BinaryObjectScanner.Packer /// public string? CheckExecutable(string file, PortableExecutable exe, bool includeDebug) { - bool mpress1 = exe.ContainsSection(".MPRESS1"); - bool mpress2 = exe.ContainsSection(".MPRESS2 "); - // TODO: Confirm if both need to be present - if (mpress1 || mpress2) - return "MPRESS"; // TODO: Figure out how to get version + // TODO: Figure out how to get version + + if (exe.ContainsSection(".MPRESS1")) + return "MPRESS"; + if (exe.ContainsSection(".MPRESS2")) + return "MPRESS"; return null; } diff --git a/BinaryObjectScanner/Packer/PKLite.cs b/BinaryObjectScanner/Packer/PKLite.cs index b8327549..a6204491 100644 --- a/BinaryObjectScanner/Packer/PKLite.cs +++ b/BinaryObjectScanner/Packer/PKLite.cs @@ -12,7 +12,7 @@ namespace BinaryObjectScanner.Packer public string? CheckExecutable(string file, PortableExecutable exe, bool includeDebug) { // - if (exe.ContainsSection(".pklstb")) + if (exe.ContainsSection(".pklstb", exact: true)) return "PKLITE32"; // TODO: Figure out how to determine version return null; diff --git a/BinaryObjectScanner/Packer/Shrinker.cs b/BinaryObjectScanner/Packer/Shrinker.cs index 3a7d4bb6..32182a8d 100644 --- a/BinaryObjectScanner/Packer/Shrinker.cs +++ b/BinaryObjectScanner/Packer/Shrinker.cs @@ -10,12 +10,13 @@ namespace BinaryObjectScanner.Packer /// public string? CheckExecutable(string file, PortableExecutable exe, bool includeDebug) { - bool shrink0 = exe.ContainsSection(".shrink0", exact: true); - bool shrink2 = exe.ContainsSection(".shrink2", exact: true); + // TODO: Confirm if both need to be present + // TODO: Figure out how to get version - // TODO: Confirm if both need to be present - if (shrink0 || shrink2) - return "Shrinker"; // TODO: Figure out how to get version + if (exe.ContainsSection(".shrink0", exact: true)) + return "Shrinker"; + if (exe.ContainsSection(".shrink2", exact: true)) + return "Shrinker"; return null; } diff --git a/BinaryObjectScanner/Protection/NEACProtect.cs b/BinaryObjectScanner/Protection/NEACProtect.cs index 9c5f3a63..dd76de46 100644 --- a/BinaryObjectScanner/Protection/NEACProtect.cs +++ b/BinaryObjectScanner/Protection/NEACProtect.cs @@ -28,7 +28,9 @@ namespace BinaryObjectScanner.Protection // Get the .neac0 and .neac1 sections, if they exist. // Found in "NeacSafe64.sys" and "NeacSafe.sys". - if (exe.ContainsSection(".neac0", exact: true) || exe.ContainsSection(".neac1", exact: true)) + if (exe.ContainsSection(".neac0", exact: true)) + return "NEAC Protect"; + if (exe.ContainsSection(".neac1", exact: true)) return "NEAC Protect"; string? name = exe.ProductName; diff --git a/BinaryObjectScanner/Protection/SecuROM.cs b/BinaryObjectScanner/Protection/SecuROM.cs index 4b954311..0da4e173 100644 --- a/BinaryObjectScanner/Protection/SecuROM.cs +++ b/BinaryObjectScanner/Protection/SecuROM.cs @@ -187,7 +187,9 @@ namespace BinaryObjectScanner.Protection } // Get the .cms_d and .cms_t sections, if they exist -- TODO: Confirm if both are needed or either/or is fine - if (exe.ContainsSection(".cmd_d", true) || exe.ContainsSection(".cms_t", true)) + if (exe.ContainsSection(".cmd_d", true)) + return $"SecuROM 1-3"; + if (exe.ContainsSection(".cms_t", true)) return $"SecuROM 1-3"; return null;