From e9d97008a70e3b3f70e881695f949f508435eec3 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 6 Feb 2022 22:05:24 -0800 Subject: [PATCH] some patches --- EpicRerouter/Interop.cs | 12 +++++++++--- EpicRerouter/Patches.cs | 30 +++++++++++++++++++++++++++++- EpicRerouter/Program.cs | 13 ++++++++----- QSB/QSBCore.cs | 5 ++++- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/EpicRerouter/Interop.cs b/EpicRerouter/Interop.cs index d3b2533d..c1956df3 100644 --- a/EpicRerouter/Interop.cs +++ b/EpicRerouter/Interop.cs @@ -4,13 +4,17 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using static EntitlementsManager; using Debug = UnityEngine.Debug; namespace EpicRerouter { + /// + /// runs on qsb side + /// public static class Interop { - public static void Log(object msg) => Debug.LogError($"[interop] {msg}"); + public static AsyncOwnershipStatus OwnershipStatus { get; private set; } = AsyncOwnershipStatus.NotReady; public static void Go() { @@ -43,8 +47,10 @@ namespace EpicRerouter UseShellExecute = false }); process!.WaitForExit(); - var ownershipStatus = (EntitlementsManager.AsyncOwnershipStatus)process.ExitCode; - Log($"ownership status = {ownershipStatus}"); + OwnershipStatus = (AsyncOwnershipStatus)process.ExitCode; + Log($"ownership status = {OwnershipStatus}"); } + + public static void Log(object msg) => Debug.LogError($"[interop] {msg}"); } } diff --git a/EpicRerouter/Patches.cs b/EpicRerouter/Patches.cs index ad2ab5ad..5d0f0c3a 100644 --- a/EpicRerouter/Patches.cs +++ b/EpicRerouter/Patches.cs @@ -2,6 +2,34 @@ namespace EpicRerouter { + /// + /// runs on qsb side + /// [HarmonyPatch(typeof(EpicPlatformManager))] - public static class Patches { } + internal static class Patches + { + [HarmonyPrefix] + [HarmonyPatch("instance", MethodType.Getter)] + private static bool GetInstance() + { + Interop.Log("instance get called"); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch("instance", MethodType.Setter)] + private static bool SetInstance() + { + Interop.Log("instance set called"); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch("platformInterface", MethodType.Getter)] + private static bool GetPlatformInterface() + { + Interop.Log("platformInterface get called"); + return false; + } + } } diff --git a/EpicRerouter/Program.cs b/EpicRerouter/Program.cs index 56e72019..0de52559 100644 --- a/EpicRerouter/Program.cs +++ b/EpicRerouter/Program.cs @@ -1,13 +1,16 @@ -using Epic.OnlineServices.Ecom; -using System; +using System; using System.Reflection; using System.Threading; +using static EntitlementsManager; namespace EpicRerouter { - public static class Program + /// + /// runs on process side + /// + internal static class Program { - public static void Main(string[] assemblyLocations) + private static void Main(string[] assemblyLocations) { try { @@ -21,7 +24,7 @@ namespace EpicRerouter { Console.WriteLine("all done"); Thread.Sleep(3000); - Environment.Exit((int)OwnershipStatus.Owned); + Environment.Exit((int)AsyncOwnershipStatus.Owned); } } } diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 11676331..58320e80 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -52,7 +52,10 @@ namespace QSB public void Awake() { - EpicRerouter.Interop.Go(); + if (true || typeof(EpicPlatformManager).Assembly.GetTypes().Any(x => x.Name == "EpicEntitlementRetriever")) + { + EpicRerouter.Interop.Go(); + } UIHelper.ReplaceUI(UITextType.PleaseUseController, "Quantum Space Buddies is best experienced with friends...");