diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..65cb0e99 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Doorstop"] + path = Doorstop + url = https://github.com/NeighTools/UnityDoorstop.git diff --git a/BSIPA.sln b/BSIPA.sln index 34c5c3a7..cb99673e 100644 --- a/BSIPA.sln +++ b/BSIPA.sln @@ -17,32 +17,162 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPA.Loader", "IPA.Loader\IP EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPA.Injector", "IPA.Injector\IPA.Injector.csproj", "{2A1AF16B-27F1-46E0-9A95-181516BC1CB7}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy", "Doorstop\Proxy\Proxy.vcxproj", "{88609E16-731F-46C9-8139-6B1A7A83240D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + Verbose_Release|Any CPU = Verbose_Release|Any CPU + Verbose_Release|x64 = Verbose_Release|x64 + Verbose_Release|x86 = Verbose_Release|x86 + Verbose|Any CPU = Verbose|Any CPU + Verbose|x64 = Verbose|x64 + Verbose|x86 = Verbose|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|x64.ActiveCfg = Debug|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|x64.Build.0 = Debug|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|x86.ActiveCfg = Debug|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|x86.Build.0 = Debug|Any CPU {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|Any CPU.ActiveCfg = Release|Any CPU {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|Any CPU.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|x64.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|x64.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|x86.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Release|x86.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|x64.ActiveCfg = Verbose_Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|x64.Build.0 = Verbose_Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|x86.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose_Release|x86.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|Any CPU.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|Any CPU.Build.0 = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|x64.ActiveCfg = Verbose|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|x64.Build.0 = Verbose|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|x86.ActiveCfg = Release|Any CPU + {14092533-98BB-40A4-9AFC-27BB75672A70}.Verbose|x86.Build.0 = Release|Any CPU {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|x64.ActiveCfg = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|x64.Build.0 = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|x86.ActiveCfg = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Debug|x86.Build.0 = Debug|Any CPU {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Release|Any CPU.ActiveCfg = Release|Any CPU {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Release|Any CPU.Build.0 = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Release|x64.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Release|x86.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Release|x86.Build.0 = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose_Release|x64.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose_Release|x86.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose_Release|x86.Build.0 = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|Any CPU.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|Any CPU.Build.0 = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|x64.ActiveCfg = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|x64.Build.0 = Debug|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|x86.ActiveCfg = Release|Any CPU + {C66092B0-5C1E-44E9-B524-E0E8E1425379}.Verbose|x86.Build.0 = Release|Any CPU {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|x64.ActiveCfg = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|x64.Build.0 = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|x86.ActiveCfg = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Debug|x86.Build.0 = Debug|Any CPU {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|Any CPU.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|x64.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|x64.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|x86.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Release|x86.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|x64.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|x64.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|x86.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose_Release|x86.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|Any CPU.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|Any CPU.Build.0 = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|x64.ActiveCfg = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|x64.Build.0 = Debug|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|x86.ActiveCfg = Release|Any CPU + {F08C3C7A-3221-432E-BAB8-32BCE58408C8}.Verbose|x86.Build.0 = Release|Any CPU {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|x64.ActiveCfg = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|x64.Build.0 = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|x86.ActiveCfg = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Debug|x86.Build.0 = Debug|Any CPU {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|Any CPU.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|x64.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|x64.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|x86.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Release|x86.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|x64.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|x64.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|x86.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose_Release|x86.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|Any CPU.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|Any CPU.Build.0 = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|x64.ActiveCfg = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|x64.Build.0 = Debug|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|x86.ActiveCfg = Release|Any CPU + {5AD344F0-01A0-4CA8-92E5-9D095737744D}.Verbose|x86.Build.0 = Release|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|x64.ActiveCfg = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|x64.Build.0 = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|x86.ActiveCfg = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Debug|x86.Build.0 = Debug|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|Any CPU.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|x64.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|x64.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|x86.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Release|x86.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|x64.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|x64.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|x86.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose_Release|x86.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|Any CPU.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|Any CPU.Build.0 = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x64.ActiveCfg = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x64.Build.0 = Debug|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.ActiveCfg = Release|Any CPU + {2A1AF16B-27F1-46E0-9A95-181516BC1CB7}.Verbose|x86.Build.0 = Release|Any CPU + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.ActiveCfg = Debug|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x64.Build.0 = Debug|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.ActiveCfg = Debug|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Debug|x86.Build.0 = Debug|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|Any CPU.ActiveCfg = Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|x64.ActiveCfg = Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|x64.Build.0 = Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|x86.ActiveCfg = Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Release|x86.Build.0 = Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|Any CPU.ActiveCfg = Verbose_Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x64.ActiveCfg = Verbose_Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x64.Build.0 = Verbose_Release|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x86.ActiveCfg = Verbose_Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose_Release|x86.Build.0 = Verbose_Release|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|Any CPU.ActiveCfg = Verbose|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.ActiveCfg = Verbose|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.Build.0 = Verbose|x64 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.ActiveCfg = Verbose|Win32 + {88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.Build.0 = Verbose|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Doorstop b/Doorstop new file mode 160000 index 00000000..563b4d70 --- /dev/null +++ b/Doorstop @@ -0,0 +1 @@ +Subproject commit 563b4d704eef6d96528b8940306ac25ead715594 diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index d1fcd727..f920a78d 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -19,17 +19,24 @@ namespace IPA.Injector // aren't defined in mscorlib, we can control exactly what // gets loaded. - // This loads AppDomain, System.IO, System.Collections.Generic, and System.Reflection. - // If kernel32.dll is not already loaded, this will also load it. - // This call also loads IPA.Loader and initializes the logging system. In the process - // it loads Ionic.Zip. - SetupLibraryLoading(); + try + { + // This loads System.Runtime.InteropServices, and Microsoft.Win32.SafeHandles. + Windows.WinConsole.Initialize(); - // This loads System.Runtime.InteropServices, and Microsoft.Win32.SafeHandles. - Windows.WinConsole.Initialize(); + // This loads AppDomain, System.IO, System.Collections.Generic, and System.Reflection. + // If kernel32.dll is not already loaded, this will also load it. + // This call also loads IPA.Loader and initializes the logging system. In the process + // it loads Ionic.Zip. + SetupLibraryLoading(); - // This will load Harmony and UnityEngine.CoreModule - InstallBootstrapPatch(); + // This will load Harmony and UnityEngine.CoreModule + InstallBootstrapPatch(); + } + catch (Exception e) + { + Console.WriteLine(e); + } } private static void InstallBootstrapPatch() diff --git a/IPA/IPA.csproj b/IPA/IPA.csproj index 9cbd7948..105fa46f 100644 --- a/IPA/IPA.csproj +++ b/IPA/IPA.csproj @@ -28,6 +28,8 @@ false false true + + AnyCPU @@ -39,6 +41,7 @@ prompt 4 false + Debug AnyCPU @@ -50,6 +53,7 @@ 4 false true + Release favicon.ico @@ -60,6 +64,20 @@ false + + true + bin\Verbose\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + Debug + + + bin\Verbose_Release\ + Release + @@ -106,6 +124,11 @@ false + + + diff --git a/IPA/Program.cs b/IPA/Program.cs index 9a7befc1..28b5fd50 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -31,11 +31,12 @@ namespace IPA public static ArgumentFlag ArgNoWait = new ArgumentFlag("--nowait", "-n") { DocString = "doesn't wait for user input after the operation" }; public static ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses value as arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" }; public static ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" }; + public static ArgumentFlag ArgDestructive = new ArgumentFlag("--destructive", "-d") { DocString = "patches the game using the now outdated destructive methods" }; [STAThread] static void Main(string[] args) { - Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch).Process(); + Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgDestructive).Process(); if (ArgHelp) { @@ -132,35 +133,115 @@ namespace IPA { var backup = new BackupUnit(context); - #region Patch Version Check + if (ArgDestructive) + { + #region Patch Version Check - var patchedModule = PatchedModule.Load(context.EngineFile); + var patchedModule = PatchedModule.Load(context.EngineFile); #if DEBUG - var isCurrentNewer = Version.CompareTo(patchedModule.Data.Version) >= 0; + var isCurrentNewer = Version.CompareTo(patchedModule.Data.Version) >= 0; #else - var isCurrentNewer = Version.CompareTo(patchedModule.Data.Version) > 0; + var isCurrentNewer = Version.CompareTo(patchedModule.Data.Version) > 0; #endif - Console.WriteLine($"Current: {Version} Patched: {patchedModule.Data.Version}"); - if (isCurrentNewer) + Console.WriteLine($"Current: {Version} Patched: {patchedModule.Data.Version}"); + if (isCurrentNewer) + { + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine( + $"Preparing for update, {(patchedModule.Data.Version == null ? "UnPatched" : patchedModule.Data.Version.ToString())} => {Version}"); + Console.WriteLine("--- Starting ---"); + Revert(context); + Console.ResetColor(); + + #region File Copying + + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("Updating files... "); + var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins"); + bool isFlat = Directory.Exists(nativePluginFolder) && + Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll")); + bool force = !BackupManager.HasBackup(context) || ArgForce; + var architecture = DetectArchitecture(context.Executable); + + Console.WriteLine("Architecture: {0}", architecture); + + CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force, + backup, + (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, + architecture)); + CopyAll(new DirectoryInfo(context.LibsPathSrc), new DirectoryInfo(context.LibsPathDst), force, + backup, + (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, + architecture)); + + Console.WriteLine("Successfully updated files!"); + + #endregion + } + else + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Files up to date @ Version {Version}!"); + Console.ResetColor(); + } + + #endregion + + #region Patching + + if (!patchedModule.Data.IsPatched || isCurrentNewer) + { + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine($"Patching UnityEngine.dll with Version {Application.ProductVersion}... "); + backup.Add(context.EngineFile); + patchedModule.Patch(Version); + Console.WriteLine("Done!"); + Console.ResetColor(); + } + + #endregion + + #region Creating shortcut + if (!File.Exists(context.ShortcutPath)) + { + Console.ForegroundColor = ConsoleColor.DarkGreen; + Console.WriteLine("Creating shortcut to IPA ({0})... ", context.IPA); + try + { + Shortcut.Create( + fileName: context.ShortcutPath, + targetPath: context.IPA, + arguments: Args(context.Executable, "-ln"), + workingDirectory: context.ProjectRoot, + description: "Launches the game and makes sure it's in a patched state", + hotkey: "", + iconPath: context.Executable + ); + } + catch (Exception) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.Error.WriteLine("Failed to create shortcut, but game was patched!"); + } + Console.ResetColor(); + } + #endregion + } + else { - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine( - $"Preparing for update, {(patchedModule.Data.Version == null ? "UnPatched" : patchedModule.Data.Version.ToString())} => {Version}"); - Console.WriteLine("--- Starting ---"); - Revert(context); - Console.ResetColor(); - - #region File Copying + Console.ForegroundColor = ConsoleColor.Blue; + Console.WriteLine("Restoring old version... "); + if (BackupManager.HasBackup(context)) + BackupManager.Restore(context); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("Updating files... "); var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins"); bool isFlat = Directory.Exists(nativePluginFolder) && Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll")); bool force = !BackupManager.HasBackup(context) || ArgForce; var architecture = DetectArchitecture(context.Executable); - Console.WriteLine("Architecture: {0}", architecture); + Console.ForegroundColor = ConsoleColor.DarkCyan; + Console.WriteLine("Installing files... "); CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force, backup, @@ -170,20 +251,11 @@ namespace IPA backup, (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, architecture)); - - Console.WriteLine("Successfully updated files!"); - - #endregion - } - else - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"Files up to date @ Version {Version}!"); - Console.ResetColor(); + CopyAll(new DirectoryInfo(context.IPARoot), new DirectoryInfo(context.ProjectRoot), force, + backup, + null, false); } - #endregion - #region Create Plugin Folder if (!Directory.Exists(context.PluginsFolder)) @@ -196,20 +268,6 @@ namespace IPA #endregion - #region Patching - - if (!patchedModule.Data.IsPatched || isCurrentNewer) - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine($"Patching UnityEngine.dll with Version {Application.ProductVersion}... "); - backup.Add(context.EngineFile); - patchedModule.Patch(Version); - Console.WriteLine("Done!"); - Console.ResetColor(); - } - - #endregion - #region Virtualizing if (File.Exists(context.AssemblyFile)) @@ -228,31 +286,6 @@ namespace IPA #endregion - #region Creating shortcut - if (!File.Exists(context.ShortcutPath)) - { - Console.ForegroundColor = ConsoleColor.DarkGreen; - Console.WriteLine("Creating shortcut to IPA ({0})... ", context.IPA); - try - { - Shortcut.Create( - fileName: context.ShortcutPath, - targetPath: context.IPA, - arguments: Args(context.Executable, "-ln"), - workingDirectory: context.ProjectRoot, - description: "Launches the game and makes sure it's in a patched state", - hotkey: "", - iconPath: context.Executable - ); - } - catch (Exception) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.Error.WriteLine("Failed to create shortcut, but game was patched!"); - } - Console.ResetColor(); - } - #endregion } catch (Exception e) { @@ -372,7 +405,7 @@ namespace IPA } public static void CopyAll(DirectoryInfo source, DirectoryInfo target, bool aggressive, BackupUnit backup, - Func> interceptor = null) + Func> interceptor = null, bool recurse = true) { if (interceptor == null) { @@ -398,11 +431,12 @@ namespace IPA } // Copy each subdirectory using recursion. - foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) - { - DirectoryInfo nextTargetSubDir = new DirectoryInfo(Path.Combine(target.FullName, diSourceSubDir.Name)); - CopyAll(diSourceSubDir, nextTargetSubDir, aggressive, backup, interceptor); - } + if (recurse) + foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) + { + DirectoryInfo nextTargetSubDir = new DirectoryInfo(Path.Combine(target.FullName, diSourceSubDir.Name)); + CopyAll(diSourceSubDir, nextTargetSubDir, aggressive, backup, interceptor, recurse); + } }