|
发表于 2013-5-12 14:12:28
|
显示全部楼层
网上有例子:- /*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(("[Test] CreateThread Test Failed!"));
- } ZwClose(hThread);
- // 等待事件
- KeWaitForSingleObject(&kEvent, Executive, KernelMode, FALSE, 0);
- }
- // 线程函数
- VOID
- MyThreadFunc( IN PVOID context )
- {
- PUNICODE_STRING str = (PUNICODE_STRING)context;
- KdPrint(("[Test] %d : %wZ", (int)PsGetCurrentProcessId(), str));
- // 设置事件对象
- KeSetEvent(&kEvent, 0, FALSE);
- // 结束线程
- PsTerminateSystemThread(STATUS_S
- }
复制代码 |
|