From ac1cbd8c428f44b4b487531465c77b39308210d2 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Tue, 22 Oct 2019 19:26:30 -0500 Subject: [PATCH] Added a level of indirection in the injector for safety loading shipped libraries --- IPA.Injector/Injector.cs | 8 +++++++- IPA.Loader/Loader/LibLoader.cs | 6 +++--- IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 52404fd1..ecefca57 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -96,7 +96,7 @@ namespace IPA.Injector GameVersionEarly.Load(); - HarmonyProtector.Protect(); + InstallHarmonyProtections(); pluginAsyncLoadTask = PluginLoader.LoadTask(); permissionFixTask = PermissionFix.FixPermissions(new DirectoryInfo(Environment.CurrentDirectory)); @@ -104,6 +104,7 @@ namespace IPA.Injector catch (Exception e) { Console.WriteLine(e); + throw; } } @@ -123,6 +124,11 @@ namespace IPA.Injector LibLoader.Configure(); } + private static void InstallHarmonyProtections() + { // proxy function to delay resolution + HarmonyProtector.Protect(); + } + private static void InstallBootstrapPatch() { var cAsmName = Assembly.GetExecutingAssembly().GetName(); diff --git a/IPA.Loader/Loader/LibLoader.cs b/IPA.Loader/Loader/LibLoader.cs index 01b23a3d..ea565220 100644 --- a/IPA.Loader/Loader/LibLoader.cs +++ b/IPA.Loader/Loader/LibLoader.cs @@ -47,9 +47,9 @@ namespace IPA.Loader internal static void Configure() { + SetupAssemblyFilenames(true); AppDomain.CurrentDomain.AssemblyResolve -= AssemblyLibLoader; AppDomain.CurrentDomain.AssemblyResolve += AssemblyLibLoader; - SetupAssemblyFilenames(true); } internal static void SetupAssemblyFilenames(bool force = false) @@ -93,8 +93,8 @@ namespace IPA.Loader }).All(f => true); // force it to iterate all } - var unityData = Directory.EnumerateDirectories(Environment.CurrentDirectory, "*_Data").First(); - AddDir(Path.Combine(unityData, "Plugins")); + //var unityData = Directory.EnumerateDirectories(Environment.CurrentDirectory, "*_Data").First(); + //AddDir(Path.Combine(unityData, "Plugins")); foreach (var dir in Environment.GetEnvironmentVariable("path").Split(Path.PathSeparator)) AddDir(dir); diff --git a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache b/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache deleted file mode 100644 index f8d3f98f..00000000 --- a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache +++ /dev/null @@ -1 +0,0 @@ -cc86aa342ebce00fb3a7de08cdd743019e060632