Skip to Main Content

BTD_Mod_Helper​.Api​.Hooks​.ModHook_TN,TM_


BloonsTD6 Mod Helper

BTD_Mod_Helper.Api.Hooks

ModHook<TN,TM> Class

Provides a base mod hook for intercepting and modifying method calls using prefix and postfix hooks

public abstract class ModHook<TN,TM> : BTD_Mod_Helper.Api.ModContent
    where TN : System.Delegate
    where TM : System.Delegate

Type parameters

TN

The type of the unmanaged delegate

TM

The type of the managed delegate

Inheritance System.ObjectModContent  ModHook<TN,TM>

Derived
BloonDamageHook
BloonDegradeHook

Fields

ModHook<TN,TM>.Hook Field

The native hook instance used for attaching the hook

protected NativeHook<TN> Hook;

Field Value

MelonLoader.NativeUtils.NativeHook

ModHook<TN,TM>.HookDelegate Field

The delegate instance representing the hook method

protected TN HookDelegate;

Field Value

TN

ModHook<TN,TM>.PostfixList Field

Stores postfix hook methods sorted by their priority

protected Dictionary<int,List<TM>> PostfixList;

Field Value

System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List<TM>>

ModHook<TN,TM>.PrefixList Field

Stores prefix hook methods sorted by their priority

protected Dictionary<int,List<TM>> PrefixList;

Field Value

System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List<TM>>

Properties

ModHook<TN,TM>.HookMethod Property

Gets the unmanaged hook method used to intercept the target method

protected abstract TN HookMethod { get; }

Property Value

TN

ModHook<TN,TM>.TargetMethod Property

Gets the target method information that this mod hook intercepts

protected abstract System.Reflection.MethodInfo TargetMethod { get; }

Property Value

System.Reflection.MethodInfo

Methods

ModHook<TN,TM>.AddPostfix(TM) Method

Adds a postfix hook method to be executed after the original method

public void AddPostfix(TM method);

Parameters

method TM

The postfix hook method

ModHook<TN,TM>.AddPrefix(TM) Method

Adds a prefix hook method to be executed before the original method

public void AddPrefix(TM method);

Parameters

method TM

The prefix hook method

ModHook<TN,TM>.CallOriginalMethod(object[]) Method

Calls the original (trampoline) method with the specified arguments

public object CallOriginalMethod(params object[] args);

Parameters

args System.Object[]

Arguments to pass to the original method

Returns

System.Object
The result of the original method call

ModHook<TN,TM>.CreateAndAttachHook() Method

Creates and attaches the native hook to the target method.
Validates the delegate type and attaches the hook if valid.

public void CreateAndAttachHook();

ModHook<TN,TM>.GetBoolValue(bool) Method

Converts a boolean value to its byte representation.

protected static byte GetBoolValue(bool value);

Parameters

value System.Boolean

The boolean value to convert.

Returns

System.Byte
A byte value where true is 1 and false is 0.

ModHook<TN,TM>.Register() Method

Unused

public override void Register();
To learn how to download BTD Mod Helper and install mods, click here