diff --git a/Engines/Evb/EvbDetectionHelper.cs b/Engines/Evb/EvbDetectionHelper.cs index 39bf941..953b03e 100644 --- a/Engines/Evb/EvbDetectionHelper.cs +++ b/Engines/Evb/EvbDetectionHelper.cs @@ -10,34 +10,21 @@ namespace GameLauncher.Engines.Evb /// that ordinary (unpacked) games are never misclassified. /// /// Detection strategy: - /// 1. Parse the PE header and inspect the section table for the packer's sections - /// (".enigma1" / ".enigma2"). A present section is a decisive match. - /// 2. When sections are inconclusive, scan bounded windows of the file for the - /// "Enigma Virtual Box" marker string embedded by the packer. + /// Parse the PE header and inspect the section table for the packer's sections + /// (".enigma1" / ".enigma2"). A present section is a decisive match; anything else + /// is treated as "not EVB" so plain (unpacked) games are never misclassified. /// /// This class is engine-local and has no side effects. /// public static class EvbDetectionHelper { - /// Marker string embedded by the Enigma Virtual Box packer. - private const string EnigmaMarker = "Enigma Virtual Box"; - /// Section names produced by the packer. private static readonly string[] EnigmaSections = { ".enigma1", ".enigma2" }; - /// Additional loader identifiers checked during the content scan. - private static readonly string[] EvbContentMarkers = - { - EnigmaMarker, - "evb.dll", - "EnigmaVB", - }; - /// Returns true when the given executable is packed with EVB. /// - /// Step 1 reads the PE section table for the packer's section names. - /// Step 2 falls back to a bounded content scan for the packer marker. - /// Any IO/format error yields false (treated as "not confidently EVB"). + /// Reads the PE section table for the packer's section names. Any IO/format error + /// yields false (treated as "not confidently EVB"). /// public static bool IsEvbPacked(string exePath) { @@ -48,24 +35,12 @@ namespace GameLauncher.Engines.Evb try { - // Step 1: decisive PE section check. - if (HasEnigmaSection(exePath)) - { - return true; - } - } - catch - { - // Fall through to the content scan on any parse failure. - } - - try - { - // Step 2: content marker scan over bounded windows. - return ContainsEvbContentMarker(exePath); + // Decisive: the packer's own PE sections are the only reliable signal. + return HasEnigmaSection(exePath); } catch { + // Unparseable executable -> never claim EVB. return false; } } @@ -188,46 +163,5 @@ namespace GameLauncher.Engines.Evb return false; } - - /// - /// Scans bounded windows of the executable for EVB loader markers. - /// EVB metadata typically sits near the end of the PE (overlay). - /// - private static bool ContainsEvbContentMarker(string exePath) - { - const int windowSize = 2 * 1024 * 1024; - using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - long size = fs.Length; - if (size < 1024) - { - return false; - } - - double[] fractions = { 0.5, 0.8, 0.9, 0.97 }; - foreach (var frac in fractions) - { - long start = (long)(size * frac); - int readLen = (int)Math.Min(windowSize, size - start); - if (readLen <= 0) - { - continue; - } - - var buf = new byte[readLen]; - fs.Seek(start, SeekOrigin.Begin); - int read = fs.Read(buf, 0, buf.Length); - var text = System.Text.Encoding.ASCII.GetString(buf, 0, read); - - foreach (var marker in EvbContentMarkers) - { - if (text.IndexOf(marker, StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } - } - } - - return false; - } } }