KeystrokeAPI icon indicating copy to clipboard operation
KeystrokeAPI copied to clipboard

Wrong condition in KeystrokeAPI.Dispose = wrong unhook

Open JanVargovsky opened this issue 6 years ago • 0 comments

As title says, you have wrong condition in the Dispose method of the KeystrokeAPI class.

It is supposed to be

if (globalKeyboardHookId != IntPtr.Zero)
    User32.UnhookWindowsHookEx(globalKeyboardHookId);

instead of

if (globalKeyboardHookId == IntPtr.Zero)
    User32.UnhookWindowsHookEx(globalKeyboardHookId);

Also the overall design of the class is quite easy to create handle leaks - e.g. call twice CreateKeyboardHook and you are no longer able to unhook the hook.

JanVargovsky avatar Feb 23 '19 11:02 JanVargovsky