Overview
MonoDetour is a .NET detouring library powered by MonoMod.RuntimeDetour.
It focuses on being as convenient as possible while also being easy to use. And as such, hook generation with C# source generators is a core part of it, which makes hooking easy and fun.
MonoDetour comes in 3 parts:
- MonoDetour: The library which handles hooking
- MonoDetour.HookGen: The C# HookGen source generator
- MonoDetour.ILWeaver: A redesigned MonoMod ILCursor
MonoDetour.ILWeaver is not required to be used, although is recommended.
Adding to Your Project
Add this to your csproj, changing the version number to optimally the newest:
<ItemGroup> <PackageReference Include="MonoDetour.HookGen" Version="0.1.1-*" PrivateAssets="all" /> <PackageReference Include="MonoDetour" Version="0.1.1-*" /></ItemGroup>
MonoDetour.HookGen will automatically bring in the oldest MonoDetour reference it supports, so it’s a good idea to specify the version for both.
Additionally MonoDetour automatically brings in the oldest MonoMod.RuntimeDetour version it supports, so also specify its version to the one you want (or don’t if it’s included by e.g. BepInEx references). MonoDetour should support MonoMod.RuntimeDetour versions 21.12.13.1 and 25.*, with possibly anything in between.