MonoModReorg.RuntimeDetour 22.11.9-prerelease.1

This is a prerelease version of MonoModReorg.RuntimeDetour.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MonoModReorg.RuntimeDetour --version 22.11.9-prerelease.1                
NuGet\Install-Package MonoModReorg.RuntimeDetour -Version 22.11.9-prerelease.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MonoModReorg.RuntimeDetour" Version="22.11.9-prerelease.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MonoModReorg.RuntimeDetour --version 22.11.9-prerelease.1                
#r "nuget: MonoModReorg.RuntimeDetour, 22.11.9-prerelease.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MonoModReorg.RuntimeDetour as a Cake Addin
#addin nuget:?package=MonoModReorg.RuntimeDetour&version=22.11.9-prerelease.1&prerelease

// Install MonoModReorg.RuntimeDetour as a Cake Tool
#tool nuget:?package=MonoModReorg.RuntimeDetour&version=22.11.9-prerelease.1&prerelease                

Notable APIs

  • MonoMod.RuntimeDetour.Hook - An easy-to-use method hook
  • MonoMod.RuntimeDetour.ILHook - Modifies the IL of a method
  • MonoMod.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:

  1. Hook - This is effectively Detour but better. It sits as part of the same detour chain as Detour 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.
  2. 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 an ILContext 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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,983 3/23/2023
23.3.2.1 2,136 3/2/2023
23.1.2-prerelease.1 5,732 1/3/2023
22.11.21-prerelease.2 1,200 11/22/2022
22.11.21-prerelease.1 103 11/21/2022
22.11.17-prerelease.1 125 11/17/2022
22.11.9-prerelease.1 604 11/9/2022
22.11.8-prerelease.1 110 11/8/2022
22.11.8-prerelease 156 11/8/2022
22.11.4-prerelease 138 11/5/2022
22.10.25-prerelease 148 10/25/2022
22.10.21-prerelease 144 10/21/2022
22.10.11-prerelease 151 10/11/2022
22.10.6-prerelease 146 10/6/2022
22.9.29-prerelease 180 9/29/2022
22.9.23-prerelease 261 9/23/2022
22.9.14-prerelease 192 9/14/2022
22.9.7-prerelease 129 9/7/2022
22.8.29-prerelease 151 8/29/2022