|
@ -1,4 +1,6 @@ |
|
|
using IPA.Config; |
|
|
|
|
|
|
|
|
#nullable enable |
|
|
|
|
|
using IPA.AntiMalware; |
|
|
|
|
|
using IPA.Config; |
|
|
using IPA.Injector.Backups; |
|
|
using IPA.Injector.Backups; |
|
|
using IPA.Loader; |
|
|
using IPA.Loader; |
|
|
using IPA.Logging; |
|
|
using IPA.Logging; |
|
@ -29,8 +31,8 @@ namespace IPA.Injector |
|
|
// ReSharper disable once UnusedMember.Global
|
|
|
// ReSharper disable once UnusedMember.Global
|
|
|
internal static class Injector |
|
|
internal static class Injector |
|
|
{ |
|
|
{ |
|
|
private static Task pluginAsyncLoadTask; |
|
|
|
|
|
private static Task permissionFixTask; |
|
|
|
|
|
|
|
|
private static Task? pluginAsyncLoadTask; |
|
|
|
|
|
private static Task? permissionFixTask; |
|
|
//private static string otherNewtonsoftJson = null;
|
|
|
//private static string otherNewtonsoftJson = null;
|
|
|
|
|
|
|
|
|
// ReSharper disable once UnusedParameter.Global
|
|
|
// ReSharper disable once UnusedParameter.Global
|
|
@ -40,7 +42,7 @@ namespace IPA.Injector |
|
|
// and since this class doesn't have any static fields that
|
|
|
// and since this class doesn't have any static fields that
|
|
|
// aren't defined in mscorlib, we can control exactly what
|
|
|
// aren't defined in mscorlib, we can control exactly what
|
|
|
// gets loaded.
|
|
|
// gets loaded.
|
|
|
|
|
|
|
|
|
|
|
|
_ = args; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
if (Environment.GetCommandLineArgs().Contains("--verbose")) |
|
|
if (Environment.GetCommandLineArgs().Contains("--verbose")) |
|
@ -48,16 +50,6 @@ namespace IPA.Injector |
|
|
|
|
|
|
|
|
SetupLibraryLoading(); |
|
|
SetupLibraryLoading(); |
|
|
|
|
|
|
|
|
/*var otherNewtonsoft = Path.Combine( |
|
|
|
|
|
Directory.EnumerateDirectories(Environment.CurrentDirectory, "*_Data").First(), |
|
|
|
|
|
"Managed", |
|
|
|
|
|
"Newtonsoft.Json.dll"); |
|
|
|
|
|
if (File.Exists(otherNewtonsoft)) |
|
|
|
|
|
{ // this game ships its own Newtonsoft; force load ours and flag loading theirs
|
|
|
|
|
|
LibLoader.LoadLibrary(new AssemblyName("Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed")); |
|
|
|
|
|
otherNewtonsoftJson = otherNewtonsoft; |
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
EnsureDirectories(); |
|
|
EnsureDirectories(); |
|
|
|
|
|
|
|
|
// this is weird, but it prevents Mono from having issues loading the type.
|
|
|
// this is weird, but it prevents Mono from having issues loading the type.
|
|
@ -93,6 +85,9 @@ namespace IPA.Injector |
|
|
|
|
|
|
|
|
GameVersionEarly.Load(); |
|
|
GameVersionEarly.Load(); |
|
|
|
|
|
|
|
|
|
|
|
// load the anti-malware engine
|
|
|
|
|
|
_ = AntiMalwareEngine.Engine; |
|
|
|
|
|
|
|
|
Updates.InstallPendingUpdates(); |
|
|
Updates.InstallPendingUpdates(); |
|
|
|
|
|
|
|
|
LibLoader.SetupAssemblyFilenames(true); |
|
|
LibLoader.SetupAssemblyFilenames(true); |
|
@ -110,9 +105,9 @@ namespace IPA.Injector |
|
|
{ |
|
|
{ |
|
|
string path; |
|
|
string path; |
|
|
if (!Directory.Exists(path = Path.Combine(Environment.CurrentDirectory, "UserData"))) |
|
|
if (!Directory.Exists(path = Path.Combine(Environment.CurrentDirectory, "UserData"))) |
|
|
Directory.CreateDirectory(path); |
|
|
|
|
|
|
|
|
_ = Directory.CreateDirectory(path); |
|
|
if (!Directory.Exists(path = Path.Combine(Environment.CurrentDirectory, "Plugins"))) |
|
|
if (!Directory.Exists(path = Path.Combine(Environment.CurrentDirectory, "Plugins"))) |
|
|
Directory.CreateDirectory(path); |
|
|
|
|
|
|
|
|
_ = Directory.CreateDirectory(path); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static void SetupLibraryLoading() |
|
|
private static void SetupLibraryLoading() |
|
@ -184,7 +179,7 @@ namespace IPA.Injector |
|
|
goto endPatchCoreModule; |
|
|
goto endPatchCoreModule; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
MethodDefinition cctor = null; |
|
|
|
|
|
|
|
|
MethodDefinition? cctor = null; |
|
|
foreach (var m in application.Methods) |
|
|
foreach (var m in application.Methods) |
|
|
if (m.IsRuntimeSpecialName && m.Name == ".cctor") |
|
|
if (m.IsRuntimeSpecialName && m.Name == ".cctor") |
|
|
cctor = m; |
|
|
cctor = m; |
|
@ -311,9 +306,6 @@ namespace IPA.Injector |
|
|
if (bootstrapped) return; |
|
|
if (bootstrapped) return; |
|
|
bootstrapped = true; |
|
|
bootstrapped = true; |
|
|
|
|
|
|
|
|
/*if (otherNewtonsoftJson != null) |
|
|
|
|
|
Assembly.LoadFrom(otherNewtonsoftJson);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type) |
|
|
Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type) |
|
|
{ |
|
|
{ |
|
@ -336,12 +328,12 @@ namespace IPA.Injector |
|
|
private static void Bootstrapper_Destroyed() |
|
|
private static void Bootstrapper_Destroyed() |
|
|
{ |
|
|
{ |
|
|
// wait for plugins to finish loading
|
|
|
// wait for plugins to finish loading
|
|
|
pluginAsyncLoadTask.Wait(); |
|
|
|
|
|
permissionFixTask.Wait(); |
|
|
|
|
|
|
|
|
pluginAsyncLoadTask?.Wait(); |
|
|
|
|
|
permissionFixTask?.Wait(); |
|
|
|
|
|
|
|
|
log.Debug("Plugins loaded"); |
|
|
log.Debug("Plugins loaded"); |
|
|
log.Debug(string.Join(", ", PluginLoader.PluginsMetadata.StrJP())); |
|
|
log.Debug(string.Join(", ", PluginLoader.PluginsMetadata.StrJP())); |
|
|
PluginComponent.Create(); |
|
|
|
|
|
|
|
|
_ = PluginComponent.Create(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |