Skip to content

Implement window-proc hooking path in HydraHook-ImGui sample #41

@coderabbitai

Description

@coderabbitai

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:

  1. Validate inputs: Check that the HWND and WNDPROC are valid before proceeding
  2. Store original WNDPROC: Maintain a per-window map (e.g., originalWndProcMap) to store the original WNDPROC before replacing it
  3. Install hook safely: Use SetWindowLongPtr/SetWindowSubclass to install the hook from HookWindowProc
  4. Forward messages correctly: Use CallWindowProc (or CallWindowProcW) to forward messages to the saved original, preserving calling convention
  5. Handle cleanup: On WM_NCDESTROY/WM_DESTROY, restore the original procedure
  6. Thread safety: Guard map access and hook install/removal with a mutex/critical section (e.g., csHook) to avoid races and re-entrancy
  7. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions