> ## Documentation Index
> Fetch the complete documentation index at: https://lua.nlcrack.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Hooks

> MinHook-based function detouring. Requires insecure mode. All hooks are removed when the script unloads.

## Functions

| Function | Returns | Description |
| - | - | - |
| `hooks.add(target, detour)` | `hook, original` | Install a detour at address `target` |
| `hooks.remove(target)` | `bool` | Remove hook by target address |
| `hooks.list()` | `table` | Array of this script's hook objects |

## Hook methods

| Method | Returns | Description |
| - | - | - |
| `hook:original()` | `number` | Address of the original function |
| `hook:target()` | `number` | Hooked target address |
| `hook:active()` | `bool` | Whether the hook is live |
| `hook:remove()` | `bool` | Remove this hook |

## Example

```lua theme={null} theme={null}
local addr = memory.find_pattern('client.dll', '48 89 5C 24 ? 57 48 83 EC 20 ...')
local h, orig = hooks.add(addr, function(rcx, rdx)
    -- call original
    -- return value
end)

events.on('unload', function()
    h:remove()
end)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.