HydraHook
Direct3D and Core Audio hooking library for Windows
Loading...
Searching...
No Matches
Hook.h File Reference

C++ wrapper for Microsoft Detours function hooking. More...

#include "Windows.h"
#include <detours/detours.h>
#include "Exceptions.hpp"

Go to the source code of this file.

Classes

struct  convention< CallConvention::stdcall_t, retn, args... >
struct  convention< CallConvention::cdecl_t, retn, args... >
class  Hook< cc, retn, args >
 RAII Detours hook wrapper for function interception. More...

Enumerations

enum class  CallConvention { stdcall_t , cdecl_t }
 Supported calling conventions for hook targets. More...

Variables

bool g_hookDestructorDetachSuppressed = false
 When set, ~Hook() does not detach.

Detailed Description

C++ wrapper for Microsoft Detours function hooking.

Provides a type-safe Hook template for attaching/detaching detours with support for __stdcall and __cdecl conventions. Uses RAII for transaction management.

Dependencies
Requires detours library and HydraHook::Core::Exceptions::DetourException.

Definition in file Hook.h.

Enumeration Type Documentation

◆ CallConvention

enum class CallConvention
strong

Supported calling conventions for hook targets.

Enumerator
stdcall_t 

__stdcall convention.

cdecl_t 

__cdecl convention.

Definition at line 56 of file Hook.h.

Variable Documentation

◆ g_hookDestructorDetachSuppressed

bool g_hookDestructorDetachSuppressed = false
inline

When set, ~Hook() does not detach.

DLL_PROCESS_DETACH runs static destructors after a retained Destroy returns. Those destructors must not call DetourDetach while the worker or a callback is still inside a hook. A later successful Destroy clears this.

Definition at line 53 of file Hook.h.

Referenced by DestroyEngine(), and Hook< cc, retn, args >::~Hook().