Pali Rohár <[email protected]> wrote:
> Hello, in past I was looking at GetVersion and GetVersionEx functions
> and I was inspecting how they works. So I think I should have all those
> information for which you are asking.
>
> Microsoft started removing most of documentation for GetVersion and
> GetVersionEx functions, but web archive has copy of it before removal:
>
> https://web.archive.org/web/20041209205313/http://msdn.microsoft.com/library/en-us/sysinfo/base/getversion.asp
> https://web.archive.org/web/20020905235730/http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp
>
> On internet can be found various dumps of WinSDK documentation,
> like from WIN32.HLP file. For example these:
>
> https://winapi.freetechsecrets.com/win32/WIN32GetVersion.htm
> https://winapi.freetechsecrets.com/win32/WIN32GetVersionEx.htm
>
> https://library.thedatadungeon.com/msdn-2000-04/sysmgmt/hh/sysmgmt/sysinfo_41bi.htm
> https://library.thedatadungeon.com/msdn-2000-04/sysmgmt/hh/sysmgmt/sysinfo_49iw.htm
>
> Also there are some undocumented parts of GetVersion function, specially
> what is filled in reserved bits. I was running different tests in the
> past and here is hopefully the full documentation. I was also checking
> the wine sources in past and it confirms it.
>
> GetVersion returns DWORD with these bits:
> [31:30] - PlatformId XORed with 0b10
> [29:16] - BuildNumber
> [15:08] - MinorVersion
> [07:00] - MajorVersion
>
> The highest bit [31] is also indicating (when set) if the OS is DOS based.

It is really nice that it is possible to distinguish NT-based and DOS-based 
systems using just DWORD value returned by GetVersion; this means there is no 
need for GetVersionEx, at least for my use case.

Since I only care about Windows NT and Windows 9x, and not Win32s, checking the 
high bit to distinguish them will just do.

> GetVersionEx is returning what is written in MS documentation, just
> compared with GetVersion, on Win32s is GetVersionEx returning the
> Win32s version (1.30), and GetVersion is returning OS version (3.11).

So there is a difference on Win32s.

> PlatformId is one of:
> VER_PLATFORM_WIN32s - Win32s
> VER_PLATFORM_WIN32_WINDOWS - Win9x
> VER_PLATFORM_WIN32_NT - WinNT
> (in both GetVersionEx and GetVersion, just be aware of XOR 0b10)

IMO, it is really annoying that Microsoft decided to remove this information 
from documentation; interestingly enough, all three constants are still present 
in winnt.h, though no comments to give any context about their usage.

> There is also VER_PLATFORM_WIN32_CE which indicates Windows CE
> implementation , but Windows CE does not support running PE
> IMAGE_SUBSYSTEM_WINDOWS_GUI and PE IMAGE_SUBSYSTEM_WINDOWS_CUI binaries
> and it also does not have GetVersion function at all. Only GetVersionEx.
> So mostly you can ignore CE.

Yep. Just like details about Win32s, which I do not intent to touch at all.

> Therefore if you want to check for all possible OS system variants, the
> GetVersion() function is universal, available on all implementations and
> contains mostly everything what you need.

>From all the information I have so far, it seems like there is no way to 
>distinguish Windows 95/98/Me from each other. Or maybe bits in high-order word 
>supply some of extra information?

- Kirill Makurin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to