- Add Enigma Virtual Box (EVB) engine support: detection, badge, unpack/restore UI - Bundle evbunpack.exe under Engines/Evb/Tools/evbunpack (Apache-2.0, with LICENSE/README) - Copy Engines\\**\\Tools\\** to build output via csproj (publish already covered by publish.ps1) - Throttle evbunpack progress reporting and shorten timeout to stop UI freeze - Rename original packed exe to .glbak and write a completion marker; make Restore reverse it - Launch the unpacked exe from _evb_extracted so script mods apply - Replace EVB MessageBox dialogs with readable log summaries - Remove obsolete boxed/7zip extraction code (NwjsPackageUnpacker, TkoolPackagedExtractionService)
123 lines
4.9 KiB
C#
123 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using GameLauncher.Helpers;
|
|
|
|
namespace GameLauncher.Engines.Evb
|
|
{
|
|
/// <summary>
|
|
/// Resolves the bundled evbunpack executable used to unpack Enigma Virtual Box (EVB)
|
|
/// packed applications.
|
|
///
|
|
/// Design notes (durable / reusable):
|
|
/// - The tool is bundled under `Engines\Evb\Tools\evbunpack\` (per-engine tools folder).
|
|
/// - Path resolution goes through <see cref="AppPathHelper"/> so that deployed, production
|
|
/// and source-tree layouts are all supported without hard-coding this machine's paths.
|
|
/// - CLI argument construction is kept in one place so callers never duplicate the
|
|
/// evbunpack invocation contract.
|
|
///
|
|
/// The evbunpack CLI contract:
|
|
/// evbunpack [-pe {10_70,9_70,7_80}] [--legacy-fs] <input exe> <output folder>
|
|
/// It restores both the packed virtual file system and the original PE executable.
|
|
/// </summary>
|
|
public static class EvbUnpackerToolProvider
|
|
{
|
|
/// <summary>Engine identifier passed to <see cref="AppPathHelper.GetEngineToolsDirectory"/>.</summary>
|
|
public const string EngineName = "Evb";
|
|
|
|
/// <summary>Bundled unpacker executable name.</summary>
|
|
public const string DefaultToolExeName = "evbunpack.exe";
|
|
|
|
/// <summary>Relative subfolder under Engines/Evb/Tools that holds the tool.</summary>
|
|
public const string ToolSubDirectory = "evbunpack";
|
|
|
|
/// <summary>
|
|
/// Default PE rebuild variant used when the caller does not specify one.
|
|
/// 9_70 works for Enigma Virtual Box 9.70 and 10.70/11.00 in most cases;
|
|
/// callers may override via <see cref="BuildArguments"/>.
|
|
/// </summary>
|
|
public const string DefaultPeVariant = "9_70";
|
|
|
|
/// <summary>Gets the engine tools directory (Engines/Evb/Tools).</summary>
|
|
public static string GetToolsDirectory()
|
|
{
|
|
return AppPathHelper.GetEngineToolsDirectory(EngineName);
|
|
}
|
|
|
|
/// <summary>Gets the bundled tool subfolder (Engines/Evb/Tools/evbunpack).</summary>
|
|
public static string GetToolDirectory()
|
|
{
|
|
return Path.Combine(GetToolsDirectory(), ToolSubDirectory);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resolves the evbunpack.exe path, or null when the tool is missing.
|
|
/// Prefers the bundled subfolder, then falls back to a flat layout inside the
|
|
/// engine tools folder (and the shared <see cref="AppPathHelper.ResolveEngineTool"/> probe).
|
|
/// </summary>
|
|
public static string? GetToolPath()
|
|
{
|
|
try
|
|
{
|
|
var candidates = new[]
|
|
{
|
|
Path.Combine(GetToolDirectory(), DefaultToolExeName),
|
|
Path.Combine(GetToolsDirectory(), DefaultToolExeName),
|
|
};
|
|
|
|
var found = candidates.FirstOrDefault(File.Exists);
|
|
if (found != null)
|
|
{
|
|
return found;
|
|
}
|
|
|
|
// Fall back to the shared per-engine resolver (checks deployed + dev layouts).
|
|
return AppPathHelper.ResolveEngineTool(
|
|
EngineName,
|
|
Path.Combine(ToolSubDirectory, DefaultToolExeName));
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>True when the unpacker executable exists and is usable.</summary>
|
|
public static bool IsAvailable() => GetToolPath() != null;
|
|
|
|
/// <summary>
|
|
/// Builds the argument list for the unpacker CLI.
|
|
/// Emits the PE variant first, then the optional legacy switch, then the
|
|
/// input executable and the output folder. Values are raw (no quoting); callers
|
|
/// pass them through <c>ProcessStartInfo.ArgumentList</c> which handles escaping.
|
|
/// </summary>
|
|
/// <param name="inputExePath">Path to the EVB-packed executable.</param>
|
|
/// <param name="outputDirectory">Folder that receives the unpacked files.</param>
|
|
/// <param name="legacyFileSystem">When true, adds <c>--legacy-fs</c> for packer version 7.80.</param>
|
|
/// <param name="peVariant">PE rebuild variant (10_70/9_70/7_80); defaults to <see cref="DefaultPeVariant"/>.</param>
|
|
public static IReadOnlyList<string> BuildArguments(
|
|
string inputExePath,
|
|
string outputDirectory,
|
|
bool legacyFileSystem = false,
|
|
string? peVariant = null)
|
|
{
|
|
var args = new List<string>();
|
|
|
|
if (legacyFileSystem)
|
|
{
|
|
args.Add("--legacy-fs");
|
|
}
|
|
|
|
var variant = string.IsNullOrWhiteSpace(peVariant) ? DefaultPeVariant : peVariant.Trim();
|
|
args.Add("-pe");
|
|
args.Add(variant);
|
|
|
|
args.Add(inputExePath);
|
|
args.Add(outputDirectory);
|
|
|
|
return args;
|
|
}
|
|
}
|
|
}
|