Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:50:22+00:00 2026-06-13T04:50:22+00:00

I am modifying an existing Windows Kernel device driver and in there I need

  • 0

I am modifying an existing Windows Kernel device driver and in there I need to capture a timestamp. I was intending to use time.h library and call the clock() function to get that, however under windows visual studio, the linking is failing. So I took it as a means that I need to work within the driver’s libraries.

I found the following function, KeInitializeTimer, and KeSetTimerEx but these are used if I plan to set up a timer and wake up on it. What I really need is something that will give me a timestamp.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:50:23+00:00Added an answer on June 13, 2026 at 4:50 am

    I am updating my question with an answer for others to benefit from my findings.

    To get a timestamp, you can use KeQueryTickCount(). This routine will give you the count of interval interrupts that occurred since the system was booted. However, if you need to find out since the last timestamp you captured, an X amount of time has passed you need to also query your system to determine the time it takes for each interval clock interrupt.

    ULONG KeQueryTimeIncrement() give you the number of 100-nanosecond units.

    Example:

    PLARGE_INTEGER timeStamp;
    
    KeQueryTickCount(&timeStamp);
    

    Please note that PLARGE_INTEGER is defined as such:

    #if defined(MIDL_PASS)
    typedef struct _LARGE_INTEGER {
    #else // MIDL_PASS
    typedef union _LARGE_INTEGER {
        struct {
            ULONG LowPart;
            LONG HighPart;
        } DUMMYSTRUCTNAME;
        struct {
            ULONG LowPart;
            LONG HighPart;
        } u;
    #endif //MIDL_PASS
        LONGLONG QuadPart;
    } LARGE_INTEGER;
    

    So lets say, you want to see if 30 seconds passed since you last took a timestamp, you can do the following:

    ULONG tickIncrement, ticks;
    LARGE_INTEGER waitTillTimeStamp;
    tickIncrement = KeQueryTimeIncrement();
    

    // 1sec is 1,000,000,000 nano sec, however, since KeQueryTimeIncrement is in
    // 100ns increments, divide that and your constant is 10,000,000

    ticks = ((30 * 10,000,000) / tickIncrement);
    KeQueryTickCount(&waitTillTimeStamp);
    waitTillTimeStamp.QuadPart += ticks;
    
    <.....Some code and time passage....>
    KeQueryTickCount(&currTimeStamp);
    
    
    if (waitTillTimeStamp.QuadPart < currTimeStamp.QuadPart) {
        <...Do whatever...>
    }
    

    Another example to help you understand this, what if you want to translate the timestamp you got into a time value such as milliseconds.

    LARGE_INTEGER mSec, currTimeStamp;
    ULONG timeIncrement;
    
    timeIncrement = KeQueryTimeIncrement();
    
    
    KeQueryTickCount(&currTimeStamp);
    
    // 1 millisecond is 1,000,000 nano seconds, but remember divide by 100 to account for 
    // KeQueryTickCount granularity.
    mSec.QuadPart = (currTimeStamp.QuadPart * timeIncrement) / 10000;
    

    Remember this example is for demonstration purposes, mSec is not the current time in milliseconds. Based on the APIs used above, it is merely the number of milliseconds that have elapsed since the system was started.

    You can also use GetTickCount(), but this returns a DWORD and thus will only be able to give you the number of milliseonds since the system was started for up to 49.7 days.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am modifying an existing app.And there is an issue trying to run ADT
Thanks for your attention and time. I'm modifying an existing JavaScript but can't understand
I'm analyzing existing Windows Store applications and modifying them to make sure my company's
I'm modifying existing security code. The specifications are pretty clear, there is example code,
I'm working with Youtube API and PHP library: http://code.google.com/apis/youtube/2.0/developers_guide_php.html I'm modifying existing app: http://googlecodesamples.com/youtube/php/YouTubeVideoApp/index.php
Is there a way to tell Python about additional site-packages locations without modifying existing
I'm modifying an existing application in C++ that uses GLUT (so I can't get
I am modifying an existing HQL query which returns individual columns rather than an
I'm working on modifying some existing code for a payment gateway and I'm not
I'm trying to start modifying an existing application with Eclipse. Actually I had it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.