关于FreeLibrary函数,我将一段代码远程插入到其他进程中(远程线程插入,不是DLL插入)。在远程线程中执行LoadLibrary加载一个dll,dll加载成功。然后在远程线程中使用FreeLibrary释放这个加载的dll却始终不成功,用兵刃等工具查看,这个dll依旧存在于远程进程当中。这是什么原因呢?
那么我还有一个疑问,如果进程中的线程1调用LoadLibrary加载了一个dll文件。然后该进程的线程2通过消息的方式得到了加载这个dll的模块句柄,然后使用FreeLibrary是否可以释放掉这个dll。
那么我还有一个疑问,如果进程中的线程1调用LoadLibrary加载了一个dll文件。然后该进程的线程2通过消息的方式得到了加载这个dll的模块句柄,然后使用FreeLibrary是否可以释放掉这个dll。
解决方案 »
- 一段代码
- 如何用多线程扫描多个机器的固定一个短口?
- 关于文件打开对话框
- 谁做过视频监控 的解码器部分.. ??????? 100分答谢...
- OLE DB中的会话(Session)到底有何用处?如何使用?
- 如何使生成的tabsheet和我的主窗口一样大?
- 在IME中是否可以建立一个窗口并拥有一个线程?
- 怎样把一个8位的已经灰度化的位图保存到硬盘上,是否自己创建文件头,文件信息头,保存系统调色盘(如果需要的话),还有就是图象信息,用CFILE或者序列化的方法将数据按BMP的文件格式保存到磁盘文件中。有没有代码实现,因为我是新手,经理逼着要,很痛苦,谢谢你
- 如何把DOS程序启动窗口设置为全屏,条件是在别的机器有同样效果!!
- 那里有MATLAB 开发包下载?提供个连接,谢谢!
- 我的 timer哪里用错了,重新清晰的发了下,消息循环根本没进,谁能比较正确的分析下,谢谢了
- 我的 timer哪里用错了,重新清晰的发了下,消息循环根本没进,谁能比较正确的分析下,谢谢了
这是可以的,因为所有的模块对整个进程都是透明的!
LoadLibrary和FreeLibrary可以跨线程配对,不能跨进程,至于你的注入就不了解了,可以GETLASTERROR看下。Module handles are not global or inheritable. A call to LoadLibrary by one process does not produce a handle that another process can use — for example, in calling GetProcAddress. The other process must make its own call to LoadLibrary for the module before calling GetProcAddress.Each process maintains a reference count for each loaded library module. This reference count is incremented each time LoadLibrary is called and is decremented each time FreeLibrary is called. A DLL module loaded at process initialization due to load-time dynamic linking has a reference count of one. This count is incremented if the same module is loaded by a call to LoadLibrary.During initial process startup or after a call to LoadLibrary, the system scans the list of loaded DLLs for the process. For each DLL that has not already been called with the DLL_PROCESS_ATTACH value, the system calls the DLL's entry-point function. This call is made in the context of the thread that caused the process address space to change, such as the primary thread of the process or the thread that called LoadLibrary.