2022-02-07 05:38:14 +00:00
|
|
|
|
using HarmonyLib;
|
2022-02-07 05:52:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Debug = UnityEngine.Debug;
|
2022-02-07 05:38:14 +00:00
|
|
|
|
|
|
|
|
|
namespace EpicRerouter
|
|
|
|
|
{
|
|
|
|
|
public static class Interop
|
|
|
|
|
{
|
2022-02-07 05:52:18 +00:00
|
|
|
|
public static void Log(object msg) => Debug.LogError($"[interop] {msg}");
|
2022-02-07 05:38:14 +00:00
|
|
|
|
|
|
|
|
|
public static void Go()
|
|
|
|
|
{
|
|
|
|
|
Log("go");
|
|
|
|
|
|
|
|
|
|
Harmony.CreateAndPatchAll(typeof(Patches));
|
2022-02-07 05:52:18 +00:00
|
|
|
|
|
|
|
|
|
var processPath = Path.Combine(
|
|
|
|
|
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!,
|
|
|
|
|
"EpicRerouter.exe"
|
|
|
|
|
);
|
|
|
|
|
var assemblyLocations = AppDomain.CurrentDomain.GetAssemblies()
|
|
|
|
|
.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return x.Location == string.Empty ? null : x.Location;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.Where(x => x != null);
|
|
|
|
|
var process = Process.Start(new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = processPath,
|
|
|
|
|
WorkingDirectory = Path.GetDirectoryName(processPath)!,
|
|
|
|
|
Arguments = assemblyLocations.Join(x => $"\"{x}\"", " "),
|
|
|
|
|
UseShellExecute = false
|
|
|
|
|
});
|
|
|
|
|
process!.WaitForExit();
|
|
|
|
|
var ownershipStatus = (EntitlementsManager.AsyncOwnershipStatus)process.ExitCode;
|
|
|
|
|
Log($"ownership status = {ownershipStatus}");
|
2022-02-07 05:38:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|