DLL注入后创建线程失败


原因:DLL的返回值应该为TRUE.


//使用如下代码可成功创建线程


#include <windows.h>
#include <tchar.h>

DWORD WINAPI ThreadProc(
  LPVOID lpParameter   // thread data
)
{
 MessageBox(NULL, "线程开始!", "", MB_OK);
// ChangeMemory();
 return 0;
}

BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
    switch ( fdwReason )
    {
    case DLL_PROCESS_ATTACH:
        {
            MessageBox( NULL, _T("DLL已进入目标进程。"), _T("信息"), MB_ICONINFORMATION );
   DWORD dwTID;
   HANDLE hThread =  CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, NULL, 0, &dwTID);
        }
        break;
    case DLL_PROCESS_DETACH:
        {
            MessageBox( NULL, _T("DLL已从目标进程卸载。"), _T("信息"), MB_ICONINFORMATION );
        }
        break;
    }
    return TRUE;
}

你可能感兴趣的:(DLL注入后创建线程失败)