Skip to content

API: MmGetHookTrampoline

Archie_UwU edited this page Sep 30, 2024 · 2 revisions

Returns a pointer to the trampoline of a hook created by MmCreateHook. This allows code to call a non-intercepted version of a hooked function.

Syntax

PVOID MmGetHookTrampoline(
    [in]  AurieModule*     Module
    [in]  std::string_view HookIdentifier
);

Parameters

Module

The module that created the hook specified by HookIdentifier. This parameter must point to a valid module.

HookIdentifier

A unique case-sensitive name of the hook created by Module.

Return Value

The function returns the base address of the trampoline. To use the trampoline as a way of calling the hooked function without triggering the hook, the caller should cast this value to a function pointer of the same type as the hooked function.

Upon failure, a nullptr is returned. In such scenarios, callers should assume that the hook does not exist.

Remarks

The MmGetHookTrampoline function is not designed with mid-function hooks (ie. hooks created by MmCreateMidfunctionHook) with mind, as they do not use a traditional trampoline.

Upon trying to invoke MmGetHookTrampoline with a HookIdentifier belonging to a mid-function hook, nullptr will always be returned.