Monday, February 16, 2015

GetVersionInfoEx Windows 10

If you are writing drivers and have check the Windows version to enable the driver, then you typically use RtlGetVersion to check the OSVERSIONINFO for the dwMajorVersion and dwMinorVersion at a minimum.

The issue I had the other day was to test my driver on Windows 10. The version numbers for Windows 8.1 and below are all readily available online, but it's probably too early for Windows 10, so I had to find it on my own.

You can skip all the attempts and failures to get the version at the end.

-- ATTEMPT #1
Write an Win32 application to get the Windows version.

-- FAILURE #1
GetVersionEx on Windows 8.1 = C4496 "GetVersionEx" is deprecated error.

-- FAILURE #2
Read the source for VersionHelpers.h to find the _WIN32_WINNT_ preprocessor definition in the Windows Kit 8.1 include headers. Only defined till Windows 8.1. In hindsight that's kind of expected. I should install the Windows Kit for Windows 10 for that.

-- ATTEMPT #2
Write a Win32 app to get the Windows version using VerifyVersionInfo.

-- FAILURE #3
The app returns 6.2 (corresponding to Windows 8.0) as mentioned in the document. After trying to add the preprocessor definition as mentioned in the documentation, and also trying the manifest route (didn't work), I googled online for the proper way to embed the valid manifest.

-- SUCCESS
A post on correctly using VerifyVersionInfo mentioned that you can get the version using WMI.
Open powershell.

PS > $os = Get-WMIObject  win32_operatingsystem
PS> $os
SystemDirectory : C:\Windows\system32
Organization    :
BuildNumber     : 9926
RegisteredUser  : <ME>
SerialNumber    : <SR_NO>
Version         : 10.0.9926

YAY!



TL;DR; RtlGetVersion for Windows 10 = 10.0.

No comments:

Post a Comment