windows 检测键盘挂钩

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1465135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:11:27  来源:igfitidea点击:

Detecting Keyboard Hooks

windowssecuritywindows-vistakeyboardhook

提问by Kaveh Shahbazian

Is there a way to detect which programs or modules are listening to a keyboard hook? By Sysinternals maybe?

有没有办法检测哪些程序或模块正在监听键盘钩子?通过 Sysinternals 也许?

回答by Jaroslav Jandek

It largely depends on what level of abstraction are you obtaining your key presses.
For maximum detection you could use hardware directly or go as low as possible (some hooks work at HW driver-level).

这在很大程度上取决于您获得按键的抽象级别。
为了最大限度地检测,您可以直接使用硬件或尽可能低(一些钩子在硬件驱动程序级别工作)。

For security purposes, you could also use a virtual keyboard - hooks would have to be targeted specifically at your application to simulate key presses.

出于安全目的,您还可以使用虚拟键盘 - 钩子必须专门针对您的应用程序来模拟按键操作。

回答by Remy Lebeau

Nope. You would likely have to hook into SetWindowsHookEx() itself in order to detect that.

不。您可能必须挂钩 SetWindowsHookEx() 本身才能检测到它。

回答by Marc Bernier

I don't think you can, there's no GetWindowsHook function that would return the hook(s). Also, I'm under the impression that the main keyboard processing routine is hooked through SetWindowsHookEx(), so even if there are no hooks, there's at least one, Windows itself.

我认为你不能,没有 GetWindowsHook 函数可以返回钩子。此外,我的印象是主键盘处理例程是通过 SetWindowsHookEx() 挂钩的,因此即使没有挂钩,也至少有一个挂钩,即 Windows 本身。