为什么这个dll不会从我的进程中卸载? [英] Why won't this dll unload from my process?

查看:57
本文介绍了为什么这个dll不会从我的进程中卸载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个vb6 exe,它启动一个线程钩子注入另一个进程。

钩子安装程序代码在用c />


完成installhook调用之后我完成了dll并且它现在被注入到目标进程中,所以我调用FreeLibrary,它返回1表示它成功但是看看

Process Explorer不仅显示目标进程中注入的hookproc,而且dll代码的实例仍然悬挂在安装该钩子的此进程上并保持不变。当注入的代码终止时说安装过程正在使用它时,这会导致删除钩子dll时出现问题。



我希望这是远程清晰的。



VB6hook starter



I have a vb6 exe that starts a thread hook injected into another process.
The hook installer code is in the dll that is written in c

After the installhook call is made I am finished with the dll and it is now injected into the target process so I call FreeLibrary which is returning 1 which means it succeeded but a look at
Process Explorer shows not only the injected hookproc in the target process but an instance of the dll code is still hanging around and being held onto by the this process that installed the hook. This is causing an issue in deleting the hook dll when the injected code terminates saying it is in use by the installing process.

I hope this is remotely clear.

VB6 "hook starter"

hinstDLL = LoadLibrary(AppFilePath + "\\BCRMultiUnit\BCRBitBridgeHelper.dll")

hkprcSysMsg = GetProcAddress(hinstDLL, "ReadVSTStripNumProc")

InstallHookProc = GetProcAddress(hinstDLL, "installhook")

BitBridgeThread = GetWindowThreadProcessId(HwndBitBridge, 0)

installhook ByVal hinstDLL, ByVal BitBridgeThread

FreeLibrary (hinstDLL) '' I expect this to unload the dll from this process





钩子dll中的钩子安装程序功能





The hook installer function in the hook dll

BOOL __declspec(dllexport)__stdcall installhook(HINSTANCE hinstDLL, long BitBridgeThread)
{
	hBitBridge = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)ReadVSTStripNumProc, hinstDLL, BitBridgeThread);
return TRUE;
}





帮助? :-)



提前致谢!



:Ron



Help? :-)

Thanks in advance!

:Ron

推荐答案

谷歌再次搜索我在其他地方发现了类似问题的非神圣解决方案。



你可能想尝试调用FreeLibrary(模块) )在一个循环中直到它失败.Windows保存DLL的加载计数,并且只有当它变为零时它才会卸载DLL。



这只是坚果但是现在正在工作。
Googling once again I found a un-holy solution to a similar question elsewhere.

" You might want to try calling FreeLibrary(Module) in a loop until it fails. Windows keeps a loaded count for DLLs and only when it goes to zero does it unload the DLL."

This is just nuts but for now is working.


这篇关于为什么这个dll不会从我的进程中卸载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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