diff --git a/EpicRerouter/ExeSide/Program.cs b/EpicRerouter/ExeSide/Program.cs index 6179bb4c..f33b18bb 100644 --- a/EpicRerouter/ExeSide/Program.cs +++ b/EpicRerouter/ExeSide/Program.cs @@ -1,7 +1,5 @@ -using HarmonyLib; -using System; +using System; using System.IO; -using System.Linq; using System.Reflection; using System.Threading; using static EntitlementsManager; @@ -15,28 +13,25 @@ namespace EpicRerouter.ExeSide private static void Main(string[] args) { - ProductName = args[1]; - Console.WriteLine($"product name = {ProductName}"); - Version = args[2]; - Console.WriteLine($"version = {Version}"); + AppDomain.CurrentDomain.UnhandledException += (_, e) => + { + Console.Error.WriteLine(e.ExceptionObject); + Console.ReadKey(); + }; - var assemblyDirs = args.Skip(2).ToArray(); - Console.WriteLine($"assembly dirs = {assemblyDirs.Join()}"); + ProductName = args[0]; + Console.WriteLine($"product name = {ProductName}"); + Version = args[1]; + Console.WriteLine($"version = {Version}"); + var managedDir = args[2]; + Console.WriteLine($"managed dir = {managedDir}"); Console.WriteLine(); AppDomain.CurrentDomain.AssemblyResolve += (_, e) => { var name = new AssemblyName(e.Name).Name + ".dll"; - foreach (var dir in assemblyDirs) - { - var path = Path.Combine(dir, name); - if (File.Exists(path)) - { - return Assembly.LoadFile(path); - } - } - - return null; + var path = Path.Combine(managedDir, name); + return File.Exists(path) ? Assembly.LoadFile(path) : null; }; Go(); @@ -60,10 +55,7 @@ namespace EpicRerouter.ExeSide EpicEntitlementRetriever.Uninit(); EpicPlatformManager.Uninit(); - Console.WriteLine("all done"); - Console.ReadKey(); - - Environment.Exit((int)AsyncOwnershipStatus.NotReady); + // Environment.Exit((int)AsyncOwnershipStatus.NotReady); } } } diff --git a/EpicRerouter/ModSide/Interop.cs b/EpicRerouter/ModSide/Interop.cs index 23b151fd..50d734ac 100644 --- a/EpicRerouter/ModSide/Interop.cs +++ b/EpicRerouter/ModSide/Interop.cs @@ -30,28 +30,17 @@ namespace EpicRerouter.ModSide Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "EpicRerouter.exe" ); - var assemblyDirs = AppDomain.CurrentDomain.GetAssemblies() - .Select(x => - { - try - { - return Path.GetDirectoryName(x.Location); - } - catch - { - return null; - } - }) - .Where(x => x != null) - .Distinct(); + var args = new[] + { + Application.productName, + Application.version, + Path.GetDirectoryName(typeof(EpicPlatformManager).Assembly.Location) + }; var process = Process.Start(new ProcessStartInfo { FileName = processPath, WorkingDirectory = Path.GetDirectoryName(processPath)!, - Arguments = assemblyDirs - .Prepend(Application.productName) - .Prepend(Application.version) - .Join(x => $"\"{x}\"", " "), + Arguments = args.Join(x => $"\"{x}\"", " "), UseShellExecute = false }); process!.WaitForExit();