windows driver 创建线程

VOID ThreadStart(_In_  PVOID StartContext)
{
	PWCHAR str = (PWCHAR)StartContext;
	MySleep(10);//延时10ms
	KdPrint(("%ws\n", str));
	ExFreePool(str);
	PsTerminateSystemThread(STATUS_SUCCESS);
}
void MyThread()
{
	HANDLE hThread = NULL;
	UNICODE_STRING str = {0};
	wchar_t strInfo[] = {L"我爱你, 一生一世"};
	str.Buffer = (PWCHAR)ExAllocatePoolWithTag(NonPagedPool, ArrayLength, 'MY');
	str.Length = str.MaximumLength = (USHORT)wcslen(strInfo);
	RtlStringCbPrintfW(str.Buffer, ArrayLength, L"%ws", strInfo);
	PsCreateSystemThread(&hThread, 0, NULL, NULL, NULL, ThreadStart, str.Buffer);
	ZwClose(hThread);
}

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

posted @ 2014-11-13 20:20  QQ76211822  阅读(327)  评论(0编辑  收藏  举报