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
Adding to Your Project
Section titled “Adding to Your Project”Note: MonoDetour implements interop support for HarmonyX. This means that MonoDetour prefix and postfix hooks are aware of HarmonyX prefix and postfix hooks, and they respect each other.
Add this to your csproj, changing the version number of MonoDetour.HookGen to optimally the newest:
<ItemGroup> <PackageReference Include="MonoDetour.HookGen" Version="0.7.*" PrivateAssets="all" /> <PackageReference Include="MonoDetour" Version="[*,2.0)" /> <!-- Highest version below 2.0 --></ItemGroup>Current MonoDetour.HookGen version:
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.
Requesting a Package Upload
Section titled “Requesting a Package Upload”MonoDetour ships new package versions automatically for certain games on modding platforms like Thunderstore. You should not reupload MonoDetour if the upload can be automated.
Requirements for upload for a new game/platform:
- The platform must have a publishing API (e.g. Thunderstore)
- The mod loader must ship MonoMod (e.g. BepInEx 5, BepInEx 6, MelonLoader)
If your game/platform passes the above requirements, answer the following questions:
- Which platform to publish it on? (e.g. Thunderstore)
- Which game/community?
- Which mod loader? (BepInEx 5, BepInEx 6, etc.)
- Does MonoDetour work for the game? (MonoDetour currently only targets
netstandard2.0)
You can either open a new issue on MonoDetour’s GitHub or leave a message on the Discord server: