Did MS change something about keyboard hooks in Windows Vista or 7?

折月煮酒 提交于 2019-12-06 15:49:48

Well, it's been tinkered with plenty when UAC was implemented in Vista. Nevertheless, this is not a common complaint. Yes, it is quite possible for Windows to stop calling back the hook callback. A built-in feature to prevent the operating system from getting unresponsive when there is one hooker that doesn't handle the callback in a timely manner. It gets automatically removed from the callback list without any diagnostic.

This is based on a timeout and can indeed trip when the OS is starting to run low on resources. Like not having enough RAM and running lots of processes, getting massive paging. More likely with later versions of Windows since they need more RAM and tend to suffer when the machine was upgraded instead of wiped before the install due to disk fragmentation problems (especially the paging file).

The timeout setting can be tweaked by adding the HKCU\Control Panel\Desktop\LowLevelHooksTimeout value (DWORD, say 10000). Ask more questions about it at superuser.com

I ran into the same timeout issue you describe when I was writing my own keyboard hook the other day. To get around the issue, I wrote my hookcallback proc such that it calls a key press event asynchronously and immediately returns.

Here's a link to my code, if you're interested.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!