在Windows内核模式下获取UTC时间

时间:2017-04-20 14:48:07

标签: c++ windows kernel-mode

如何在Windows内核模式下获取时间?

我知道KeQuerySystemTime(但这是基于1601的。)

我找到了这个解决方案。

LONGLONG FileTime_to_POSIX(FILETIME ft)
{
    // takes the last modified date
    LARGE_INTEGER date, adjust;

    date.HighPart = ft.dwHighDateTime;
    date.LowPart = ft.dwLowDateTime;

    // 100-nanoseconds = milliseconds * 10000
    adjust.QuadPart = 11644473600000 * 10000;

    // removes the diff between 1970 and 1601
    date.QuadPart -= adjust.QuadPart;

    // converts back from 100-nanoseconds to seconds
    return date.QuadPart / 10000000;
}

但这似乎是错误的,我测试了它并且它错了大约10秒

0 个答案:

没有答案