MonoModReorg.RuntimeDetour
23.3.22.1
dotnet add package MonoModReorg.RuntimeDetour --version 23.3.22.1
NuGet\Install-Package MonoModReorg.RuntimeDetour -Version 23.3.22.1
<PackageReference Include="MonoModReorg.RuntimeDetour" Version="23.3.22.1" />
paket add MonoModReorg.RuntimeDetour --version 23.3.22.1
#r "nuget: MonoModReorg.RuntimeDetour, 23.3.22.1"
// Install MonoModReorg.RuntimeDetour as a Cake Addin #addin nuget:?package=MonoModReorg.RuntimeDetour&version=23.3.22.1 // Install MonoModReorg.RuntimeDetour as a Cake Tool #tool nuget:?package=MonoModReorg.RuntimeDetour&version=23.3.22.1
Notable APIs
MonoMod.RuntimeDetour.Hook
- An easy-to-use method hookMonoMod.RuntimeDetour.ILHook
- Modifies the IL of a methodMonoMod.RuntiemDetour.DetourContext
- Persistent, shared detour configuration
Basic Usage
// Create a Hook.
using (var d = new Hook(methodInfoFrom, methodInfoTo))
{
// When the detour goes out-of-scope (and thus has Dispose() called), the detour is undone.
// If the object is collected by the garbage collector, the detour is also undone.
}
Visit the GitHub and look for RuntimeDetour for more documentation.
Detour Types
There are 2 managed detour types that are available:
Hook
- This is effectivelyDetour
but better. It sits as part of the same detour chain asDetour
objects. The target of the hook may be a delegate, and so may be an instance method associated with some object. Hook targets may also take as their first parameter a delegate with a signature matching the detour source. This delegate, when called, will invoke the next detour in the chain, or the original if this is the last detour in the chain. Note: this delegate should usually only be called while the hook method is on the stack. See The Detour Chain for more information.ILHook
- This is a different kind of detour. If you're familiar with Harmony, this is effectively a transpiler. When you construct an ILHook, you provide a delegate which gets provided anILContext
which can be used to modify the IL of the method. If multiple ILHooks are present for the same method, the order the manipulators are invoked is the same as the order detours in a detour chain would be.
Each detour (Hook
or ILHook
) may have an associated DetourConfig
. Each detour config must have
an ID--this will typically be the name of the mod which applies the hook. They also have a list of IDs which
detours associated with this config will run before, and a similar list that they will run after. If some config A
wants to run before B
, and B
wants to run before A
, the resulting order is unspecified. The
MonoMod debug log will make a note of this.
Detour configs may also have a priority. Detours with any priority will execute before any without, unless one of the before or after fields caused it to be placed differently. The before and after fields take precedence over the priority field.
Any detours with no DetourConfig
get run in an arbitrary order after all those with a DetourConfig
.
The Detour Chain
All detours whose source method is the same are part of one detour chain. When the source method is called, the first detour in the chain gets called. That detour then has complete control over how that function behaves. It may, at any point, invoke the delegate (gotten from the delegate parameter to a hook method) to invoke the next detour in the chain. It may pass any parameters, and do anything with the return value.
While within the original method invocation (i.e. in the detour chain, with every prior detour on the stack), invoking the continuation delegate is safe, and will always invoke the next detour in the chain. Modifying the detour chain for a method is thread safe, and modifications will wait until all existing invocations of the detour chain exit, and all new invocations of the chain will wait until the chain modification is complete before execution. Notably, though, this means that invoking continuation delegates while the detour chain is not on the stack is not thread-safe, nor is it guaranteed to actually invoke the delegate chain as it exists at the moment of invocation. Always invoke the original method, and never delay invocation of the original delegate.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net35 is compatible. net40 was computed. net403 was computed. net45 was computed. net451 was computed. net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Mono.Cecil (>= 0.10.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
-
.NETFramework 4.5.2
- Mono.Cecil (>= 0.11.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
-
.NETStandard 2.0
- Mono.Cecil (>= 0.11.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
- System.Collections.NonGeneric (>= 4.0.0)
- System.ComponentModel.TypeConverter (>= 4.0.0)
- System.IO.FileSystem.Primitives (>= 4.0.0)
- System.Reflection.Emit.ILGeneration (>= 4.0.0)
- System.Reflection.Emit.Lightweight (>= 4.0.0)
- System.Reflection.TypeExtensions (>= 4.0.0)
-
net5.0
- Mono.Cecil (>= 0.11.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
-
net6.0
- Mono.Cecil (>= 0.11.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
-
net7.0
- Mono.Cecil (>= 0.11.4)
- MonoModReorg.Backports (>= 23.3.22.1)
- MonoModReorg.Core (>= 23.3.22.1)
- MonoModReorg.ILHelpers (>= 23.3.22.1)
- MonoModReorg.Utils (>= 23.3.22.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
23.3.22.1 | 3,996 | 3/23/2023 |
23.3.2.1 | 2,140 | 3/2/2023 |
23.1.2-prerelease.1 | 5,734 | 1/3/2023 |
22.11.21-prerelease.2 | 1,202 | 11/22/2022 |
22.11.21-prerelease.1 | 105 | 11/21/2022 |
22.11.17-prerelease.1 | 127 | 11/17/2022 |
22.11.9-prerelease.1 | 607 | 11/9/2022 |
22.11.8-prerelease.1 | 112 | 11/8/2022 |
22.11.8-prerelease | 158 | 11/8/2022 |
22.11.4-prerelease | 140 | 11/5/2022 |
22.10.25-prerelease | 150 | 10/25/2022 |
22.10.21-prerelease | 146 | 10/21/2022 |
22.10.11-prerelease | 153 | 10/11/2022 |
22.10.6-prerelease | 148 | 10/6/2022 |
22.9.29-prerelease | 182 | 9/29/2022 |
22.9.23-prerelease | 263 | 9/23/2022 |
22.9.14-prerelease | 194 | 9/14/2022 |
22.9.7-prerelease | 131 | 9/7/2022 |
22.8.29-prerelease | 153 | 8/29/2022 |