Questions tagged [unhookwindowshookex]
7 questions
15
votes
2 answers
How can I ensure that UnhookWindowsHookEx is called even upon abnormal termination?
Unfortunately, MSDN is not clear enough with it. I'm writing a program which uses a global hook, and I'm worrying about what would happen if the program terminates abnormally (crashes, killed by user, etc).
Does Windows automatically unhook global…

Gary Chang
- 1,042
- 12
- 18
5
votes
2 answers
Unloading an Injected DLL
I have a DLL I inject into other processes using SetWindowsHookEx. Inside the DLL I increment the module's reference counter by calling GetModuleHandleEx so I can control when the module is unloaded.
At this point the module reference count "should…

tdemay
- 649
- 8
- 23
4
votes
2 answers
Unloading DLL from all processes after unhooking global CBT hook
How do you properly unload a DLL from all processes when the system-wide hook that loaded them gets unloaded?
From MSDN:
You can release a global hook
procedure by using
UnhookWindowsHookEx, but this function
does not free the DLL containing…

Vegard Larsen
- 12,827
- 14
- 59
- 102
1
vote
1 answer
UnhookWindowsHookEx produces ERROR_INVALID_HOOK_HANDLE?
I'm trying to implement a background application in WPF that does some things only when right-clicking the top of the screen, so I tried hooking WH_MOUSE_LL, which works great. The problem is unhooking the callback when exiting the application,…

Cubi73
- 1,891
- 3
- 31
- 52
0
votes
1 answer
How to UnHook properly?
I made a very simple Hook codes (I'm a beginner).
I opened Notepad and tested.
If I press ANY key it make a beep and printed itself.
Except "x" key, it is a terminator key.
Question :
I do not want to see "x" key printed. I just quit the program.…

Jason
- 361
- 3
- 15
-1
votes
1 answer
Unhooking a hook set with SetWindowsHookEx more than once crashes the hooked process
I am trying to hook the keyboard and mouse events of a target application.
I followed the SO question How to hook external process with SetWindowsHookEx and WH_KEYBOARD, and the hooks are installed and uninstalled correctly the first time. However,…

Sagar Kapadia
- 105
- 1
- 9
-4
votes
1 answer
Java JNA: How cast integer (int) to HHOOK?
I want unhook all hook messages (ring 3) and not is able because in Java seems that not is possible the cast from int for HHOOK type.
Someone know how solve this?
import com.sun.jna.platform.win32.Kernel32;
import…
user10560917