News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

OS Info for Windows 8 and 10

Started by dedndave, October 02, 2015, 07:14:44 AM

Previous topic - Next topic

sinsi

Dave, this might be of use - Targeting your application for Windows
QuoteIn Windows 8.1 and Windows 10, the GetVersion and GetVersionEx APIs have been deprecated and superseded by the Version Helper APIs. While you can still call the deprecated APIs, if your application does not specifically target Windows 8.1 or Windows 10, you will get Windows 8 version (6.2.0.0).

In order to target Windows 8.1 or Windows 10, you need to include the app manifest in the source file.

jj, you can still build exes for 2000 because the version helpers use APIs that 2000 has.
Attached is the header from the Win10 SDK.

TouEnMasm

The version helper can be very useful with a lib who include it's functions.
Quote
jj2007's GetVersionInfo, posted above, agrees, so apparently 8.1 = 6.3! Microsoft needs to hire better arithmeticians
The Major and minor version must be read with the help of:
https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms724833(v=vs.85).aspx
6.3 = Windows 8 or Windows Server 2012 R2
Fa is a musical note to play with CL

TouEnMasm

good advice
Quote
In Windows 8.1 and Windows 10, the GetVersion and GetVersionEx APIs have been deprecated and superseded by the Version Helper APIs. While you can still call the deprecated APIs, if your application does not specifically target Windows 8.1 or Windows 10, you will get Windows 8 version (6.2.0.0).

In order to target Windows 8.1 or Windows 10, you need to include the app manifest in the source file

I try to made that without any modify on the answer of GetVersionInfoEx

I have added that to my rc file

Quote
#define _NT_TARGET_VERSION $(_NT_TARGET_VERSION_LATEST)
#define IDR_VERSION1 1
#define SXS_MANIFEST_RESOURCE_ID  1
#define SXS_MANIFEST "cpusys.manifest"
#define SXS_ASSEMBLY_NAME "Microsoft.Windows.Foo"
#define SXS_ASSEMBLY_VERSION 1.0   
#define SXS_ASSEMBLY_LANGUAGE_INDEPENDENT 1
#define SXS_MANIFEST_IN_RESOURCES 1

cpusys.manifest is the same as the html page
Fa is a musical note to play with CL

jj2007

Quote from: sinsi on October 03, 2015, 10:57:17 PMjj, you can still build exes for 2000 because the version helpers use APIs that 2000 has.

Yes, it uses VerifyVersionInfoW, which in turn calls good ol' RtlGetVersion, the one I used in my code. Thanks for the header file, I had seen an unofficial one somewhere, good to have the original.

QuoteWhile you can still call the deprecated APIs, if your application does not specifically target Windows 8.1 or Windows 10, you will get Windows 8 version (6.2.0.0).

RtlGetVersion returns 6.3 on Windows 8.1, without manifest. The logic "manifest-wise my application is not specifically targeted for 8.1, so I want the OS to fake an 8.0" is rather redmondish  :eusa_boohoo:

TouEnMasm

http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe?msg=5080848#xx5080848xx

return 10.0 with Windows 10
invoke DllRtlGetVersion,TXT("ntdll.dll"),addr osvi ;GetVersionEx

Quote
.data
   osvi OSVERSIONINFOEX <>
.code
DllRtlGetVersion PROC  pnameddll:DWORD,  posversion:DWORD
         Local Hlib:DWORD
         Local  retour:DWORD
         mov retour,0 ;failed
   invoke LoadLibrary,pnameddll
   mov Hlib,eax
   .if eax != 0
      Invoke GetProcAddress,Hlib,TXT("RtlGetVersion")
      .if eax != 0
         mov edx,posversion
         mov [edx].OSVERSIONINFOEX.dwOSVersionInfoSize,sizeof OSVERSIONINFOEX
         push posversion
         call eax
         pop edx
         .if eax != 0
            mov retour,1      ;succès
         .endif      
      .endif   
      invoke FreeLibrary,Hlib
   .endif
   
FindeDllRtlGetVersion:
         mov eax,retour
         ret
DllRtlGetVersion endp   

Fa is a musical note to play with CL

TouEnMasm

#20
Here a test prog

i find an inversion on:
Windows  OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION

To view Windows 10 in the zip,OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION

Perhaps is there the same problem with other system ??
Fa is a musical note to play with CL

dedndave

must be 64-bit, Yves - can't run it on XP   :(

hutch--

Seems to work OK on my Win7 64. The "Windows Server 2008 R2" is about of the same vintage which may account for the mis identification.


Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz
Windows Server 2008 R2, Build S 7601


;constants switch for translate.inc
_WIN32_WINNT equ 00000601h
NTDDI_VERSION equ 06010000h
WINVER equ 06010000h

_MSC_VER equ   ;defaut value 1500
;Reports the major and minor versions of the compiler. For example, 1310
;for Microsoft Visual C++ .NET 2003. 1310 represents version 13 and a 1.0
;point release. The Visual C++ 2005 compiler version is 1400.

;Type cl /? at the command line to see the major and minor versions of
;your compiler along with the build number.
;http://msdn.microsoft.com/en-us/library/b0084kay(vs.80).aspx

_WIN32_IE equ  ;internet explorer version * 100h ,if 8 _WIN32_IE equ 800h
   include sdkddkver.sdk   
;How to COPY this ?
;select the text,CTRL-C to copy to the clipbord


jj2007

Hutch,
What do you get from a simple commandline ver?

Quote from: dedndave on October 04, 2015, 11:37:25 AM
i guess that would formatted as "5.1.2600 SP 3.0"

RtlGetVersion   5.1 SP 3.0 build 2600
Suite mask      0100: SINGLEUSERTS
ProductType     WORKSTATION
CSDVersion      Service Pack 3


@Dave: Thanks :icon14: So far RtlGetVersion returns correct numbers for all OS versions, including Sinsi's 10.0. It seems to be the lowest level solution, except for reading the PEB directly.

TouEnMasm

Quote
must be 64-bit, Yves - can't run it on XP 
Too bad,there is not real change that justify this.The code worked perfectly in my old xp.
It is 32 bit,it's not so easy to change from 32 to 64 in asm.
Fa is a musical note to play with CL

jj2007

Quote from: dedndave on October 04, 2015, 11:33:20 AM
must be 64-bit, Yves - can't run it on XP   :(

It is 32-bit indeed, just launch it with Olly. It displays a RichEd control with the text below.

@Yves: The cpu is OK but I'm definitely not running Windows Server 2008 R2 8)

       Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
Windows Server 2008 R2, Build S 7601


;constants switch for translate.inc
_WIN32_WINNT equ 00000601h
NTDDI_VERSION equ 06010000h
WINVER equ 06010000h

_MSC_VER equ   ;defaut value 1500
;Reports the major and minor versions of the compiler. For example, 1310
;for Microsoft Visual C++ .NET 2003. 1310 represents version 13 and a 1.0
;point release. The Visual C++ 2005 compiler version is 1400.

;Type cl /? at the command line to see the major and minor versions of
;your compiler along with the build number.
;http://msdn.microsoft.com/en-us/library/b0084kay(vs.80).aspx

_WIN32_IE equ  ;internet explorer version * 100h ,if 8 _WIN32_IE equ 800h
include sdkddkver.sdk
;How to COPY this ?
;select the text,CTRL-C to copy to the clipbord

TouEnMasm


After some test,Rtlgetversion seems to be a not very good way.
Just answer 0 as wProductType.
The god (MSDN) way is this one:
Quote
To obtain the full version number for the operating system,
call the GetFileVersionInfo function on one of the system DLLs,
such as Kernel32.dll, then call VerQueryValue to obtain
the \\StringFileInfo\\<lang><codepage>\\ProductVersion subblock of the file
version information.
Fa is a musical note to play with CL

adeyblue

Don't forget

void
__stdcall
RtlGetNtVersionNumbers(
   ULONG* pMajor,
   ULONG* pMinor,
   ULONG* pBuild
);

from XP onwards because 14 methods that return the version just wasn't enough.

TouEnMasm

Only 14 methods ??????:
If it is a game , the more powerfull is dumpbin
He found "RtlGetNtProductType"
After an acces violation,RtlGetNtProductType PROTO product:LPDWORD
He return 1 (WORKSTATION on Windows 10)
I will try to fulfill others conditions.

Fa is a musical note to play with CL

jj2007

Quote from: ToutEnMasm on October 05, 2015, 01:00:55 AMAfter some test,Rtlgetversion seems to be a not very good way.

@Yves: Which test? Show me one example where RtlGetVersion doesn't return the correct OS version number.

@adeyblue: Nice find :t And it looks really, really foolproof :icon_mrgreen:

RtlGetNtVersionNumbers    Ú$  8BFF                     mov edi, edi
77AF6CEB                  ³.  55                       push ebp
77AF6CEC                  ³.  8BEC                     mov ebp, esp
77AF6CEE                  ³.  8B45 08                  mov eax, [ebp+8]
77AF6CF1                  ³.  85C0                     test eax, eax
77AF6CF3                  ³. 74 06                    jz short 77AF6CFB
77AF6CF5                  ³.  C700 06000000            mov dword ptr [eax], 6
77AF6CFB                  ³>  8B45 0C                  mov eax, [ebp+0C]
77AF6CFE                  ³.  85C0                     test eax, eax
77AF6D00                  ³. 74 06                    jz short 77AF6D08
77AF6D02                  ³.  C700 01000000            mov dword ptr [eax], 1


RtlGetNtVersionNumbers:
major   6
minor   1
build   7601