首页
社区
课程
招聘
[求助]关于Hook有几个问题请教
发表于: 2008-11-27 17:23 4877

[求助]关于Hook有几个问题请教

2008-11-27 17:23
4877
1 当调用全局钩子dll的exe关闭后,是不是所有其他进程的该dll都被卸掉了,为什么?

2 当调用全局钩子dll的exe关闭后,是不是不管是否调用UnhookWindowsHookEx,钩子都会进行卸载,为什么

3 DLL_PROCESS_DETACH的含义? 为什么我全局钩子后,有的进程还在 却几次跑到DLL_PROCESS_DETACH处的代码?

在线请教!

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 197
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
不知道,關注一下。
2008-11-27 21:15
0
雪    币: 212
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
母都不在了  子也不在了
2008-11-28 05:23
0
雪    币: 193
活跃值: (26)
能力值: ( LV9,RANK:210 )
在线值:
发帖
回帖
粉丝
4
1.不一定,要看你的DLL的线程是否全部回收完毕,一般是都被卸掉了
2.是的
3.程序重载或着一些程序有反钩子保护措施的 会对钩住自己的DLL进行尝试性FreeLibrary
2008-11-28 22:12
0
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
谢了 已经明白了
2008-12-2 16:11
0
雪    币: 139
活跃值: (126)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
6
1. No. Run SysInternal's Process Explorer (procexp.exe) on other processes after you killed yours, and you will see the fact.

2. No. Could be my bad memory, but this global hook job requires that your process contains user32.dll, which means your application is of a windowed app --- so if you write a console one, or a Windows service program, this global hook won't work, since they do not load user32.dll.

Once the DLL gets hooked into the target process, ALL the threads running within the process will call its DllMain() with ThreadAttach parameter and so on. It will stay there in other processes unless its load count reaches ZERO --- tons of ways you can do to make it.

3. DLL_PROCESS_DETACH的含义?
The DllMain() will be called with DLL_PROCESS_DETACH once before the process will die, either exit by itself, or someone force it to down.

为什么我全局钩子后,有的进程还在 却几次跑到DLL_PROCESS_DETACH处的代码?

Then it's a bug, either in Windows, or in someone's code :-)

Typically it should access the code within DllMain()!DLL_PROCESS_DETACH for just once, and may access code at DllMain()!DLL_THREAD_DETACH for certain number of times depends on how many threads you have in the process.
2008-12-6 08:21
0
雪    币: 139
活跃值: (126)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
7
Check this out:

http://www.codeproject.com/KB/system/hooksys.aspx

Explains well on the topic.
2008-12-6 09:06
0
游客
登录 | 注册 方可回帖
返回
//