2

I am working on a Windows NDIS driver using the latest WDK that is in need of a millisecond resolution kernel time counter that is monotonically non-decreasing. I looked through MSDN as well as WDK's documentation but found nothing useful except something called TsTime, which I am not sure whether is just a made-up name for an example or an actual variable. I am aware of NDISGetCurrentSystemTime, but would like to have something that is lower-overhead like ticks or jiffies, unless NDISGetCurrentSystemTime itself is low-overhead.

It seems that there ought to be a low-overhead global variable that stores some sort of kernel time counter. Anyone has insight on what this may be?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
software engineer
  • 271
  • 1
  • 4
  • 15

2 Answers2

1

How about GetTickCount / GetTickCount64 (Check the reqs on the latter)

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • +1 This is the best cheap timer if one wants it reasonably precise with little overhead, but not necessarily with high resolution. – Damon May 11 '11 at 18:00
  • My bad. I didn't realized Alex linked the doc to GetTickCount. I also was negligent in not stating that I am using WDK to develop the NDIS driver so the function has to be available in the latest WDK, which GetTickCount doesn't appear to be. The documentation Alex linked appears to be Win2000. – software engineer May 11 '11 at 18:36
  • Beaten to KeQueryTickCount, also the win2000 note is the minimum requirement - meaning unless its otherwise stated, its supported in all subsequent versions – Alex K. May 11 '11 at 18:44
1

Use KeQueryTickCount. And perhaps use KeQueryTimeIncrement once to be able to convert the tick count into a more meaningful time unit.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152