From 9b1034f7d98420c1738c17f3358875bb05e0310f Mon Sep 17 00:00:00 2001 From: Bepis <36346617+bbepis@users.noreply.github.com> Date: Sun, 8 Nov 2020 02:32:03 +1100 Subject: [PATCH] Allow base unity libraries to be given to unhollower --- BepInEx.IL2CPP/ProxyAssemblyGenerator.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/BepInEx.IL2CPP/ProxyAssemblyGenerator.cs b/BepInEx.IL2CPP/ProxyAssemblyGenerator.cs index 723bd84..205f77f 100644 --- a/BepInEx.IL2CPP/ProxyAssemblyGenerator.cs +++ b/BepInEx.IL2CPP/ProxyAssemblyGenerator.cs @@ -96,17 +96,15 @@ namespace BepInEx.IL2CPP { listener.DoPreloaderLog("Generating Il2CppUnhollower assemblies", LogLevel.Message); - if (Directory.Exists(Preloader.IL2CPPUnhollowedPath)) - Directory.Delete(Preloader.IL2CPPUnhollowedPath, true); - Directory.CreateDirectory(Preloader.IL2CPPUnhollowedPath); + foreach (var dllFile in Directory.EnumerateFiles(Preloader.IL2CPPUnhollowedPath, "*.dll", SearchOption.TopDirectoryOnly)) + File.Delete(dllFile); + string tempDumperDirectory = Path.Combine(Preloader.IL2CPPUnhollowedPath, "temp"); Directory.CreateDirectory(tempDumperDirectory); - - var dumperConfig = new Config { GenerateScript = false, @@ -130,12 +128,26 @@ namespace BepInEx.IL2CPP UnhollowerBaseLib.LogSupport.TraceHandler += s => listener.DoUnhollowerLog(s, LogLevel.Debug); UnhollowerBaseLib.LogSupport.ErrorHandler += s => listener.DoUnhollowerLog(s, LogLevel.Error); + + string unityBaseLibDir = Path.Combine(Preloader.IL2CPPUnhollowedPath, "base"); + + if (Directory.Exists(unityBaseLibDir)) + { + listener.DoPreloaderLog("Found base unity libraries", LogLevel.Debug); + } + else + { + unityBaseLibDir = null; + } + + var unhollowerOptions = new UnhollowerOptions { GameAssemblyPath = GameAssemblyPath, MscorlibPath = Path.Combine(Paths.GameRootPath, "mono", "Managed", "mscorlib.dll"), SourceDir = Path.Combine(tempDumperDirectory, "DummyDll"), - OutputDir = Preloader.IL2CPPUnhollowedPath + OutputDir = Preloader.IL2CPPUnhollowedPath, + UnityBaseLibsDir = unityBaseLibDir }; AssemblyUnhollower.Program.Main(unhollowerOptions);