窗户挂钩 [英] Windows Hooks

查看:116
本文介绍了窗户挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个系统钩子dll来监视另一个应用程序中的Windows消息.一切正常,除了在我的应用程序退出后,钩子dll需要很长时间才能消失.这很烦人,因为我不能经常构建项目.我注意到,钩子dll被注入到XP窗口中的30多个应用程序中.我的应用程序退出后,前10个以上的应用程序立即释放钩子dll.但是其余的应用程序会在5-10分钟后释放钩子dll.

我的问题是:有没有办法在调用UnhookWindowsHookEx()之后加快钩子dll的卸载?还是有办法编写只注入到我感兴趣的特定应用程序中的系统挂钩dll?

谢谢

I wrote a system hook dll that monitors windows messages in another application. Everything works except it takes a long time for the hook dll to go away after my application exited. This is annoying because I can not build my projects as often. I noticed that the hook dll is injected to more than 30 applications on my XP windows. The first 10 plus applications release the hook dll as soon as my application exited. But the rest of the applications release the hook dll at 5-10 minutes later.

My question is: is there a way to speed up the unloading of the hook dll after calling UnhookWindowsHookEx()? or is there a way to write a system hook dll that only injects into a particular application that I am interested?

Thanks

推荐答案

您的代码中肯定包含阻止DLL的内容.
您可以尝试注释掉挂钩回调中的所有代码,并检查是否发生这种情况.

使用SetWindowsHookEx可以挂接到当前进程或所有进程.您需要其他技术来仅挂接到选定的进程.

这是一些有关钩子的好文章-
将代码注入另一个进程的三种方法 [ API挂钩已显示 [使用CreateRemoteThread的更完整的DLL注入解决方案 [
There must be something in your code that is holding up the DLL.
You could try to comment out all code in the hook callback and check if this happens.

Using SetWindowsHookEx you can either hook into the current process or all processes. You need other techniques to only hook into selected processes.

Here are some good articles on hooking -
Three Ways to Inject Your Code into Another Process[^]
API Hooking Revealed[^]
A More Complete DLL Injection Solution Using CreateRemoteThread[^]


这篇关于窗户挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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