Decompiled source of OmegaProject02 v1.0.0

patchers/AdvancedCompany.Preloader.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AdvancedCompany.Preloader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AdvancedCompany.Preloader")]
[assembly: AssemblyTitle("AdvancedCompany.Preloader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AdvancedCompany.Preloader
{
	public static class Patcher
	{
		public static ManualLogSource Log;

		private static Dictionary<string, string> CrippleAssemblies = new Dictionary<string, string>
		{
			{ "LateCompany", "LateCompany.Plugin" },
			{ "ShipLobby", "ShipLobby.ShipLobby" }
		};

		public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "abc" };


		public static void Initialize()
		{
			Log = Logger.CreateLogSource("AdvancedCompanyPreloader");
			AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
		}

		private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			Harmony val = new Harmony("AdvancedCompany");
			Assembly loadedAssembly = args.LoadedAssembly;
			foreach (KeyValuePair<string, string> crippleAssembly in CrippleAssemblies)
			{
				if (!loadedAssembly.FullName.StartsWith(crippleAssembly.Key))
				{
					continue;
				}
				Log.LogMessage((object)("BepInEx is loading " + crippleAssembly.Key + "..."));
				Type[] types = loadedAssembly.GetTypes();
				HarmonyMethod val2 = new HarmonyMethod(typeof(Patcher).GetMethod("Cripple", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
				Type[] array = types;
				foreach (Type type in array)
				{
					if (!(type.FullName == crippleAssembly.Value))
					{
						continue;
					}
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
					MethodInfo[] array2 = methods;
					foreach (MethodInfo methodInfo in array2)
					{
						if (methodInfo.Name == "Awake")
						{
							Log.LogMessage((object)("Removing Awake from " + crippleAssembly.Key + "! Successfully prevented " + crippleAssembly.Key + " from loading."));
							try
							{
								val.Patch((MethodBase)methodInfo, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							}
							catch (Exception)
							{
							}
						}
					}
				}
			}
		}

		private static bool Cripple()
		{
			return false;
		}

		public static void Patch(AssemblyDefinition assembly)
		{
		}
	}
}