BugTrap icon indicating copy to clipboard operation
BugTrap copied to clipboard

Windows version detect issue

Open GoldRenard opened this issue 10 years ago • 8 comments

CSymEngine::GetOsInfo(COsInfo& rOsInfo) uses deprecated GetVersionEx API. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2).

We need to find out better way to get windows version, including real major/minor versions, product type, etc.

For a workaround, I just take kernel32.dll version: https://github.com/GoldRenard/BugTrap/commit/ab264288d75990f6f9407ef371187ee919970eee In this way we don't know the real product type, so we can't detect is it server OS or client.

GoldRenard avatar Aug 08 '15 22:08 GoldRenard

Yeah, this is an interesting issue ... I don't know if this helps any:

http://stackoverflow.com/questions/9817160/getversionex-under-windows-8

http://stackoverflow.com/questions/27246562/how-to-get-the-os-version-in-win8-1-as-getversion-getversionex-are-deprecated

Perhaps, GetProductInfo to help find if server or client OS.

bchavez avatar Aug 09 '15 01:08 bchavez

There are a bunch of new macros from MSDN that are preferable way to get version information in new SDK: https://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx

zabulus avatar Oct 13 '15 07:10 zabulus

Some of this new macros has issues. New macros, immediately new bugs :| To get IsWindows8Point1OrGreater() or IsWindows10OrGreater() working the module needs a manifest included. Btw: I have installed SDK 8.1 but IsWindows10OrGreater() is not included in my VersionHelpers.h.

As mentioned by Ehsan A Samani in an article on CodeProject (http://www.codeproject.com/Articles/678606/Part1-Overcoming-Windows-8-1s-deprecation-of-GetVe#Update) the old but not deprecated function NetWkstaGetInfo() can also be used to get major and minor version. I'm not sure how to distinguish then between workstation and server.

sesom42 avatar Oct 14 '15 09:10 sesom42

working the module needs a manifest included.

Of course, it is by design and not a bug. Windows 10 compatible applications must include the manifest so the OS can differentiate the compatibility behavior. If an app doesn't have the manifest, it shouldn't know anything about new OS.

SDK 8.1 but IsWindows10OrGreater()

Because you need SDK 10 for this to be available.

zabulus avatar Oct 14 '15 11:10 zabulus

I've also made a Win-version (+ServPack+build-number) retriever where I compare the OSVERSIONINFOEXW structures obtained from GetVersionEx(), RtlGetVersion() and NetWkstaGetInfo(). It is here.

gvanem avatar Feb 06 '16 09:02 gvanem

@gvanem could you clarify the licence for win_ver.c?

bchavez avatar Feb 11 '16 00:02 bchavez

@bchavez I've not thought of it, but a MIT License is fine.

gvanem avatar Feb 11 '16 08:02 gvanem

For people who search how to setup a manifest, just add this file in the project who use BugTrap.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity 
        name="YOURAPPNAME" 
        version="1.0.0.0" 
        type="win32" />
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
        <application> 
            <!-- Windows 10 & 11 --> 
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
            <!-- Windows 8.1 -->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
            <!-- Windows 8 -->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
            <!-- Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>      
            <!-- Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>          
        </application> 
    </compatibility>
</assembly>

gaetandezeiraud avatar Mar 18 '23 08:03 gaetandezeiraud