Windows 64位操作系统上的SetWindowsHookEx问题 [英] SetWindowsHookEx problem on windows 64bit OS

查看:263
本文介绍了Windows 64位操作系统上的SetWindowsHookEx问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



亲爱的,

Dears,

这是关于64位操作系统全局挂钩的问题,我需要你的帮助。

This is a problem about global hook on 64bit OS, I need your help.

我通过在32位DLL中使用SetWindowsHookEx设置一个全局钩子来过滤指定的32位进程的键盘和鼠标操作,使用进程ID进行过滤条件。

I set up a global hook by using SetWindowsHookEx in a 32bit DLL to filter the keyboard and mouse operation for specified 32bit process, using process id for filtering condition.

它在所有32位操作系统上运行良好,但是在windows vista 64bit和win7 64bit OS上发生了一个奇怪的现象(我还没有在WinXP 64上测试它)。当32位dll包含全局钩子被另一个32位进程加载到内存中时(它也是由我开发的
),然后启动目标GUI进程,如果焦点在目标GUI进程窗口中,它将被挂钩,它工作正常(不能使用键盘和鼠标),如果我专注于另一个不被钩住的32位工艺窗口,可以使用键盘
和鼠标(这很好),但如果我专注在另一个64位进程窗口,例如Windows资源管理器,记事本。键盘和鼠标无法使用!!!(这是问题)

It works fine on all of 32bit operating system, but a curious phenomenon occurs on window vista 64bit and win7 64bit OS(I've not test it on WinXP 64 yet). When the 32bit dll contains global hook is loaded into memory by another 32bit process(it is also developed by me), then start target GUI process which is to be hooked, if focus is in the target GUI process window, it works fine(keyboard and mouse can not be used), if I focus on another 32bit process window which is not to be hooked, the keyboard and mouse can be used(this is fine), but if I focus on another 64bit process window, such as windows explorer, notepad. The keyboard and mouse can not be used!!!(this is the problem)

通过对日志文件的一些跟踪,我发现当我将焦点从目标挂钩进程更改为另一个64位时在进程窗口中,MouseProc和KeyboardProc中的进程ID保持相同的值(该值是钩子进程ID),但如果我将焦点
从目标钩子进程更改为另一个32位进程窗口,则进程ID将更改为新的专注流程。

Through some tracking on the log file, I found that when I change focus from target hooked process to another 64bit process window, the process id in MouseProc and KeyboardProc keeps the same one(the value is the hooked process id), but if I change focus from target hooked process to another 32bit process window, the process id will change as the new focused process.

这只是好奇而且我不知道它是否是64位操作系统的机制。 

It is just curious and I don not know whether it is the mechanism of 64bit OS. 

为什么焦点改变时进程ID不会改变?是否有任何解决方案可以在全局挂钩程序中区分32位进程和64位进程?

Why the process id not changing when focus is changed? Is there any solution to make a distinction between 32bit process and 64bit process in a global hooked procedure?

非常感谢您的帮助!!!

Much appreciation for your help!!!

 

祝福,

ShenHui。

推荐答案

嗯,这里的问题是你无法将32位DLL加载到64位进程中。因此,如果您想要进行全局挂钩或挂钩64位进程,那么您还需要提供64位DLL。
Well, the problem here is that you cannot load a 32 bit DLL into a 64 bit process. So if you want to do a global hook or hook a 64 bit process then you will also need to supply a 64 bit DLL.


这篇关于Windows 64位操作系统上的SetWindowsHookEx问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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