MonoMod.RuntimeDetour
25.0.0-prerelease.2
See the version list below for details.
dotnet add package MonoMod.RuntimeDetour --version 25.0.0-prerelease.2
NuGet\Install-Package MonoMod.RuntimeDetour -Version 25.0.0-prerelease.2
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.0.0-prerelease.2" />
paket add MonoMod.RuntimeDetour --version 25.0.0-prerelease.2
#r "nuget: MonoMod.RuntimeDetour, 25.0.0-prerelease.2"
// Install MonoMod.RuntimeDetour as a Cake Addin #addin nuget:?package=MonoMod.RuntimeDetour&version=25.0.0-prerelease.2&prerelease // Install MonoMod.RuntimeDetour as a Cake Tool #tool nuget:?package=MonoMod.RuntimeDetour&version=25.0.0-prerelease.2&prerelease
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)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
-
.NETFramework 4.5.2
- Mono.Cecil (>= 0.11.4)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
-
.NETStandard 2.0
- Mono.Cecil (>= 0.11.4)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
- System.Reflection.Emit.ILGeneration (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
-
net5.0
- Mono.Cecil (>= 0.11.4)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
-
net6.0
- Mono.Cecil (>= 0.11.4)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
-
net7.0
- Mono.Cecil (>= 0.11.4)
- MonoMod.Backports (>= 1.0.0-prerelease.2)
- MonoMod.Core (>= 1.0.0-prerelease.2)
- MonoMod.ILHelpers (>= 1.0.0-prerelease.2)
- MonoMod.Utils (>= 25.0.0-prerelease.2)
NuGet packages (20)
Showing the top 5 NuGet packages that depend on MonoMod.RuntimeDetour:
Package | Downloads |
---|---|
Rookout
Rookout is a .NET package that supports on the fly debugging and data extraction from .NET applications in production. |
|
HarmonyX
A general non-destructive patch library for .NET and Mono modules |
|
MonoMod.RuntimeDetour.HookGen
Auto-generate hook helper .dlls, hook arbitrary methods via events: On.Namespace.Type.Method += YourHandlerHere; |
|
OTAPI.Upcoming
The Open Terraria API, known as OTAPI, is a low-level API for Terraria that rewrites and hooks into the official or modded binaries for others to use. OTAPI is primarily a server modification and is available as a cross platform package via NuGet. Version 3.0 is now a .NET6 library thanks to ModFramework being able to retarget the .NET4 vanilla assembly up to .NET6. This means that any mod you create can be written as a .NET6 module and later merged into the patched assembly thanks to MonoMod. Here is what is now possible: - Native Runtime hooks, just reference OTAPI.Runtime.dll and register to MonoMod events generated from the Terraria assembly. - Full .NET6 ecosystem and its performance improvements. No need for two targets such as Windows & Mono anymore either. - A new optional internal module system via ModFramework to load precompiled dll's, .cs files or even top level classes. - A strong set of libraries with methods and extensions to help you build more mods. - Create 1 file MonoMod patches to rewrite or inject new meta data to the assembly. |
|
OTAPI.Upcoming.tModLoader
The Open Terraria API, known as OTAPI, is a low-level API for Terraria that rewrites and hooks into the official or modded binaries for others to use. OTAPI is primarily a server modification and is available as a cross platform package via NuGet. Version 3.0 is now a .NET6 library thanks to ModFramework being able to retarget the .NET4 vanilla assembly up to .NET6. This means that any mod you create can be written as a .NET6 module and later merged into the patched assembly thanks to MonoMod. Here is what is now possible: - Native Runtime hooks, just reference OTAPI.Runtime.dll and register to MonoMod events generated from the Terraria assembly. - Full .NET6 ecosystem and its performance improvements. No need for two targets such as Windows & Mono anymore either. - A new optional internal module system via ModFramework to load precompiled dll's, .cs files or even top level classes. - A strong set of libraries with methods and extensions to help you build more mods. - Create 1 file MonoMod patches to rewrite or inject new meta data to the assembly. |
GitHub repositories (13)
Showing the top 5 popular GitHub repositories that depend on MonoMod.RuntimeDetour:
Repository | Stars |
---|---|
BepInEx/BepInEx
Unity / XNA game patcher and plugin framework
|
|
tModLoader/tModLoader
A mod to make and play Terraria mods. Supports Terraria 1.4 (and earlier) installations
|
|
LavaGang/MelonLoader
The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
|
|
valheimPlus/ValheimPlus
A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.
|
|
ManlyMarco/RuntimeUnityEditor
In-game inspector and debugging tools for applications made with Unity3D game engine
|
Version | Downloads | Last updated |
---|---|---|
25.2.1 | 83 | 11/13/2024 |
25.2.0 | 1,116 | 9/16/2024 |
25.1.2 | 18,405 | 6/11/2024 |
25.1.1 | 20,066 | 5/15/2024 |
25.1.0 | 659,748 | 2/6/2024 |
25.1.0-prerelease.2 | 17,152 | 1/8/2024 |
25.1.0-prerelease.1 | 14,756 | 12/7/2023 |
25.0.2 | 143,973 | 8/5/2023 |
25.0.0 | 18,121 | 6/16/2023 |
25.0.0-prerelease.2 | 13,799 | 5/25/2023 |
25.0.0-prerelease.1 | 13,761 | 5/20/2023 |
22.7.31.1 | 31,451 | 12/24/2022 |
22.5.1.1 | 195,586 | 5/1/2022 |
22.4.23.1 | 15,050 | 4/23/2022 |
22.3.23.4 | 178,847 | 3/23/2022 |
22.2.10.1 | 15,346 | 2/12/2022 |
22.1.29.1 | 29,147 | 2/2/2022 |
22.1.4.3 | 23,888 | 1/4/2022 |
21.12.13.1 | 84,933 | 12/14/2021 |
21.12.11.1 | 19,938 | 12/11/2021 |
21.11.9.2 | 17,507 | 12/8/2021 |
21.11.1.1 | 17,115 | 11/2/2021 |
21.10.10.1 | 8,070 | 10/10/2021 |
21.10.8.11 | 1,984 | 10/8/2021 |
21.9.19.1 | 3,695 | 9/19/2021 |
21.8.19.1 | 33,420 | 8/19/2021 |
21.8.5.1 | 25,046 | 8/5/2021 |
21.7.22.3 | 16,659 | 7/22/2021 |
21.7.8.3 | 15,337 | 7/9/2021 |
21.6.21.1 | 11,325 | 6/21/2021 |
21.4.29.1 | 14,713 | 5/6/2021 |
21.4.21.3 | 7,616 | 4/21/2021 |
21.4.2.3 | 6,820 | 4/3/2021 |
21.3.30.1 | 1,958 | 3/30/2021 |
21.3.28.2 | 2,187 | 3/28/2021 |
21.3.1.1 | 11,783 | 3/1/2021 |
21.1.11.1 | 44,854 | 1/12/2021 |
21.1.10.4 | 2,067 | 1/10/2021 |
20.12.25.1 | 2,323 | 12/25/2020 |
20.11.26.2 | 7,327 | 11/26/2020 |
20.11.16.1 | 3,153 | 11/16/2020 |
20.11.5.1 | 10,578 | 11/5/2020 |
20.8.28.1 | 2,119 | 11/5/2020 |
20.8.3.5 | 6,373 | 8/3/2020 |
20.5.21.5 | 8,107 | 5/23/2020 |
20.5.14.1 | 2,277 | 5/17/2020 |
20.5.7.1 | 5,101 | 5/7/2020 |
20.5.2.5 | 2,927 | 5/2/2020 |
20.4.3.1 | 2,345 | 4/3/2020 |
20.3.5.1 | 3,648 | 3/6/2020 |
20.3.1.1 | 2,150 | 3/1/2020 |
20.2.1.1 | 2,536 | 2/1/2020 |
20.1.1.4 | 4,551 | 1/1/2020 |
19.12.4.1 | 2,868 | 12/4/2019 |
19.11.5.1 | 2,592 | 11/5/2019 |
19.9.1.6 | 2,729 | 9/1/2019 |
19.8.2.3 | 2,452 | 8/2/2019 |
19.7.4.3 | 2,222 | 7/4/2019 |
19.6.9.5 | 2,298 | 6/9/2019 |
19.5.1.1 | 2,241 | 5/5/2019 |
19.4.10.9 | 2,283 | 4/10/2019 |
19.4.1.3 | 2,338 | 4/1/2019 |
19.2.7.8 | 2,494 | 2/7/2019 |
19.1.3.1 | 2,361 | 1/3/2019 |
18.12.9.1 | 2,337 | 12/18/2018 |
18.11.10.6 | 2,536 | 11/10/2018 |
18.11.9.9 | 2,159 | 11/9/2018 |
18.11.7.4 | 1,251 | 11/8/2018 |
18.11.4.19 | 1,268 | 11/4/2018 |
18.10.22.8 | 1,251 | 10/22/2018 |
18.10.0.37226 | 1,297 | 10/22/2018 |
18.10.0.35263 | 1,328 | 10/22/2018 |