Windows内核-显示OS的版本

显示OS的major,minor,build版本Number:

#include <ntddk.h>

void SampleUnload(_In_ PDRIVER_OBJECT DriverObject)
{
UNREFERENCED_PARAMETER(DriverObject);
KdPrint(("Sample driver Unload called! \n"));
}
void PrintOsVersion(PRTL_OSVERSIONINFOW lp)
{
DbgPrint("The major OS version number = %u\n", lp->dwMajorVersion);
DbgPrint("The minor OS version number = %u\n", lp->dwMinorVersion);
DbgPrint("The build OS version number = %u\n", lp->dwBuildNumber);
DbgPrint(("Print is over"));
}


extern "C"
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath) {
DriverObject->DriverUnload = SampleUnload;
UNREFERENCED_PARAMETER(RegistryPath);
OSVERSIONINFOW test;
test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
RtlGetVersion(&test);
PrintOsVersion(&test);
KdPrint(("Sample driver initialized successfully\n !"));

return STATUS_SUCCESS;
}