Skip to content

Wrong condition in KeystrokeAPI.Dispose = wrong unhook #11

@JanVargovsky

Description

@JanVargovsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions