Context
A TODO was added in PR #40 at line 1011 of samples/HydraHook-ImGui/dllmain.cpp indicating that the window-proc hooking path needs to be implemented.
Related PR: #40
Comment thread: #40 (comment)
Requested by: @nefarius
Description
The HookWindowProc function currently has incomplete implementation (guarded by #ifdef WNDPROC_HOOK). This issue tracks the work needed to implement a full, safe hook path for window procedure interception.
Implementation Requirements
The window-proc hooking path should:
- Validate inputs: Check that the HWND and WNDPROC are valid before proceeding
- Store original WNDPROC: Maintain a per-window map (e.g.,
originalWndProcMap) to store the original WNDPROC before replacing it
- Install hook safely: Use
SetWindowLongPtr/SetWindowSubclass to install the hook from HookWindowProc
- Forward messages correctly: Use
CallWindowProc (or CallWindowProcW) to forward messages to the saved original, preserving calling convention
- Handle cleanup: On
WM_NCDESTROY/WM_DESTROY, restore the original procedure
- Thread safety: Guard map access and hook install/removal with a mutex/critical section (e.g.,
csHook) to avoid races and re-entrancy
- Error handling: Add minimal error logging on failures so issues are visible
Current State
The WNDPROC_HOOK conditional block exists but needs the full implementation as described above to ensure overlay stability for input handling.
Context
A TODO was added in PR #40 at line 1011 of
samples/HydraHook-ImGui/dllmain.cppindicating that the window-proc hooking path needs to be implemented.Related PR: #40
Comment thread: #40 (comment)
Requested by: @nefarius
Description
The
HookWindowProcfunction currently has incomplete implementation (guarded by#ifdef WNDPROC_HOOK). This issue tracks the work needed to implement a full, safe hook path for window procedure interception.Implementation Requirements
The window-proc hooking path should:
originalWndProcMap) to store the original WNDPROC before replacing itSetWindowLongPtr/SetWindowSubclassto install the hook fromHookWindowProcCallWindowProc(orCallWindowProcW) to forward messages to the saved original, preserving calling conventionWM_NCDESTROY/WM_DESTROY, restore the original procedurecsHook) to avoid races and re-entrancyCurrent State
The
WNDPROC_HOOKconditional block exists but needs the full implementation as described above to ensure overlay stability for input handling.