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; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Hamunii.DetourContext.Dispose_Fix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.9.0")] [assembly: AssemblyInformationalVersion("1.0.9+da2bc108338890f9c69505ed2097f45f4bebdfee")] [assembly: AssemblyProduct("DetourContext.Dispose_Fix")] [assembly: AssemblyTitle("Hamunii.DetourContext.Dispose_Fix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.9.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 DetourContext_Dispose_Fix { internal class Patcher { [CompilerGenerated] private static class <>O { public static Manipulator <0>__Fix_DetourContext_Dispose; } internal static ManualLogSource Logger = Logger.CreateLogSource("Hamunii.DetourContext.Dispose_Fix"); private static ILHook disposeHook = null; public static IEnumerable TargetDLLs { get; } = new string[0]; public static void Initialize() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(DetourContext), "Dispose", (Type[])null, (Type[])null); object obj = <>O.<0>__Fix_DetourContext_Dispose; if (obj == null) { Manipulator val = Fix_DetourContext_Dispose; <>O.<0>__Fix_DetourContext_Dispose = val; obj = (object)val; } disposeHook = new ILHook((MethodBase)methodInfo, (Manipulator)obj); } private static void Fix_DetourContext_Dispose(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); if (!val.TryGotoNext(new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "IsDisposed"), (Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { Logger.LogInfo((object)"Nothing to patch."); return; } val.Index += 2; val.Next.OpCode = OpCodes.Brfalse_S; } public static void Patch(AssemblyDefinition _) { } } }