quantum-space-buddies/EpicRerouter/ExeSide/Program.cs

67 lines
1.5 KiB
C#
Raw Normal View History

2022-02-07 07:23:49 +00:00
using System;
2022-02-07 07:09:55 +00:00
using System.IO;
2022-02-07 07:54:52 +00:00
using System.Linq;
2022-02-07 07:09:55 +00:00
using System.Reflection;
using System.Threading;
using static EntitlementsManager;
namespace EpicRerouter.ExeSide
{
public static class Program
{
public static string ProductName;
public static string Version;
private static void Main(string[] args)
{
2022-02-07 07:23:49 +00:00
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
Console.Error.WriteLine(e.ExceptionObject);
Console.ReadKey();
};
ProductName = args[0];
2022-02-07 07:09:55 +00:00
Console.WriteLine($"product name = {ProductName}");
2022-02-07 07:23:49 +00:00
Version = args[1];
2022-02-07 07:09:55 +00:00
Console.WriteLine($"version = {Version}");
2022-02-07 07:23:49 +00:00
var managedDir = args[2];
Console.WriteLine($"managed dir = {managedDir}");
2022-02-07 07:54:52 +00:00
var gameArgs = args.Skip(3).ToArray();
Console.WriteLine($"game args = {string.Join(", ", gameArgs)}");
2022-02-07 07:09:55 +00:00
Console.WriteLine();
AppDomain.CurrentDomain.AssemblyResolve += (_, e) =>
{
var name = new AssemblyName(e.Name).Name + ".dll";
2022-02-07 07:23:49 +00:00
var path = Path.Combine(managedDir, name);
return File.Exists(path) ? Assembly.LoadFile(path) : null;
2022-02-07 07:09:55 +00:00
};
Go();
}
private static void Go()
{
try
{
EpicPlatformManager.Init();
EpicEntitlementRetriever.Init();
while (EpicEntitlementRetriever.GetOwnershipStatus() == AsyncOwnershipStatus.NotReady)
{
EpicPlatformManager.Tick();
Thread.Sleep(100);
}
}
finally
{
EpicEntitlementRetriever.Uninit();
EpicPlatformManager.Uninit();
2022-02-07 08:07:53 +00:00
Console.ReadKey();
2022-02-07 08:20:01 +00:00
Environment.Exit((int)AsyncOwnershipStatus.NotOwned);
2022-02-07 07:09:55 +00:00
}
}
}
}