奇怪了,我这个为什么创建不了系统线程?
#include <ntddk.h>HANDLE hMyThread;
VOID MyThread(IN PVOID pContext)
KdPrint(("ok100fen"));
PsTerminateSystemThread(0);
}
VOID Unload(IN PDRIVER_OBJECT DriverObject)
{
}
NTSTATUSDriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
PsCreateSystemThread(&hMyThread,0,NULL,NULL,NULL,MyThread,NULL);
DriverObject->DriverUnload = Unload;
return STATUS_SUCCESS;
} 网上有例子:/*http://www.edu03.com/2010/0611/1001.html*/
VOID
CreateThreadTest()
{
HANDLE hThread;
NTSTATUS status;
UNICODE_STRING ustrTest;
// 初始化
KeInitializeEvent(&kEvent, SynchronizationEvent, TRUE);
RtlInitUnicodeString(&ustrTest, L"This is a string for test!");
// 创建系统线程
status = PsCreateSystemThread(&hThread, 0, NULL, NULL, NULL, MyThreadFunc,
(PVOID)(&ustrTest));
if (!NT_SUCCESS(status))
{
KdPrint((" CreateThread Test Failed!"));
} ZwClose(hThread);
// 等待事件
KeWaitForSingleObject(&kEvent, Executive, KernelMode, FALSE, 0);
}
// 线程函数
VOID
MyThreadFunc( IN PVOID context )
{
PUNICODE_STRING str = (PUNICODE_STRING)context;
KdPrint((" %d : %wZ", (int)PsGetCurrentProcessId(), str));
// 设置事件对象
KeSetEvent(&kEvent, 0, FALSE);
// 结束线程
PsTerminateSystemThread(STATUS_S
}
页:
[1]