Table of Contents
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
TN
The type of the unmanaged delegate
TM
The type of the managed delegate
Inheritance System.Object ModContent ModHook<TN,TM>
Derived
↳ BloonDamageHook
↳ BloonDegradeHook
The native hook instance used for attaching the hook
protected NativeHook<TN> Hook;
MelonLoader.NativeUtils.NativeHook
The delegate instance representing the hook method
protected TN HookDelegate;
Stores postfix hook methods sorted by their priority
protected Dictionary<int,List<TM>> PostfixList;
System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List<TM>>
Stores prefix hook methods sorted by their priority
protected Dictionary<int,List<TM>> PrefixList;
System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List<TM>>
Gets the unmanaged hook method used to intercept the target method
protected abstract TN HookMethod { get; }
Gets the target method information that this mod hook intercepts
protected abstract System.Reflection.MethodInfo TargetMethod { get; }
Adds a postfix hook method to be executed after the original method
public void AddPostfix(TM method);
method
TM
The postfix hook method
Adds a prefix hook method to be executed before the original method
public void AddPrefix(TM method);
method
TM
The prefix hook method
Calls the original (trampoline) method with the specified arguments
public object CallOriginalMethod(params object[] args);
args
System.Object[]
Arguments to pass to the original method
System.Object
The result of the original method call
Creates and attaches the native hook to the target method.
Validates the delegate type and attaches the hook if valid.
public void CreateAndAttachHook();
Converts a boolean value to its byte representation.
protected static byte GetBoolValue(bool value);
value
System.Boolean
The boolean value to convert.
System.Byte
A byte value where true is 1 and false is 0.
Unused
public override void Register();