MonoMod.Core 1.0.1

.NET 5.0 .NET Standard 2.0 .NET Framework 3.5
dotnet add package MonoMod.Core --version 1.0.1
NuGet\Install-Package MonoMod.Core -Version 1.0.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="MonoMod.Core" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MonoMod.Core --version 1.0.1
#r "nuget: MonoMod.Core, 1.0.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 MonoMod.Core as a Cake Addin
#addin nuget:?package=MonoMod.Core&version=1.0.1

// Install MonoMod.Core as a Cake Tool
#tool nuget:?package=MonoMod.Core&version=1.0.1

THIS IS PROBABLY NOT THE LIBRARY YOU WANT TO BE USING. You probably want RuntimeDetour instead.

You have been warned.


Notable APIs

  • MonoMod.Core.DetourFactory.Current
  • MonoMod.Core.ICoreDetour

Usage

Use DetourFactory.Current.CreateDetour to create a single detour from one method to another. The detour will be automatically undone when the returnedc object is disposed or garbage collected. Only one such detour may be made per method. If multiple are made, they will not be cleaned up properly. MonoMod.Core does not track which methods have already been detoured, and will not throw.

It is therefore highly recommended to use a higher-level detouring API (like that provided by MonoMod.RuntimeDetour or Harmony) to perform detours. Those higher level APIs also provide solutions to many of the limitations to Core's detour abstraction, such as the ability to call the original, unmodified method, or modify the IL of the method. (See their documentation for how this is actually done.)

Other potentially useful APIs

The default IDetourFactory utilizes MonoMod.Core.Platforms.PlatformTriple.Current to implement detours. Notably, that factory handles re-creating the underlying ISimpleNativeDetour objects when methods are recompiled by the runtime.

PlatformTriple does provide a few other utilities which may be useful for a higher-level library, however:

  • PlatformTriple.Prepare JIT compiles a method, sully supporting generic instantiations
  • PlatformTriple.GetIdentifiable translates the provided MethodBase into an instance which can be used as, for instance, the key to a ConditionalWeakTable

The other methods of PlatformTriple are means of implementing the detour factory, and likely should not be touched.

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-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)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on MonoMod.Core:

Package Downloads
Lib.Harmony

A general non-destructive patch library for .NET and Mono modules

MonoMod.RuntimeDetour

Flexible and easily extensible runtime detouring library. Wrap, replace and manipulate (Mono.Cecil) methods at runtime.

Rookout

Rookout is a .NET package that supports on the fly debugging and data extraction from .NET applications in production.

SonicGD.Lib.Harmony

A general non-destructive patch library for .NET and Mono modules

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on MonoMod.Core:

Repository Stars
pardeike/Harmony
A library for patching, replacing and decorating .NET and Mono methods during runtime
Version Downloads Last updated
1.0.1 6,075 8/5/2023
1.0.0 86,636 6/16/2023
1.0.0-prerelease.2 39,238 5/25/2023
1.0.0-prerelease.1 381 5/20/2023