void Load()
{
BOOL bSuccess = FALSE;
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(si);
DWORD dwCreateFlag = CREATE_SUSPENDED;
TCHAR szFile1[] = TEXT("C:\\windows\\system32\\notepad.exe");
bSuccess = ::CreateProcess( NULL, szFile1, NULL, NULL, FALSE, dwCreateFlag, NULL, NULL, &si, &pi );
wchar_t szFilePath[MAX_PATH] = L"C:\\windows\\system32\\kernel32.dll";
LPVOID lpFilePath = VirtualAllocEx( pi.hProcess,NULL,sizeof(szFilePath),MEM_COMMIT,PAGE_READWRITE );
if( lpFilePath )
{
DWORD dwBytes = 0;
WriteProcessMemory( pi.hProcess, lpFilePath, szFilePath, sizeof(szFilePath), &dwBytes );
HMODULE hKernel = GetModuleHandleW(L"Kernel32.dll");
LPVOID pLoadLibrary = GetProcAddress( hKernel,"LoadLibraryW" );
DWORD dwThreadId = 0;
HANDLE hThread = NULL;
hThread = CreateRemoteThread( pi.hProcess,NULL,0,(LPTHREAD_START_ROUTINE)pLoadLibrary,lpFilePath,CREATE_SUSPENDED,&dwThreadId );
ResumeThread(hThread);
}
Sleep(50);// 这里如果不 Sleep,记事本正常启动,否则 ResumeThread( pi.hThread ) 后记事本无声消失了
ResumeThread( pi.hThread );
}
========================================
就以上一个简单的创建远程线程的例子,在 Windows7、Windows 2003 下正常运行,并且无论 Sleep 多长时间都可以看到记事本窗口,但 XP 下就不行了,Sleep 超过 5 ms Notepad 进程都是突然无影踪
这如何解析?
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课