diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj
index e6d8eee50..c49823c6a 100644
--- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj
+++ b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj
@@ -38,8 +38,8 @@
-
-
+
+
diff --git a/Directory.Build.props b/Directory.Build.props
index c9adbd472..5773937b5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -49,8 +49,10 @@
6.2.0
7.0.1
22.7.31.1
+ 25.0.11
+ 25.3.3
0.11.6
- 2.10.2
+ 2.16.0
3.0.4
3.2.0
6.0.0-beta.5
diff --git a/MelonLoader/Attributes/PatchShield.cs b/MelonLoader/Attributes/PatchShield.cs
index 3a377f9ff..183364a73 100644
--- a/MelonLoader/Attributes/PatchShield.cs
+++ b/MelonLoader/Attributes/PatchShield.cs
@@ -50,13 +50,20 @@ internal static void Install()
}
catch (Exception ex) { LogException(ex); }
- Hook.OnDetour += (detour, originalMethod, patchMethod, delegateTarget) => MethodCheck(originalMethod);
- ILHook.OnDetour += (detour, originalMethod, ilmanipulator) => MethodCheck(originalMethod);
- Detour.OnDetour += (detour, originalMethod, patchMethod) => MethodCheck(originalMethod);
+ try
+ {
+ Core.HarmonyInstance.Patch(AccessTools.Method(typeof(Hook), "Apply"),
+ AccessTools.Method(patchShieldType, "PatchMethod_Hook_Apply").ToNewHarmonyMethod());
+ Core.HarmonyInstance.Patch(AccessTools.Method(typeof(ILHook), "Apply"),
+ AccessTools.Method(patchShieldType, "PatchMethod_ILHook_Apply").ToNewHarmonyMethod());
+ }
+ catch (Exception ex) { LogException(ex); }
}
private static bool PatchMethod_PatchFunctions_ReversePatch(MethodBase __1) => MethodCheck(__1);
private static bool PatchMethod_PatchProcessor_Patch(PatchProcessor __instance) => MethodCheck(PatchProcessor_OriginalRef(__instance));
private static bool PatchMethod_PatchProcessor_Unpatch(PatchProcessor __instance) => MethodCheck(PatchProcessor_OriginalRef(__instance));
+ private static bool PatchMethod_Hook_Apply(Hook __instance) => MethodCheck(__instance.Source);
+ private static bool PatchMethod_ILHook_Apply(ILHook __instance) => MethodCheck(__instance.Method);
}
}
\ No newline at end of file
diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs
index ed5f6dae5..8b154d16b 100644
--- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs
+++ b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs
@@ -44,7 +44,6 @@
[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyGlobalSettings))]
[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyMethod))]
[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyMethodExtensions))]
-[assembly: TypeForwardedTo(typeof(HarmonyLib.InlineSignature))]
[assembly: TypeForwardedTo(typeof(HarmonyLib.PatchInfo))]
[assembly: TypeForwardedTo(typeof(HarmonyLib.Patch))]
[assembly: TypeForwardedTo(typeof(HarmonyLib.PatchClassProcessor))]
diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs
deleted file mode 100644
index 4397566e5..000000000
--- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourConfig))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Detour))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Detour<>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourContext))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourModManager))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HarmonyDetourBridge))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HookConfig))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook<>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook<,>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetour))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ISortableDetour))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ILHookConfig))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ILHook))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetourConfig))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetour))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourHelper))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetourNativePlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetourRuntimePlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.OnMethodCompiledEvent))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetourData))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeARMPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeWindowsPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeX86Platform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNET50Platform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNET60Platform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCore30Platform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HookGen.HookEndpointManager))]
diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs
deleted file mode 100644
index dcfcac562..000000000
--- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: TypeForwardedTo(typeof(IgnoresAccessChecksToAttribute))]
-[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModExportNameAttribute))]
-[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModImportNameAttribute))]
-[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModInteropManager))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynData<>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Extensions))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.FastReflectionDelegate))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.FastReflectionHelper))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GenericMethodInstantiationComparer))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GenericTypeInstantiationComparer))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.LazyDisposable))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.LazyDisposable<>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDGenerator<>))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDCecilGenerator))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDEmitDynamicMethodGenerator))]
-#if !NET6_0
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDEmitMethodBuilderGenerator))]
-#endif
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodDefinition))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodHelper))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodReference))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDll))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDllImportAttribute))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDllMapping))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Relinker))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GCListener))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.ICallSiteGenerator))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.MMReflectionImporter))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Platform))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.PlatformHelper))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.ReflectionHelper))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.RelinkFailedException))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.RelinkTargetNotFoundException))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.WeakReferenceComparer))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.CecilILGenerator))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.ILGeneratorShim))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.ILGeneratorShimExt))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILContext))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.MoveType))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.SearchTarget))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILCursor))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILLabel))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILPatternMatchingExt))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.IILReferenceBag))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.NopILReferenceBag))]
-[assembly: TypeForwardedTo(typeof(MonoMod.Cil.RuntimeILReferenceBag))]
diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs
index 536776136..c30e2c662 100644
--- a/MelonLoader/Core.cs
+++ b/MelonLoader/Core.cs
@@ -1,16 +1,11 @@
using System;
using System.Diagnostics;
-using System.Reflection;
-using System.IO;
using bHapticsLib;
using System.Threading;
-using HarmonyLib;
using MelonLoader.Resolver;
using MelonLoader.Utils;
using MelonLoader.InternalUtils;
using MelonLoader.Melons;
-using MonoMod.RuntimeDetour;
-using MonoMod.RuntimeDetour.Platforms;
[assembly: MelonLoader.PatchShield]
@@ -54,14 +49,6 @@ internal static int Initialize()
Assertions.LemonAssertMapping.Setup();
HarmonyLogger.Setup();
-#if !WINDOWS && !NET6_0_OR_GREATER
- // Using Process.Start can run Console..cctor
- // Since MonoMod's PlatformHelper (used by DetourHelper.Native) runs Process.Start to determine ARM/x86
- // platform, this causes the unpatched TermInfoReader to kick in before it can be patched and fixed when
- // installing the XTermFix below. To work around this, we can force the platform directly
- DetourHelper.Native = new DetourNativeMonoPosixPlatform(new DetourNativeX86Platform());
-#endif
-
HarmonyInstance = new HarmonyLib.Harmony(Properties.BuildInfo.Name);
#if !WINDOWS && !NET6_0_OR_GREATER
diff --git a/MelonLoader/Fixes/Harmony/InstancePatchFix.cs b/MelonLoader/Fixes/Harmony/InstancePatchFix.cs
index e88871f81..8ddecdd87 100644
--- a/MelonLoader/Fixes/Harmony/InstancePatchFix.cs
+++ b/MelonLoader/Fixes/Harmony/InstancePatchFix.cs
@@ -19,8 +19,12 @@ internal static void Install()
}
catch (Exception ex) { MelonLogger.Warning(ex); }
- Hook.OnDetour += (detour, originalMethod, patchMethod, delegateTarget) => PatchMethod(patchMethod);
- Detour.OnDetour += (detour, originalMethod, patchMethod) => PatchMethod(patchMethod);
+ try
+ {
+ Core.HarmonyInstance.Patch(AccessTools.Method(typeof(Hook), "Apply"),
+ AccessTools.Method(instancePatchFixType, "PatchHookApply").ToNewHarmonyMethod());
+ }
+ catch (Exception ex) { MelonLogger.Warning(ex); }
}
private static bool PatchMethod(MethodBase __0)
@@ -31,5 +35,7 @@ private static bool PatchMethod(MethodBase __0)
throw new Exception("Patch Method must be a Static Method!");
return true;
}
+
+ private static bool PatchHookApply(Hook __instance) => PatchMethod(__instance.Target);
}
}
\ No newline at end of file
diff --git a/MelonLoader/Fixes/Il2CppInterop/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppInterop/Il2CppICallInjector.cs
index 9290894a7..6cff23b00 100644
--- a/MelonLoader/Fixes/Il2CppInterop/Il2CppICallInjector.cs
+++ b/MelonLoader/Fixes/Il2CppInterop/Il2CppICallInjector.cs
@@ -1,7 +1,7 @@
#if NET6_0_OR_GREATER
using MelonLoader.NativeUtils;
-using MonoMod.RuntimeDetour;
+using MonoMod.Core.Platforms;
using MonoMod.Utils;
using System;
using System.Collections.Generic;
@@ -272,8 +272,10 @@ private static (object, DynamicMethodDefinition, MethodInfo, IntPtr) GenerateTra
return (null, null, null, IntPtr.Zero);
// Return the New Method
- MethodInfo newMethod = trampoline.Generate().Pin();
- return (patcher, trampoline, newMethod, newMethod.GetNativeStart());
+ var triple = PlatformTriple.Current;
+ MethodInfo newMethod = trampoline.Generate();
+ triple.PinMethodIfNeeded(newMethod);
+ return (patcher, trampoline, newMethod, triple.Runtime.GetMethodEntryPoint(newMethod));
}
}
}
diff --git a/MelonLoader/Fixes/Il2CppInterop/Il2CppInteropFixes.cs b/MelonLoader/Fixes/Il2CppInterop/Il2CppInteropFixes.cs
index e760d8252..ec3e20a9a 100644
--- a/MelonLoader/Fixes/Il2CppInterop/Il2CppInteropFixes.cs
+++ b/MelonLoader/Fixes/Il2CppInterop/Il2CppInteropFixes.cs
@@ -1,4 +1,6 @@
#if NET6_0_OR_GREATER
+extern alias Iced;
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,14 +14,13 @@
using Il2CppInterop.Runtime.Runtime;
using Il2CppInterop.Runtime.Runtime.VersionSpecific.Class;
using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo;
-using Il2CppInterop.Runtime.Runtime.VersionSpecific.Type;
using HarmonyLib;
using Il2CppInterop.Generator.Contexts;
using AsmResolver.DotNet;
using Il2CppInterop.HarmonySupport;
-using Iced.Intel;
using Il2CppInterop.Common.XrefScans;
-using FlowControl = Iced.Intel.FlowControl;
+using Iced::Iced.Intel;
+using FlowControl = Iced::Iced.Intel.FlowControl;
#pragma warning disable CS8632
diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj
index ca011e4d4..d298d3a97 100644
--- a/MelonLoader/MelonLoader.csproj
+++ b/MelonLoader/MelonLoader.csproj
@@ -33,8 +33,8 @@
-
-
+
+
@@ -56,7 +56,7 @@
-
+