Skip to content

talkingtogod/zenwinhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZenWinHook Logo

License: MIT Platform: Windows Standard: C++20 Safety: Thread-Safe


Overview

ZenWinHook is a high performance, thread safe Windows hooking library built for reliability and modern C++ workflows, it provides a unified API across multiple hooking techniques, allowing you to choose the right method for your use case without sacrificing safety or stability.

Designed for systems programming, debugging, instrumentation, and runtime modification.


Why ZenWinHook?

Most hooking libraries focus on a single technique or leave edge cases undefined.

ZenWinHook is built to handle the tricky parts:

  • Thread-safe by design: avoids race conditions during patching
  • Instruction-aware inline hooks: works on complex functions
  • Multiple hook types: no need to mix libraries
  • RAII-based API: predictable lifetime and cleanup

Comparison

Feature ZenWinHook MinHook PolyHook 2
Thread-safe patching ⚠️
Instruction relocation ⚠️
Multiple hook types ⚠️
RAII API
VEH / guard page hooks

Key Features

Thread-Safe Hot-Patching

Uses instruction pointer redirection and controlled thread suspension to prevent:

  • instruction tearing
  • partially applied patches
  • crashes from concurrent execution

Inline Hooking

  • instruction parsing + relocation
  • supports relative branches and short functions
  • avoids unsafe byte overwrites

VEH

  • no code modification
  • based on page protection + exceptions
  • useful when patching isn't possible

VTable Hooking

  • instance-level method overrides
  • very low overhead
  • useful for C++ interfaces

Breakpoint Hooking

  • INT3-based interception
  • lightweight
  • useful for tracing and debugging

RAII Hook Management

scoped_hook automatically installs and removes hooks:

scoped_hook<inline_hook> hook(target, detour, &original);
  • no manual cleanup
  • no dangling hooks
  • safer in larger systems

Quick Example (REALLY QUICK.)

#include "zenwinhook/hook_inline.h"

int main() {
    using namespace zenwinhook;

    void* original_fn = nullptr;

    {
        scoped_hook<inline_hook> hook(
            &TargetFunction,
            &DetourFunction,
            &original_fn
        );

        if (hook.success()) {
            TargetFunction(1337);
        }
    } // automatically restored here
}

Performance Notes

Approximate overhead (depends on CPU and usage):

Hook Type Overhead
Inline ~ few ns
VTable ~ minimal
VEH ~100–200ns

Use Cases

  • runtime instrumentation
  • debugging and tracing
  • reverse engineering tools
  • game modding

📄 License

MIT — see LICENSE.


built by talkingtogod

About

A high performance, thread safe Windows hooking library featuring Inline, VEH, and VTable interception with RAII based management

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors