0x355/api-hooking — reverse-engineered prompt

Reverse engineered prompt

GitHub

Build me a small Windows x64 C project for learning API hooking from scratch. I want it to compile on Windows with CMake using either MSVC x64 tools or MinGW, and include a simple console demo that shows both IAT hooking and inline detour patching working on MessageBoxA.

The demo should print clear before and after logs, install the hook, show the original function pointer, intercept the MessageBoxA arguments, call the original safely, then remove the hook and prove it was restored. For the detour version, show the target bytes before and after patching, page protection info, trampoline address, stolen byte count, and restoration.

Please also include a tiny x64 instruction length decoder or test harness that prints pass or fail results for common Win64 instructions, since the detour needs to know how many bytes to overwrite. Keep it educational and readable, with comments explaining the risky Windows memory patching parts. Look up current Windows API docs online if needed.

Want more depth? Deep Reverse