views:

23

answers:

2

How can I have a timer in kernel mode such that a specified function in my driver is called approximately every second on Windows XP and above? I should be able to use all functions (in particular ZwQuerySystemInformation) in the function. I do not need a high resolution timer or millisecond accuracy or anything like that, I just need a way to schedule a function to be run about once per second in kernel mode and it must work on all 32 bit systems windows xp and higher.

+1  A: 

Create a kernel timer via KeInitializeTimer.
Set the timer with KeSetTimerEx and use a period of 1s.
Create a thread in your driver.
In the thread, call KeWaitForSingleObject to wait on the timer and upon return, call your function.
Repeat.

Brian
+1  A: 

You can use KeDelayExecutionThread within a loop in your thread.

Sergius