Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kernel mode timer

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.

like image 484
David Chang Avatar asked Jul 20 '26 16:07

David Chang


2 Answers

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.

like image 72
Brian Avatar answered Jul 22 '26 06:07

Brian


You can use KeDelayExecutionThread within a loop in your thread.

like image 43
Sergey Podobry Avatar answered Jul 22 '26 06:07

Sergey Podobry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!