SetWindowsHookEx WH_MOUSE freezes at breakpoint in Win7

Helos,

in WinXP, my application successfully uses the global mousehook to retrieve the mouse pointer and clicks, even if it has no focus. the hook is in a separate DLL and initialized as follows (in delphi):

SetWindowsHookEx(WH_MOUSE, @MouseHookCB, HInstance , 0);

now on Win7 it basically also works at runtime, but I can no longer debug my application nicely (which I can under XP). as soon as I am at the breakpoint, Win7 completely freezes. I cannot switch to another process (even the task manager does not open). if I'm lucky, I can stop my process in the IDE. in most cases, although I have to restart / log out to regain access.

I know that the problem is with the mouse hook, as it is absent if I do not use hook. this even if my hookprocedure does nothing but the following:

CallNextHookEx(MouseHook, Code, wParam, lParam);

T. Just the presence of a hook causes problems.

where globalhooks.dll writes something to EventLog, I see that it is still active, even when I am at a breakpoint.

I tried to use the lowlevelmouse hook through WH_MOUSE_LL, which basically works, but gives me strange delays in moving the mouse when setting the hook, and sometimes when resizing the window. there is also a freeze for several seconds when the breakpoint is reached, but at least the system will recover after ~ 5 seconds ... therefore this option is even worse, since it also affects the execution time.

any idea why WH_MOUSE delays my application during debugging in the first place?

+3
1

APP, HInstance. .exe , , .

SetWindowsHookEx , DLL 0.

, MouseHookCB() CallNextHookEx.

+1

Source: https://habr.com/ru/post/1759385/


All Articles