Skip to content

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 2 parts:

  • MonoDetour: The library which handles hooking at runtime
  • MonoDetour.HookGen: The C# HookGen source generator

Add this to your csproj, changing the version number to optimally the newest:

<ItemGroup>
<PackageReference Include="MonoDetour" Version="0.6.*" />
<PackageReference Include="MonoDetour.HookGen" Version="0.6.*" PrivateAssets="all" />
</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.