63 lines
2.8 KiB
C#
63 lines
2.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using GameLauncher.Engines.Common;
|
|
|
|
namespace GameLauncher.Engines.Evb
|
|
{
|
|
/// <summary>
|
|
/// Backwards-compatible facade over <see cref="EvbDetectionHelper"/>.
|
|
///
|
|
/// The plan names the detection primitive <see cref="EvbDetectionHelper"/>, but
|
|
/// several callers (the engine module, the unpack service and the game scanner)
|
|
/// were written against the shorter <c>EvbDetector</c> API. This facade keeps those
|
|
/// call sites stable while the authoritative PE-signature logic lives in
|
|
/// <see cref="EvbDetectionHelper"/>.
|
|
///
|
|
/// This class is engine-local and has no side effects.
|
|
/// </summary>
|
|
public static class EvbDetector
|
|
{
|
|
/// <summary>
|
|
/// Returns true when the game directory holds an EVB packed executable
|
|
/// that can actually be unpacked (or a completed extraction of one).
|
|
///
|
|
/// Accepts only the following decisive signals:
|
|
/// 1. A top-level executable carrying both a decisive EVB PE section (.enigma1)
|
|
/// and the EVB virtual filesystem signature ("EVB\0"), so it is unpackable.
|
|
/// 2. An already-unpacked game (game-local "_evb_extracted" with a completion
|
|
/// marker). This is required because unpacking renames the original packed exe
|
|
/// to "*.glbak", after which the signature check alone would no longer detect
|
|
/// the game and its launch / icon resolution would break.
|
|
/// </summary>
|
|
public static bool IsEvbGame(string gameDirectory)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(gameDirectory) || !Directory.Exists(gameDirectory))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// A completed extraction keeps the game recognized even without the packed exe.
|
|
if (EvbDetectionHelper.IsExtracted(gameDirectory))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory) != null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resolves the executable that should be passed to the unpacker: the first
|
|
/// <c>.exe</c> in the folder that carries a decisive EVB signature, or null.
|
|
/// </summary>
|
|
public static string? FindPackedExecutable(string gameDirectory)
|
|
=> EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory);
|
|
|
|
/// <summary>Returns true when the given executable is packed with EVB.</summary>
|
|
public static bool ContainsEvbSignature(string exePath)
|
|
=> EvbDetectionHelper.IsEvbPacked(exePath);
|
|
|
|
/// <summary>Re-exposes the engine name constant for callers that only reference this helper.</summary>
|
|
public static string EngineName => EngineDetectionHelper.EngineEvb;
|
|
}
|
|
}
|