CreateRemoteThread 和 WaitForSingleObject 的奇怪问题
2011-03-23 16:31
483 查看
测试环境: VC6.0 + XP SP2
1. P1进程通过CreateRemoteThread 在P2进程中创建一个新线程T1: 线程函数为LoadLibrary, 线程参数为注入dll的路径
2. T1 线程函数会用DLL_PROCESS_ATTACH参数调用DllMain, 在DllMain中调用 CreateThread 创建新线程T2, 并记录返回的T2线程句柄HT2
3. P1进程通过CreateRemoteThread 在P2进程中创建一个新线程T3: 线程函数为FreeLibrary, 线程参数为注入dll模块句柄
4. T3线程函数会用DLL_PROCESS_DETACH参数调用DllMain, 在DllMain中调用WaitForSingleObject(HT2, INFINITE)
问题出现了, T2线程即使结束了, WaitForSingleObject也不返回, 待解决....
问题补充: 经测试, 在T1和T3中加入延时函数(Sleep)则在延时时间内P2进程窗口无响应, 与此有关? Why?
1. P1进程通过CreateRemoteThread 在P2进程中创建一个新线程T1: 线程函数为LoadLibrary, 线程参数为注入dll的路径
2. T1 线程函数会用DLL_PROCESS_ATTACH参数调用DllMain, 在DllMain中调用 CreateThread 创建新线程T2, 并记录返回的T2线程句柄HT2
3. P1进程通过CreateRemoteThread 在P2进程中创建一个新线程T3: 线程函数为FreeLibrary, 线程参数为注入dll模块句柄
4. T3线程函数会用DLL_PROCESS_DETACH参数调用DllMain, 在DllMain中调用WaitForSingleObject(HT2, INFINITE)
问题出现了, T2线程即使结束了, WaitForSingleObject也不返回, 待解决....
问题补充: 经测试, 在T1和T3中加入延时函数(Sleep)则在延时时间内P2进程窗口无响应, 与此有关? Why?
相关文章推荐
- 赞!VC++编程创建远程线程式调用CALL_VirtualAllocEx_WriteProcessMemory_CreateRemoteThread_WaitForSingleObject
- WaitForSingleObject、WaitForMultipleObjects、CreateThread .
- 每日20行之3~~~ThreadPool之RegisterWaitForSingleObject 自动定时执行(可循环)
- WaitForSingleObject 的问题
- WaitForMultipleObjects、WaitForSingleObject、GetExitCodeThread
- CreateEvent/SetEvent/ResetEvent和WaitForSingleObject
- CreateMutex和WaitForSingleObject组合的有关问题
- testThread WaitForSingleObject
- Android游戏制作退出框遇到的问题:object not locked by thread before wait()和Can't create handler inside thread
- 关于ThreadPool.RegisterWaitForSingleObject和WaitHandle的应用介绍 【转】
- GetExitCodeThread(hThrd, &exitCode);WaitForSingleObject(hThrd,INFINITE);
- 为什么Mutex,Event,Thread句柄都是可以waitforsingleobject?
- CreateMutex和WaitForSingleObject组合的有关问题
- CreateEvent/OpenEvent/SetEvent/ResetEvent/WaitForSingleObject 相关用法说明
- GetExitCodeThread WaitForSingleObject
- ThreadPool.RegisterWaitForSingleObject 设置等待超时事件
- 线程中CreateEvevt、SetEvent与WaitForSingleObject的用法
- CreateEvent WaitForSingleObject
- MFC主线程使用WaitForSingleObject阻塞的问题 http://blog.csdn.net/sysprogram/article/details/17383455
- 多线程访问文件问题中WaitForSingleObject方法的使用,及其效率!