Equivalent function in kernel mode for GetSystemTimeAsFileTime

Hi OSR,
I have developed a driver in kernel mode, I need to access the current
system time in my driver
I have called OSAL library in my driver, it is legacy driver .
I need to write a function GetSystemTimeAsFileTime in Kernel mode.
Current it works in user mode,

Kindly let me know how to use and get the current system time in Kernel
mode.

Regards
Kumarjan5

You’re in luck! KeQuerySystemTime in fact returns UTC in 64 bit format, same as GetSystemTimeAsFileTime returns it in FILETIME structure.

Hi grigora,

Thanks a lot!

Regards
Kumarjan5!
On 14-Aug-2014 1:54 AM, wrote:

> You’re in luck! KeQuerySystemTime in fact returns UTC in 64 bit format,
> same as GetSystemTimeAsFileTime returns it in FILETIME structure.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Hi Grigora,

I have pTime structure which has sec and nsec (nano sec)
I need to populate these structures using current system time in my driver.
Using FILETIME ft in KeQuerySystemTime(&ft) will crash the driver,
(FILETIME structure is defined in windows.h) GetSystemTimeAsFileTime will
cras as I am in kernel mode.

how to use it, I need to return ptime->sec and pTime->nsec after using
KeQuerySystemTime.
I can use Large interger number i.e .LARGE_INTEGER currentsystemtime.

Kindly help me.

Regards,
kumarjan5

On Thu, Aug 14, 2014 at 8:30 AM, Kumar Rao wrote:

> Hi grigora,
>
> Thanks a lot!
>
> Regards
> Kumarjan5!
> On 14-Aug-2014 1:54 AM, wrote:
>
>> You’re in luck! KeQuerySystemTime in fact returns UTC in 64 bit format,
>> same as GetSystemTimeAsFileTime returns it in FILETIME structure.
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>
>> OSR is HIRING!! See http://www.osr.com/careers
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>

KeQuerySystemTime
“Kumar Rao” wrote in message news:xxxxx@ntdev…
Hi OSR,
I have developed a driver in kernel mode, I need to access the current system time in my driver
I have called OSAL library in my driver, it is legacy driver .
I need to write a function GetSystemTimeAsFileTime in Kernel mode. Current it works in user mode,

Kindly let me know how to use and get the current system time in Kernel mode.

Regards
Kumarjan5

FILETIME is 64bit integer

KeQuerySystemTime uses the same 64bit integer, though not named “FILETIME”
“Kumar Rao” wrote in message news:xxxxx@ntdev…
Hi Grigora,

I have pTime structure which has sec and nsec (nano sec)
I need to populate these structures using current system time in my driver.
Using FILETIME ft in KeQuerySystemTime(&ft) will crash the driver, (FILETIME structure is defined in windows.h) GetSystemTimeAsFileTime will cras as I am in kernel mode.

how to use it, I need to return ptime->sec and pTime->nsec after using KeQuerySystemTime.
I can use Large interger number i.e .LARGE_INTEGER currentsystemtime.

Kindly help me.

Regards,
kumarjan5

On Thu, Aug 14, 2014 at 8:30 AM, Kumar Rao wrote:

Hi grigora,

Thanks a lot!

Regards
Kumarjan5!

On 14-Aug-2014 1:54 AM, wrote:

You’re in luck! KeQuerySystemTime in fact returns UTC in 64 bit format, same as GetSystemTimeAsFileTime returns it in FILETIME structure.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Pls send teh codes

Can also be 64Hz, depends on several factors.
“Kumar Rao” wrote in message news:xxxxx@ntdev…
Thanks. Zhang pei
It worked, what is the windows internal kernel frequency? 100 or 1000 hz. For clock rate

Regards
Kumarjan5

On 14-Aug-2014 5:29 PM, “ZhangPei” wrote:

Confused… If you want to get readable time format in Kernel, use below code:

LARGE_INTEGER st;
TIME_FIELDS tf;
KeQuerySystemTime(&st);
RtlTimeToTimeFields(&st, &tf);

=================
Best Regards!
Zhang Pei
www.yiiyee.cn/blog

From: Kumar Rao
Sent: ‎Thursday‎, ‎August‎ ‎14‎, ‎2014 ‎5‎:‎43‎ ‎PM
To: Windows System Software Devs Interest List

Hi Grigora,

I have pTime structure which has sec and nsec (nano sec)
I need to populate these structures using current system time in my driver.
Using FILETIME ft in KeQuerySystemTime(&ft) will crash the driver, (FILETIME structure is defined in windows.h) GetSystemTimeAsFileTime will cras as I am in kernel mode.

how to use it, I need to return ptime->sec and pTime->nsec after using KeQuerySystemTime.
I can use Large interger number i.e .LARGE_INTEGER currentsystemtime.

Kindly help me.

Regards,
kumarjan5

On Thu, Aug 14, 2014 at 8:30 AM, Kumar Rao wrote:

Hi grigora,

Thanks a lot!

Regards
Kumarjan5!

On 14-Aug-2014 1:54 AM, wrote:

You’re in luck! KeQuerySystemTime in fact returns UTC in 64 bit format, same as GetSystemTimeAsFileTime returns it in FILETIME structure.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer