找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 4678|回复: 1

奇怪了,我这个为什么创建不了系统线程?

[复制链接]

90

主题

473

回帖

2

精华

钻石会员

积分
3261
发表于 2010-8-14 21:53:47 | 显示全部楼层 |阅读模式
#include <ntddk.h>
HANDLE hMyThread;
VOID MyThread(IN PVOID pContext)

        
   KdPrint(("ok100fen"));
   PsTerminateSystemThread(0);


}


VOID Unload(IN PDRIVER_OBJECT DriverObject)
{
}

NTSTATUS  DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
        
   

   PsCreateSystemThread(&hMyThread,0,NULL,NULL,NULL,MyThread,NULL);

   


   DriverObject->DriverUnload = Unload;

        return STATUS_SUCCESS;
}

857

主题

2632

回帖

2

精华

管理员

此生无悔入华夏,  长居日耳曼尼亚。  

积分
36130
发表于 2013-5-12 14:12:28 | 显示全部楼层
网上有例子:
  1. /*http://www.edu03.com/2010/0611/1001.html*/
  2. VOID
  3. CreateThreadTest()
  4. {
  5. HANDLE hThread;
  6. NTSTATUS status;
  7. UNICODE_STRING ustrTest;
  8. // 初始化
  9. KeInitializeEvent(&kEvent, SynchronizationEvent, TRUE);
  10. RtlInitUnicodeString(&ustrTest, L"This is a string for test!");
  11. // 创建系统线程
  12. status = PsCreateSystemThread(&hThread, 0, NULL, NULL, NULL, MyThreadFunc,
  13. (PVOID)(&ustrTest));
  14. if (!NT_SUCCESS(status))
  15. {
  16. KdPrint(("[Test] CreateThread Test Failed!"));
  17. } ZwClose(hThread);
  18. // 等待事件
  19. KeWaitForSingleObject(&kEvent, Executive, KernelMode, FALSE, 0);
  20. }

  21. // 线程函数
  22. VOID
  23. MyThreadFunc( IN PVOID context )
  24. {
  25. PUNICODE_STRING str = (PUNICODE_STRING)context;
  26. KdPrint(("[Test] %d : %wZ", (int)PsGetCurrentProcessId(), str));
  27. // 设置事件对象
  28. KeSetEvent(&kEvent, 0, FALSE);
  29. // 结束线程
  30. PsTerminateSystemThread(STATUS_S
  31. }
复制代码
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表