Create Hook

Signature

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.

Name
Value
Description

Auto

0x00

Automatically selects the hook type.

Jump

0xE8

Inserts a jump to the destination.

Call

0xE9

Inserts a call to the destination.

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

The inserted jump/call is always 5 bytes long.

Last updated