SetWindowsHookEx,Vista和命令提示符Windows [英] SetWindowsHookEx, Vista, and Command Prompt Windows

查看:92
本文介绍了SetWindowsHookEx,Vista和命令提示符Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的开发人员就SetWindowsHookEx在Windows Vista下的行为以及允许访问的各种方法进行了大量研究.程序可以访问所需的事件,而不会影响安全性.我知道uiAccess标志的行为,并且我知道不允许非管理性挂钩以任何方式将其自身附加到管理进程(Windows等).

我做什么理解是为什么与SetWindowsHookEx一起安装的键盘和鼠标挂钩无法从非管理性命令提示符接收事件窗户,间歇性地(例如,有时有,有时没有).

我无法通过对命令提示符窗口中安全性设置的内省来确定行为(出于事件挂钩的目的)命令提示符窗口(例如管理应用程序)和任何其他非管理应用程序之间的区别.
<我完全感到困惑.我找不到任何文档,论坛说明或其他信息,这些信息指示未升高的命令提示符窗口将无法转发事件.

帮助?

I and my fellow developers have done a large amount of research about how SetWindowsHookEx behaves under Windows Vista, and what various methods there are for permitting accessibility programs to get access to the events they need without comprimising security. I am aware of the behavior of the uiAccess flag, and I know that non-administrative hooks are not allowed to attach themselves in any way to administrative processes (windows, etc.).

What I do not understand is why keyboard and mouse hooks installed with SetWindowsHookEx do not recieve events from non-administrative command prompt windows, intermittently (i.e., sometimes they do, sometimes they don't).

I cannot through introspection of the security settings on command prompt windows determine any difference between command prompt windows that behave (for the purpose of event hooks) like adminsitrative applications and any other non-administrative aplications.

I am utterly baffled. I cannot find any documentation, forum notes, or other information that indicates that non-elevated command prompt windows would ever fail to forward events.

Help?

推荐答案

我一直在研究同一件事,最合乎逻辑的解释似乎是cmd窗口通常没有消息循环,因此不要调用getmessage(它会调用钩子).我已经通过创建两个带有和不带messageloop的命令行应用程序进行了测试.具有messageloop的命令行应用程序执行挂钩代码,没有messageloop的应用程序则不执行.

这也记录在以下内容中:
http://msdn.microsoft.com/en-us/library/ms644984( VS.85).aspx

您可能可以使用的替代方法是不依赖dll注入和getmessage的低级鼠标和键盘挂钩:
http://msdn.microsoft.com/en-us/library/ms644985(VS. 85).aspx
I've been looking into the same thing and the most logical explanation seems to be that cmd windows usually do not have a message loop and so do not call getmessage(which calls the hooks). I've tested this by creating two commandline apps one with and one without a messageloop. The commandline app with a messageloop executes the hook code, the app without the messageloop doesn't.

This is also documented under:
http://msdn.microsoft.com/en-us/library/ms644988(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms644984(VS.85).aspx

An alternative you might be able to use are the low level mouse and keyoard hooks that don't rely on dll injection and getmessage:
http://msdn.microsoft.com/en-us/library/ms644985(VS.85).aspx


这篇关于SetWindowsHookEx,Vista和命令提示符Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆