News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

OS Info for Windows 8 and 10

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

Previous topic - Next topic

TouEnMasm

To jj,
offer you a complete read;

Just answer 0 as wProductType.
I add now:
0 as wSuiteMask

Results on Windows 10

Fa is a musical note to play with CL

dedndave

i suspect that RtlGetVersion ultimately gets the answer from here...

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"CurrentVersion"="6.3"


and, registry values can be overwritten
it would probably have little effect if you overwrote that with "6.2"
the fact that it could be modified might be the issue

jj2007

Quote from: dedndave on October 05, 2015, 05:48:03 AM
i suspect that RtlGetVersion ultimately gets the answer from here...

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"CurrentVersion"="6.3"

Not really...
77AEA099                  ³.  64:A1 18000000           mov eax, fs:[18]
77AEA09F                  ³.  53                       push ebx
77AEA0A0                  ³.  56                       push esi
77AEA0A1                  ³.  8B75 08                  mov esi, [ebp+8]
77AEA0A4                  ³.  57                       push edi
77AEA0A5                  ³.  8B78 30                  mov edi, [eax+30]
77AEA0A8                  ³.  8B87 A4000000            mov eax, [edi+0A4] #####       6   #####
77AEA0AE                  ³.  8946 04                  mov [esi+4], eax
77AEA0B1                  ³.  8B87 A8000000            mov eax, [edi+0A8] #####       1   #####
77AEA0B7                  ³.  8946 08                  mov [esi+8], eax


@Yves:  :dazzled: :dazzled: :dazzled:

dedndave

oh, i see - it gets it from the TEB (or TIB)
well - we could get it from the TEB easier than calling RtlGetVersion - lol

...get the regular OS version struct
then, if it's windows 8, let the TEB decide the minor version

TouEnMasm


Wmi script: .vbs

set WMI = GetObject("WinMgmts:/root/cimv2")
set objs = WMI.InstancesOf("Win32_OperatingSystem")
for each obj in objs
WScript.Echo obj.GetObjectText_
next
Fa is a musical note to play with CL

TouEnMasm


This one use wmi to give the answer
Must be perfectly correct
Fa is a musical note to play with CL

jj2007

Quote from: ToutEnMasm on October 06, 2015, 12:13:14 AM

This one use wmi to give the answer
Must be perfectly correct

Umpf... I thought Win7 was 6.1...
_WIN32_WINNT equ 00000600h

In contrast, this gives the correct value:
RtlGetNtVersionNumbers:
major   6
minor   1
build   7601

hutch--

 :biggrin:

Later version seems to get the OS correct.


Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz
Microsoft Windows 7 Ultimate  Version: 6.1.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

Quote from: hutch-- on October 06, 2015, 01:31:17 AM
:biggrin:

Later version seems to get the OS correct.

I cheated: Vista compatibility mode :biggrin:

But adeyblue's discovery is not affected, because RtlGetNtVersionNumbers returns hardcoded version numbers.

The issue here is whether you really want to know the OS version, then RtlGetNtVersionNumbers is the way to go, or whether you want to tell your app "you are running in xyz, believe it or not". The other options rely on the TIB, and Windows will set it based on compatibility modes.

TouEnMasm


I really want to have two methods to verify the value of the switch constants,who are importants

Quote
Microsoft Windows 7 Ultimate  Version: 6.1.7601

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

"Microsoft Windows 7 Ultimate  Version: 6.1.7601" is given by WMI

_WIN32_WINNT equ 00000601h is given by RtlGetVersion

Here ,I am happy, the two give the same result.




Fa is a musical note to play with CL

dedndave

this seems fairly simple...

        ASSUME   FS:Nothing

        mov     edx,fs:[30h]
        mov     eax,[edx+0A4h]
        push    edx
        print   ustr$(eax),'.'
        pop     edx
        mov     eax,[edx+0A8h]
        print   ustr$(eax),13,10

        ASSUME  FS:ERROR

rrr314159

@dedndave,

that gets my vote for simplest routine, works on my machines. It reports compatibility mode value, right?
I am NaN ;)

dedndave

that method doesn't care about compatibility mode or a manifest
we just need to test it on a windows 8.1 system, is all
i am pretty sure it will work

jj2007

Quote from: dedndave on October 06, 2015, 08:19:46 AM
that method doesn't care about compatibility mode or a manifest

Indeed! Surprisingly, if I apply Vista to that exe, it still reports 6.1, i.e. Win7. I thought the TIB was modified by the compatibility settings ::)

rrr314159

Quote from: dedndavewe just need to test it on a windows 8.1 system

- yes, it says 6.3

Quote from: jj2007I thought the TIB was modified by the compatibility settings

- so did I ?
I am NaN ;)