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

56 lines
1.2 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;
namespace EpicRerouter.ExeSide;
public static class Program
2022-02-07 07:09:55 +00:00
{
public static string ProductName;
public static string Version;
2022-02-07 07:09:55 +00:00
private static void Main(string[] args)
{
ProductName = args[0];
Log($"product name = {ProductName}");
Version = args[1];
Log($"version = {Version}");
var managedDir = args[2];
Log($"managed dir = {managedDir}");
var gameArgs = args.Skip(3).ToArray();
Log($"game args = {string.Join(", ", gameArgs)}");
AppDomain.CurrentDomain.AssemblyResolve += (_, e) =>
2022-02-07 07:09:55 +00:00
{
var name = new AssemblyName(e.Name).Name + ".dll";
var path = Path.Combine(managedDir, name);
return File.Exists(path) ? Assembly.LoadFile(path) : null;
};
2022-02-07 07:09:55 +00:00
Go();
}
2022-02-07 07:09:55 +00:00
private static void Go()
{
try
2022-02-07 07:09:55 +00:00
{
EpicPlatformManager.Init();
EpicEntitlementRetriever.Init();
2022-02-07 07:09:55 +00:00
while (EpicEntitlementRetriever.GetOwnershipStatus() == EntitlementsManager.AsyncOwnershipStatus.NotReady)
2022-02-07 07:09:55 +00:00
{
EpicPlatformManager.Tick();
2022-02-07 07:09:55 +00:00
}
}
finally
{
EpicEntitlementRetriever.Uninit();
EpicPlatformManager.Uninit();
2022-02-07 09:09:44 +00:00
Environment.Exit((int)EpicEntitlementRetriever.GetOwnershipStatus());
}
2022-02-07 07:09:55 +00:00
}
public static void Log(object msg) => Console.Error.WriteLine(msg);
}