Class Hook<T>
Manages a hook which can be used to intercept a call to native function. This class is basically a thin wrapper around the LocalHook type to provide helper functions.
Inheritance
Implements
Inherited Members
Namespace: Dalamud.Hooking
Assembly: Dalamud.dll
Syntax
public sealed class Hook<T> : IDisposable, IDalamudHook where T : Delegate
Type Parameters
| Name | Description |
|---|---|
| T | Delegate type to represents a function prototype. This must be the same prototype as original function do. |
Constructors
| Improve this Doc View SourceHook(IntPtr, Delegate, Object)
Createss a hook. Hook is not activated until Enable() method is called.
Declaration
public Hook(IntPtr address, Delegate detour, object callbackParam = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IntPtr | address | A memory address to install a hook. |
| System.Delegate | detour | Callback function. Delegate must have a same original function prototype. |
| System.Object | callbackParam | A callback object which can be accessed within the detour. |
Properties
| Improve this Doc View SourceAddress
A memory address of the target function.
Declaration
public IntPtr Address { get; }
Property Value
| Type | Description |
|---|---|
| System.IntPtr |
Exceptions
| Type | Condition |
|---|---|
| System.ObjectDisposedException | Hook is already disposed. |
IsDisposed
Check if the hook has been disposed
Declaration
public bool IsDisposed { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsEnabled
Check if the hook is enabled.
Declaration
public bool IsEnabled { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Original
A delegate function that can be used to call the actual function as if function is not hooked yet.
Declaration
public T Original { get; }
Property Value
| Type | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ObjectDisposedException | Hook is already disposed. |
Methods
| Improve this Doc View SourceDisable()
Stops intercepting a call to the function.
Declaration
public void Disable()
Dispose()
Remove a hook from the current process.
Declaration
public void Dispose()
Enable()
Starts intercepting a call to the function.
Declaration
public void Enable()
FromSymbol(String, String, Delegate, Object)
Creates a hook. Hooking address is inferred by calling to GetProcAddress() function. Hook is not activated until Enable() method is called.
Declaration
public static Hook<T> FromSymbol(string moduleName, string exportName, Delegate detour, object callbackParam = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | moduleName | A name of the module currently loaded in the memory. (e.g. ws2_32.dll) |
| System.String | exportName | A name of the exported function name (e.g. send) |
| System.Delegate | detour | Callback function. Delegate must have a same original function prototype. |
| System.Object | callbackParam | A callback object which can be accessed within the detour. |
Returns
| Type | Description |
|---|---|
| Hook<T> |