-
-
[求助]驱动中如何sleep?
-
发表于:
2012-4-9 23:29
10259
-
RT
根据天书夜读上的代码,照葫芦画瓢写了一段。运行后没效果啊。
太菜了,不解。不知大牛们能否指点一二?
[COLOR="Sienna"]#include[/COLOR] "ntddk.h"
[COLOR="Sienna"]#define[/COLOR] DELAY_ONE_MICROSECOND (-10)
[COLOR="Sienna"]#define[/COLOR] DELAY_ONE_MILLISECOND (DELAY_ONE_MICROSECOND*1000)
static KEVENT s_event;
[COLOR="Navy"]void [/COLOR] MyThreadProc(PVOID context)
{
LARGE_INTEGER My_interval;
My_interval.QuadPart = DELAY_ONE_MILLISECOND;
[COLOR="SeaGreen"]// 睡眠12秒[/COLOR]
My_interval.QuadPart *= 12;
KeDelayExecutionThread(KernelMode, 0, &My_interval);
KdPrint(("fuck you"));
KeSetEvent(&s_event);
PsTerminateSystemThread(STATUS_SUCCESS);
}
[COLOR="Navy"]NTSTATUS [/COLOR] DriverEntry (
IN PDRIVER_OBJECT pDriverObject,
IN PUNICODE_STRING pRegistryPath )
{
HANDLE thread = NULL;
NTSTATUS status;
status = PsCreateSystemThread(&thread,0L,NULL,NULL,NULL,MyThreadProc,NULL);
ZwClose(thread);
KeWaitForSingleObject(&s_event,Executive,KernelMode,0,0);
[COLOR="Navy"]return [/COLOR]status;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课