Show / Hide Table of Contents

    Class Detour

    A fully managed detour. Multiple Detours for a method to detour from can exist at any given time. Detours can be layered. If you're writing your own detour manager or need to detour native functions, it's better to create instances of NativeDetour instead.

    Inheritance
    System.Object
    Detour
    Detour<T>
    Implements
    ISortableDetour
    IDetour
    System.IDisposable
    Namespace: MonoMod.RuntimeDetour
    Assembly: MonoMod.RuntimeDetour.dll
    Syntax
    public class Detour : Object, ISortableDetour, IDetour, IDisposable

    Constructors

    Detour(Delegate, Delegate)

    Declaration
    public Detour(Delegate from, Delegate to)
    Parameters
    Type Name Description
    System.Delegate from
    System.Delegate to

    Detour(Delegate, Delegate, DetourConfig)

    Declaration
    public Detour(Delegate from, Delegate to, DetourConfig config)
    Parameters
    Type Name Description
    System.Delegate from
    System.Delegate to
    DetourConfig config

    Detour(Delegate, Delegate, ref DetourConfig)

    Declaration
    public Detour(Delegate from, Delegate to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Delegate from
    System.Delegate to
    DetourConfig config

    Detour(Delegate, IntPtr)

    Declaration
    public Detour(Delegate from, IntPtr to)
    Parameters
    Type Name Description
    System.Delegate from
    System.IntPtr to

    Detour(Delegate, IntPtr, DetourConfig)

    Declaration
    public Detour(Delegate from, IntPtr to, DetourConfig config)
    Parameters
    Type Name Description
    System.Delegate from
    System.IntPtr to
    DetourConfig config

    Detour(Delegate, IntPtr, ref DetourConfig)

    Declaration
    public Detour(Delegate from, IntPtr to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Delegate from
    System.IntPtr to
    DetourConfig config

    Detour(Expression, IntPtr)

    Declaration
    public Detour(Expression from, IntPtr to)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.IntPtr to

    Detour(Expression, IntPtr, DetourConfig)

    Declaration
    public Detour(Expression from, IntPtr to, DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.IntPtr to
    DetourConfig config

    Detour(Expression, IntPtr, ref DetourConfig)

    Declaration
    public Detour(Expression from, IntPtr to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.IntPtr to
    DetourConfig config

    Detour(Expression, Expression)

    Declaration
    public Detour(Expression from, Expression to)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.Linq.Expressions.Expression to

    Detour(Expression, Expression, DetourConfig)

    Declaration
    public Detour(Expression from, Expression to, DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.Linq.Expressions.Expression to
    DetourConfig config

    Detour(Expression, Expression, ref DetourConfig)

    Declaration
    public Detour(Expression from, Expression to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression from
    System.Linq.Expressions.Expression to
    DetourConfig config

    Detour(Expression<Action>, IntPtr)

    Declaration
    public Detour(Expression<Action> from, IntPtr to)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.IntPtr to

    Detour(Expression<Action>, IntPtr, DetourConfig)

    Declaration
    public Detour(Expression<Action> from, IntPtr to, DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.IntPtr to
    DetourConfig config

    Detour(Expression<Action>, IntPtr, ref DetourConfig)

    Declaration
    public Detour(Expression<Action> from, IntPtr to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.IntPtr to
    DetourConfig config

    Detour(Expression<Action>, Expression<Action>)

    Declaration
    public Detour(Expression<Action> from, Expression<Action> to)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.Linq.Expressions.Expression<System.Action> to

    Detour(Expression<Action>, Expression<Action>, DetourConfig)

    Declaration
    public Detour(Expression<Action> from, Expression<Action> to, DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.Linq.Expressions.Expression<System.Action> to
    DetourConfig config

    Detour(Expression<Action>, Expression<Action>, ref DetourConfig)

    Declaration
    public Detour(Expression<Action> from, Expression<Action> to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Action> from
    System.Linq.Expressions.Expression<System.Action> to
    DetourConfig config

    Detour(MethodBase, IntPtr)

    Declaration
    public Detour(MethodBase method, IntPtr to)
    Parameters
    Type Name Description
    System.Reflection.MethodBase method
    System.IntPtr to

    Detour(MethodBase, IntPtr, DetourConfig)

    Declaration
    public Detour(MethodBase method, IntPtr to, DetourConfig config)
    Parameters
    Type Name Description
    System.Reflection.MethodBase method
    System.IntPtr to
    DetourConfig config

    Detour(MethodBase, IntPtr, ref DetourConfig)

    Declaration
    public Detour(MethodBase method, IntPtr to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Reflection.MethodBase method
    System.IntPtr to
    DetourConfig config

    Detour(MethodBase, MethodBase)

    Declaration
    public Detour(MethodBase from, MethodBase to)
    Parameters
    Type Name Description
    System.Reflection.MethodBase from
    System.Reflection.MethodBase to

    Detour(MethodBase, MethodBase, DetourConfig)

    Declaration
    public Detour(MethodBase from, MethodBase to, DetourConfig config)
    Parameters
    Type Name Description
    System.Reflection.MethodBase from
    System.Reflection.MethodBase to
    DetourConfig config

    Detour(MethodBase, MethodBase, ref DetourConfig)

    Declaration
    public Detour(MethodBase from, MethodBase to, ref DetourConfig config)
    Parameters
    Type Name Description
    System.Reflection.MethodBase from
    System.Reflection.MethodBase to
    DetourConfig config

    Fields

    Method

    Declaration
    public readonly MethodBase Method
    Field Value
    Type Description
    System.Reflection.MethodBase

    OnDetour

    Declaration
    public static Func<Detour, MethodBase, MethodBase, bool> OnDetour
    Field Value
    Type Description
    System.Func<Detour, System.Reflection.MethodBase, System.Reflection.MethodBase, System.Boolean>

    OnGenerateTrampoline

    Declaration
    public static Func<Detour, MethodBase, MethodBase> OnGenerateTrampoline
    Field Value
    Type Description
    System.Func<Detour, System.Reflection.MethodBase, System.Reflection.MethodBase>

    OnUndo

    Declaration
    public static Func<Detour, bool> OnUndo
    Field Value
    Type Description
    System.Func<Detour, System.Boolean>

    Target

    Declaration
    public readonly MethodBase Target
    Field Value
    Type Description
    System.Reflection.MethodBase

    TargetReal

    Declaration
    public readonly MethodBase TargetReal
    Field Value
    Type Description
    System.Reflection.MethodBase

    Properties

    After

    Declaration
    public IEnumerable<string> After { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<System.String>

    Before

    Declaration
    public IEnumerable<string> Before { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<System.String>

    GlobalIndex

    Declaration
    public uint GlobalIndex { get; }
    Property Value
    Type Description
    System.UInt32

    ID

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    Index

    Declaration
    public int Index { get; }
    Property Value
    Type Description
    System.Int32

    IsApplied

    Declaration
    public bool IsApplied { get; }
    Property Value
    Type Description
    System.Boolean

    IsValid

    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    System.Boolean

    MaxIndex

    Declaration
    public int MaxIndex { get; }
    Property Value
    Type Description
    System.Int32

    Priority

    Declaration
    public int Priority { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    Apply()

    Mark the detour as applied in the detour chain. This can be done automatically when creating an instance.

    Declaration
    public void Apply()

    Dispose()

    Undo and free this temporary detour.

    Declaration
    public void Dispose()

    Free()

    Free the detour, while also permanently undoing it. This makes any further operations on this detour invalid.

    Declaration
    public void Free()

    GenerateTrampoline(MethodBase)

    Generate a new DynamicMethod with which you can invoke the previous state.

    Declaration
    public MethodBase GenerateTrampoline(MethodBase signature = null)
    Parameters
    Type Name Description
    System.Reflection.MethodBase signature
    Returns
    Type Description
    System.Reflection.MethodBase

    GenerateTrampoline<T>()

    Generate a new DynamicMethod with which you can invoke the previous state.

    Declaration
    public T GenerateTrampoline<T>()
        where T : Delegate
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    Undo()

    Undo the detour without freeing it, allowing you to reapply it later.

    Declaration
    public void Undo()

    Implements

    ISortableDetour
    IDetour
    System.IDisposable
    Back to top Yet another C# modding swiss army knife.