| Previous | Next |
| ERROR_INVALID_ACCEL_HANDLE | ERROR_INVALID_DWP_HANDLE |
ERROR_INVALID_HOOK_HANDLE
The HHOOK is invalid
An HHOOK is returned by SetWindowsHookEx for one installed hook instance. It is not a hook type number, thread identifier, callback address, or module handle.
Hook cleanup is asynchronous enough to expose stale-handle bugs in shared code. A component may unhook during shutdown while another path tries to remove or otherwise reference the same hook. Double-unhook logic and storing the result of a failed SetWindowsHookEx call are also high-value suspects.
What to check
- Check that
SetWindowsHookExreturned a non-NULL handle and preserve its original error if it did not. - Serialize hook installation and removal so one owner performs cleanup.
- Clear the stored handle only after deciding how concurrent callers observe removal.
- Keep
idHook,dwThreadId,hmod, and the returnedHHOOKin separate typed fields.
ERROR_HOOK_NOT_INSTALLED describes installation state; this code means the handle value supplied as an HHOOK is invalid.
References
- Microsoft: SetWindowsHookEx
- Microsoft: UnhookWindowsHookEx
- Wine: user32 API implementation inventory
Looking for a different code? Search another status or error code.
