Skip to content

MonoDetourHook Class

A MonoDetour Hook.

C#
public class MonoDetourHook : IMonoDetourHook, IReadOnlyMonoDetourHook, IDisposable

Inheritance object

Implements IMonoDetourHook, IReadOnlyMonoDetourHook, IDisposable

The method to hook.

C#
public MethodBase Target { get; }

The hook or manipulator method.

C#
public MethodBase Manipulator { get; }

This differs from Applier’s MonoMod.RuntimeDetour.ILHook.Manipulator, as that points to the Applier itself.

A delegate of Manipulator; the hook or manipulator method.
Not null if the MonoDetourHook was passed a Delegate instead of a MethodBase during construction.

C#
public Delegate? ManipulatorDelegate { get; }

The owner MonoDetourManager of this hook.

C#
public MonoDetourManager Owner { get; }

Priority configuration for a MonoDetour Hook.

C#
public MonoDetourConfig? Config { get; }

The MonoMod.RuntimeDetour.ILHook that applies the Manipulator method.
An applier comes from a class implementing IMonoDetourHookApplier.

C#
public ILHook Applier { get; }

The IMonoDetourHookApplier type which defines how this MonoDetourHook is applied to the target method.

C#
public Type ApplierType { get; }

Gets whether or not this hook is valid and can be used.

C#
public bool IsValid { get; }

Gets whether or not this hook is applied.

C#
public bool IsApplied { get; }

Create<TApplier>(MethodBase, Delegate, MonoDetourManager, MonoDetourConfig?, bool)

Section titled “Create<TApplier>(MethodBase, Delegate, MonoDetourManager, MonoDetourConfig?, bool)”

Constructs a MonoDetourHook with Applier defined by TApplier.

C#
public static MonoDetourHook Create<TApplier>(MethodBase target, Delegate manipulator, MonoDetourManager owner, MonoDetourConfig? config = null, bool applyByDefault = true) where TApplier : class, IMonoDetourHookApplier

target MethodBase
The method to hook.

manipulator Delegate
The hook or manipulator method.

owner MonoDetourManager
The owner of this hook.

config MonoDetourConfig
The config which defines how to apply and treat this hook.

applyByDefault bool
Whether or not the hook should be applied after it has been constructed.

MonoDetourHook
A new MonoDetourHook.

Create<TApplier>(MethodBase, MethodBase, MonoDetourManager, MonoDetourConfig?, bool)

Section titled “Create<TApplier>(MethodBase, MethodBase, MonoDetourManager, MonoDetourConfig?, bool)”

Constructs a MonoDetourHook with Applier defined by TApplier.

C#
public static MonoDetourHook Create<TApplier>(MethodBase target, MethodBase manipulator, MonoDetourManager owner, MonoDetourConfig? config = null, bool applyByDefault = true) where TApplier : class, IMonoDetourHookApplier

target MethodBase
The method to hook.

manipulator MethodBase
The hook or manipulator method.

owner MonoDetourManager
The owner of this hook.

config MonoDetourConfig
The config which defines how to apply and treat this hook.

applyByDefault bool
Whether or not the hook should be applied after it has been constructed.

MonoDetourHook
A new MonoDetourHook.

TryGetFrom(Manipulator, out MonoDetourHook?)

Section titled “TryGetFrom(Manipulator, out MonoDetourHook?)”

Tries to get the corresponding MonoDetourHook for the specified MonoMod.Cil.ILContext.Manipulator if it exists.

C#
public static bool TryGetFrom(ILContext.Manipulator key, out MonoDetourHook? monoDetourHook)

key MonoMod.Cil.ILContext.Manipulator
The MonoMod.Cil.ILContext.Manipulator whose MonoDetourHook to get.

monoDetourHook MonoDetourHook
The found MonoDetourHook or null.

bool
true if the corresponding MonoDetourHook was found; otherwise, false.

Applies the hook if it was not already applied.

C#
public void Apply()

Undoes the hook if it was applied.

C#
public void Undo()

Disposes the Applier hook, disposing this MonoDetourHook.

C#
public void Dispose()