time_t

Is there anyway to use the libc time functions within a driver? Would you want to or this there some kernel api equivalent which is more suited?

Googling and reading the DDK I am starting to wonder if there is.

(I did try using time.h but got linker errors and I found a post from Mr Roddy saying the libc linking a driver is a serious no - no)

Specifically I want to record the time a network packet arrived, and then the time it took to be processed so I can disdard packets older than a certain age.

Best suggestion is to use NdisGetCurrentSystemTime.

There is also KeQueryTickCount.

Thomas F. Divine
http://www.ndis.com


From:
Sent: Wednesday, August 25, 2010 1:23 PM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] time_t

> Is there anyway to use the libc time functions within a driver? Would you
> want to or this there some kernel api equivalent which is more suited?
>
> Googling and reading the DDK I am starting to wonder if there is.
>
> (I did try using time.h but got linker errors and I found a post from Mr
> Roddy saying the libc linking a driver is a serious no - no)
>
> Specifically I want to record the time a network packet arrived, and then
> the time it took to be processed so I can disdard packets older than a
> certain age.
>
> —
> NTDEV is sponsored by OSR
>
> 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

xxxxx@yahoo.co.uk wrote:

Is there anyway to use the libc time functions within a driver? Would you want to or this there some kernel api equivalent which is more suited?

(I did try using time.h but got linker errors and I found a post from Mr Roddy saying the libc linking a driver is a serious no - no)

Well, that’s a bit of an exaggeration. There is a library called
“libcntpr.lib” that provides much of the C standard run-time library for
kernel drivers. However, it can’t provide functions for which there are
no corresponding kernel services. That means no file I/O, and no time
routines.

Specifically I want to record the time a network packet arrived, and then the time it took to be processed so I can disdard packets older than a certain age.

Won’t KeQuerySystemTime do what you want? That’s a low-impact
operation, although it’s only updated at schedular intervals, so it has
a granularity of about 16ms.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Fantastic. Thanks for your quick response.

Charlie

KeQuerySystemTime
ExSystemTimeToLocalTime
ExLocalTimeToSystemTime

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.co.uk
Sent: Wednesday, August 25, 2010 10:33 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] time_t

Fantastic. Thanks for your quick response.

Charlie


NTDEV is sponsored by OSR

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

> Is there anyway to use the libc time functions within a driver? Would you want to or this there some

kernel api equivalent which is more suited?

LONGLONG is time in Windows. The number of 100ns units since year 1601.

In user mode, it is renamed FILETIME (a structure with single LONGLONG in it). There are lots of FILETIME functions in Win32.

In kernel mode, it is just LONGLONG or LARGE_INTEGER.

If you need not the absolute time (which you can compare or subtract), and you need the day/month/year/hour/minute/second stuff, then this is called SYSTEMTIME in user mode (again lots of APIs) and TIME_FIELDS in kernel mode (with lots of RtlXxx APIs).

time_t is obsolete remnant of 70ies.

Specifically I want to record the time a network packet arrived

Well, for such application time_t, with its precision of 1 second, is surely funny.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com