获取驱动获取当前系统时间
直接上程序:
void GetCurrentTimeToWchar(WCHAR *szTime)
{
LARGE_INTEGER snow;
LARGE_INTEGER now;
TIME_FIELDS now_Fields;
//WCHAR szTime[32] = { 0 };
//获得标准时间
KeQuerySystemTime(&snow);
//转换为当地时间
ExSystemTimeToLocalTime(&snow, &now);
//转换为 TIME_FIELDS
RtlTimeToTimeFields(&now, &now_Fields);
//打印
RtlStringCchPrintfW(
szTime,
32 * 2,
L"%4d-%2d-%2d %2d:%2d:%2d",
now_Fields.Year, now_Fields.Month, now_Fields.Day,
now_Fields.Hour, now_Fields.Minute, now_Fields.Second
);
return;
}
调用:
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriver, PUNICODE_STRING pReg)
{
DbgPrint("pdriver = %wZ, , %x\n", pReg, pDriver);
//获取系统当前时间
WCHAR szTime[32] = { 0 };
GetCurrentTimeToWchar(szTime);
DbgPrint("CurrentTime = %ws \n", szTime);
return STATUS_SUCCESS;
}