Browse Source

Updated version

Began adding support for non-destructive patching
pull/46/head
Anairkoen Schno 5 years ago
parent
commit
bee1b2b371
6 changed files with 64 additions and 22 deletions
  1. +0
    -4
      IPA.Injector/Bootstrapper.cs
  2. +5
    -0
      IPA.Injector/IPA.Injector.csproj
  3. +54
    -13
      IPA.Injector/Injector.cs
  4. +2
    -2
      IPA.Injector/Properties/AssemblyInfo.cs
  5. +1
    -1
      IPA.Loader/Updating/SelfPlugin.cs
  6. +2
    -2
      IPA/Properties/AssemblyInfo.cs

+ 0
- 4
IPA.Injector/Bootstrapper.cs View File

@ -12,10 +12,6 @@ namespace IPA.Injector
void Awake()
{
//if (Environment.CommandLine.Contains("--verbose"))
//{
Windows.WinConsole.Initialize();
//}
}
void Start()


+ 5
- 0
IPA.Injector/IPA.Injector.csproj View File

@ -31,6 +31,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />


+ 54
- 13
IPA.Injector/Injector.cs View File

@ -1,4 +1,5 @@
using IPA.Loader;
using Harmony;
using IPA.Loader;
using IPA.Logging;
using System;
using System.IO;
@ -11,28 +12,68 @@ namespace IPA.Injector
{
public static class Injector
{
public static void Main(string[] args)
{ // entry point for doorstop
// At this point, literally nothing but mscorlib is loaded,
// and since this class doesn't have any static fields that
// 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();
// This loads System.Runtime.InteropServices, and Microsoft.Win32.SafeHandles.
Windows.WinConsole.Initialize();
// This will load Harmony and UnityEngine.CoreModule
InstallBootstrapPatch();
}
private static void InstallBootstrapPatch()
{
var harmony = HarmonyInstance.Create("IPA_NonDestructive_Bootstrapper");
// patch the Application static constructor to create the bootstrapper after being called
harmony.Patch(typeof(Application).TypeInitializer, null, new HarmonyMethod(typeof(Injector).GetMethod(nameof(CreateBootstrapper), BindingFlags.NonPublic | BindingFlags.Static)));
}
private static void CreateBootstrapper()
{
var bootstrapper = new GameObject("NonDestructiveBootstrapper").AddComponent<Bootstrapper>();
bootstrapper.Destroyed += Bootstrapper_Destroyed;
}
private static bool injected = false;
public static void Inject()
{
if (!injected)
{
injected = true;
Windows.WinConsole.Initialize();
SetupLibraryLoading();
var bootstrapper = new GameObject("Bootstrapper").AddComponent<Bootstrapper>();
bootstrapper.Destroyed += Bootstrapper_Destroyed;
}
}
#region Add Library load locations
AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader;
try
private static bool loadingDone = false;
public static void SetupLibraryLoading()
{
if (loadingDone) return;
loadingDone = true;
#region Add Library load locations
AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader;
try
{
if (!SetDllDirectory(LibLoader.NativeDir))
{
if (!SetDllDirectory(LibLoader.NativeDir))
{
libLoader.Warn("Unable to add native library path to load path");
}
libLoader.Warn("Unable to add native library path to load path");
}
catch (Exception) { }
#endregion
var bootstrapper = new GameObject("Bootstrapper").AddComponent<Bootstrapper>();
bootstrapper.Destroyed += Bootstrapper_Destroyed;
}
catch (Exception) { }
#endregion
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]


+ 2
- 2
IPA.Injector/Properties/AssemblyInfo.cs View File

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.10.1")]
[assembly: AssemblyFileVersion("3.10.1")]
[assembly: AssemblyVersion("3.10.2")]
[assembly: AssemblyFileVersion("3.10.2")]

+ 1
- 1
IPA.Loader/Updating/SelfPlugin.cs View File

@ -11,7 +11,7 @@ namespace IPA.Updating
internal class SelfPlugin : IBeatSaberPlugin
{
internal const string IPA_Name = "Beat Saber IPA";
internal const string IPA_Version = "3.10.1";
internal const string IPA_Version = "3.10.2";
public static SelfPlugin Instance { get; set; } = new SelfPlugin();


+ 2
- 2
IPA/Properties/AssemblyInfo.cs View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.10.1")]
[assembly: AssemblyFileVersion("3.10.1")]
[assembly: AssemblyVersion("3.10.2")]
[assembly: AssemblyFileVersion("3.10.2")]

Loading…
Cancel
Save