DEV Community

talkingtogod
talkingtogod

Posted on

ZenWinHook: A Thread-Safe Windows Hooking Library in C++

I got tired of sketchy Windows hooks, so I made my own

Hooking on Windows is one of those things that looks easy until it randomly crashes your process.

I kept running into the same issues: threads executing half patched code, weird instruction layouts breaking inline hooks, and edge cases most libraries just ignore.

So I built ZenWinHook.


Why I made it

Libraries like MinHook and PolyHook 2 are great, but they don’t really try to handle everything.

The biggest pain for me was patching safely while multiple threads are running, that’s where things usually fall apart.


What it does

ZenWinHook is a small C++ library that focuses on doing hooks properly.

It handles thread safe patching so you don’t get torn instructions.

Inline hooks actually parse and relocate instructions instead of guessing.

There are multiple hook types, so you don’t have to mix libraries.

And everything is RAII based so cleanup just happens automatically

When it’s useful

I mainly built this for:

  • debugging
  • instrumentation
  • reverse engineering
  • anything where stability actually matters

That’s it

If you’ve ever had hooks randomly crash a process, you’ll probably get why this exists.

Repo: https://github.com/talkingtogod/zenwinhook

Top comments (0)