OSRLogoOSRLogoOSRLogo x Seminar Ad

Everything Windows Driver Development

GoToHomePage xLoginx

    Fri, 19 Jan 2018     115944 members


  Online Dump Analyzer
OSR Dev Blog
The NT Insider
ListServer / Forum
Driver Jobs
  Express Links
  · The NT Insider Digital Edition - May-June 2016 Now Available!
  · Windows 8.1 Update: VS Express Now Supported
  · HCK Client install on Windows N versions
  · There's a WDFSTRING?
  · When CAN You Call WdfIoQueueP...ously

Simplifying Time Interval Specification

Personally, it's never bothered me.  But if you're mathematically challenged (like my boy Peter who has a chart in his office with "milli, micro, nano" written on it and a corresponding string of zeros for each) I can see how having to specify timeout values in NT's standard "100ns intervals" could drive you nuts.

Rob Green, a member of the NTDEV list, provides the following set of macros that'll keep you from having to scratch your head and count zeros ever again.  Using these defintions, all you'll have to do is write:

interval.QuadPart = RELATIVE(SECONDS(5));

And you'll be all set.  Thanks to Rob for his suggestion, and for his permission to share it with you here.

#define ABSOLUTE(wait) (wait)

#define RELATIVE(wait) (-(wait))

#define NANOSECONDS(nanos) \
(((signed __int64)(nanos)) / 100L)

#define MICROSECONDS(micros) \
(((signed __int64)(micros)) * NANOSECONDS(1000L))

#define MILLISECONDS(milli) \
(((signed __int64)(milli)) * MICROSECONDS(1000L))

#define SECONDS(seconds) \
(((signed __int64)(seconds)) * MILLISECONDS(1000L))


Related Articles
A New Interface for Driver Writing -- The Windows Driver Framework

User Comments
Rate this article and give us feedback. Do you find anything missing? Share your opinion with the community!
Post Your Comment

"Simplifying Time Interval Specification"
I'm so going to include this on my kernel driver definition file :P Thanks for the info!

19-Oct-11, Erkki Kekkonen

"Simplifying Time Interval Specification"
Timeout handling simplified. Pretty useful !!!

16-Sep-04, Abhijit Kulkarni

Post Your Comments.
Print this article.
Email this article.

Writing WDF Drivers I: Core Concepts

Nashua (Amherst), NH
15-19 May 2017

Writing WDF Drivers II: Advanced Implementation Techniques

Nashua (Amherst), NH
23-26 May 2017

Kernel Debugging and Crash Analysis

Dulles (Sterling), VA
26-30 Jun 2017

Windows Internals and Software Driver Development

Nashua (Amherst), NH
24-28 Jul 2017


Need to develop a Windows file system solution?

We've got a kit for that.

Need Windows internals or kernel driver expertise?

Bring us your most challenging project - we can help!

System hangs/crashes?

We've got a special diagnostic team that's standing by.

Visit the OSR Corporate Web site for more information about how OSR can help!

bottom nav links