From 9291da863cc87258db899149221767bede746ece Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 1 Aug 2018 22:35:37 -0500 Subject: [PATCH] Added then discovered that my updating system is obsolete --- .../BeatSaber/CompositeBSPlugin.cs | 2 + IllusionInjector/ConsoleWindow.cs | 63 +++--- IllusionInjector/IllusionInjector.csproj | 12 +- IllusionInjector/PluginComponent.cs | 7 +- IllusionInjector/PluginManager.cs | 28 ++- IllusionInjector/Updating/ModUpdater.cs | 205 ++++++++++++++++++ IllusionInjector/Updating/UpdateScript.cs | 98 +++++++++ ...ionInjector.csproj.CoreCompileInputs.cache | 2 +- IllusionInjector/packages.config | 2 +- IllusionPlugin/BeatSaber/IBeatSaberPlugin.cs | 5 + 10 files changed, 381 insertions(+), 43 deletions(-) create mode 100644 IllusionInjector/Updating/ModUpdater.cs create mode 100644 IllusionInjector/Updating/UpdateScript.cs diff --git a/IllusionInjector/BeatSaber/CompositeBSPlugin.cs b/IllusionInjector/BeatSaber/CompositeBSPlugin.cs index cc4c26c7..95587698 100644 --- a/IllusionInjector/BeatSaber/CompositeBSPlugin.cs +++ b/IllusionInjector/BeatSaber/CompositeBSPlugin.cs @@ -86,6 +86,8 @@ namespace IllusionInjector { get { throw new NotImplementedException(); } } + // public Uri UpdateUri => throw new NotImplementedException(); + public void OnLateUpdate() { Invoke(plugin => { if (plugin is IEnhancedBeatSaberPlugin) diff --git a/IllusionInjector/ConsoleWindow.cs b/IllusionInjector/ConsoleWindow.cs index ff46c0fd..6b2a1b45 100644 --- a/IllusionInjector/ConsoleWindow.cs +++ b/IllusionInjector/ConsoleWindow.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Runtime.InteropServices; using System.IO; using System.Text; +using Microsoft.Win32.SafeHandles; namespace Windows { @@ -11,39 +12,39 @@ namespace Windows { public static void CreateConsole() { - if (hasConsole) - return; - if (oldOut == IntPtr.Zero) - oldOut = GetStdHandle( -11 ); - if (! AllocConsole()) - throw new Exception("AllocConsole() failed"); - conOut = CreateFile( "CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0, IntPtr.Zero ); - if (! SetStdHandle(-11, conOut)) - throw new Exception("SetStdHandle() failed"); - StreamToConsole(); - hasConsole = true; + if (hasConsole) + return; + if (oldOut == IntPtr.Zero) + oldOut = GetStdHandle( -11 ); + if (! AllocConsole()) + throw new Exception("AllocConsole() failed"); + conOut = CreateFile( "CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0, IntPtr.Zero ); + if (! SetStdHandle(-11, conOut)) + throw new Exception("SetStdHandle() failed"); + StreamToConsole(); + hasConsole = true; } public static void ReleaseConsole() { - if (! hasConsole) - return; - if (! CloseHandle(conOut)) - throw new Exception("CloseHandle() failed"); - conOut = IntPtr.Zero; - if (! FreeConsole()) - throw new Exception("FreeConsole() failed"); - if (! SetStdHandle(-11, oldOut)) - throw new Exception("SetStdHandle() failed"); - StreamToConsole(); - hasConsole = false; + if (! hasConsole) + return; + if (! CloseHandle(conOut)) + throw new Exception("CloseHandle() failed"); + conOut = IntPtr.Zero; + if (! FreeConsole()) + throw new Exception("FreeConsole() failed"); + if (! SetStdHandle(-11, oldOut)) + throw new Exception("SetStdHandle() failed"); + StreamToConsole(); + hasConsole = false; } private static void StreamToConsole() { - Stream cstm = Console.OpenStandardOutput(); - StreamWriter cstw = new StreamWriter( cstm, Encoding.Default ); - cstw.AutoFlush = true; - Console.SetOut( cstw ); - Console.SetError( cstw ); + Stream cstm = Console.OpenStandardOutput(); + StreamWriter cstw = new StreamWriter( cstm, Encoding.Default ); + cstw.AutoFlush = true; + Console.SetOut( cstw ); + Console.SetError( cstw ); } private static bool hasConsole = false; private static IntPtr conOut; @@ -59,11 +60,11 @@ namespace Windows [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)] private static extern IntPtr CreateFile( string fileName, - int desiredAccess, - int shareMode, + int desiredAccess, + int shareMode, IntPtr securityAttributes, - int creationDisposition, - int flagsAndAttributes, + int creationDisposition, + int flagsAndAttributes, IntPtr templateFile ); [DllImport("kernel32.dll", ExactSpelling=true, SetLastError=true)] private static extern bool CloseHandle(IntPtr handle); diff --git a/IllusionInjector/IllusionInjector.csproj b/IllusionInjector/IllusionInjector.csproj index 9fae63a3..460cdc30 100644 --- a/IllusionInjector/IllusionInjector.csproj +++ b/IllusionInjector/IllusionInjector.csproj @@ -34,8 +34,8 @@ false - - ..\packages\Ionic.Zlib.1.9.1.5\lib\Ionic.Zlib.dll + + ..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll @@ -48,6 +48,10 @@ ..\Libs\UnityEngine.CoreModule.dll False + + ..\..\..\..\..\..\Game Library\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll + False + @@ -64,6 +68,9 @@ + + + @@ -74,6 +81,7 @@ +