Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong condition in KeystrokeAPI.Dispose = wrong unhook #11

Open
JanVargovsky opened this issue Feb 23, 2019 · 0 comments
Open

Wrong condition in KeystrokeAPI.Dispose = wrong unhook #11

JanVargovsky opened this issue Feb 23, 2019 · 0 comments

Comments

@JanVargovsky
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant