# Create Hook

### Signature

```csharp
u64 createHook(u64 source, u64 destination, s32 hookType, u64* return)
```

### Description

Creates a hook at specific address with a given type, leading to a specific destination.

Returns the original call/jump address, if applicable, or `0` if the operation fails.

### Arguments

#### Source

The memory address where the hook will be placed.

#### Destination

The memory address to which execution will be redirected.

If value is outside of 32-bit region, a trampoline will be created.

#### Hook Type

The type of hook to create, specifying how the execution flow is redirected at a given source address.

<table><thead><tr><th width="147">Name</th><th width="141">Value</th><th>Description</th></tr></thead><tbody><tr><td>Auto</td><td>0x00</td><td>Automatically selects the hook type.</td></tr><tr><td>Jump</td><td>0xE8</td><td>Inserts a jump to the destination.</td></tr><tr><td>Call</td><td>0xE9</td><td>Inserts a call to the destination.</td></tr></tbody></table>

#### Return

The pointer that will store the address of the trampoline. The trampoline allows for calling the original code at `source` after the hook is executed, providing a way to execute the original function alongside or after the hook logic.

### Notes

{% hint style="info" %}
The inserted jump/call is always 5 bytes long.
{% endhint %}
