Search code examples
c++wdk

Can't include wdm.h and ntifs.h in the same file


My compiler (vs2012) refuse to compile the following lines of code. He postes redefintion of Symbols for PEPROCESS and PETHREAD. How can i workaround this? And why can't i use both headers?

 #include <wdm.h>
 #include <Ntifs.h>

double hal_datetime_utc_now()
{
   LARGE_INTEGER gmtTime;
   KeQuerySystemTime(&gmtTime);

   ULONG utc_now;
   RtlTimeToSecondsSince1970(&gmtTime, &utc_now);
   return (double)utc_now;
}

Solution

  • I found the solution myself. In my scenario, i can remove the wdm.h. Because KeQuerySystemTime is also included in ntifs.h. So i can simply remove wdm.h.

    EDIT: typo: replace wdm.h with ntifs.h