Author Topic: OS Info for Windows 8 and 10  (Read 44356 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: OS Info for Windows 8 and 10
« Reply #30 on: October 05, 2015, 05:27:57 AM »
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

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: OS Info for Windows 8 and 10
« Reply #31 on: October 05, 2015, 05:48:03 AM »
i suspect that RtlGetVersion ultimately gets the answer from here...

Code: [Select]
[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

  • Member
  • *****
  • Posts: 13005
  • Assembler is fun ;-)
    • MasmBasic
Re: OS Info for Windows 8 and 10
« Reply #32 on: October 05, 2015, 06:10:11 AM »
i suspect that RtlGetVersion ultimately gets the answer from here...

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

Not really...
Code: [Select]
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

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: OS Info for Windows 8 and 10
« Reply #33 on: October 05, 2015, 06:12:49 AM »
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

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: OS Info for Windows 8 and 10
« Reply #34 on: October 05, 2015, 07:13:56 AM »

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

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: OS Info for Windows 8 and 10
« Reply #35 on: October 06, 2015, 12:13:14 AM »

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

jj2007

  • Member
  • *****
  • Posts: 13005
  • Assembler is fun ;-)
    • MasmBasic
Re: OS Info for Windows 8 and 10
« Reply #36 on: October 06, 2015, 01:10:21 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--

  • Administrator
  • Member
  • ******
  • Posts: 9798
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: OS Info for Windows 8 and 10
« Reply #37 on: October 06, 2015, 01:31:17 AM »
 :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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13005
  • Assembler is fun ;-)
    • MasmBasic
Re: OS Info for Windows 8 and 10
« Reply #38 on: October 06, 2015, 03:45:38 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

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: OS Info for Windows 8 and 10
« Reply #39 on: October 06, 2015, 05:17:53 AM »

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

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: OS Info for Windows 8 and 10
« Reply #40 on: October 06, 2015, 06:59:37 AM »
this seems fairly simple...

Code: [Select]
        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

  • Member
  • *****
  • Posts: 1378
Re: OS Info for Windows 8 and 10
« Reply #41 on: October 06, 2015, 07:13:30 AM »
@dedndave,

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

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: OS Info for Windows 8 and 10
« Reply #42 on: October 06, 2015, 08:19:46 AM »
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

  • Member
  • *****
  • Posts: 13005
  • Assembler is fun ;-)
    • MasmBasic
Re: OS Info for Windows 8 and 10
« Reply #43 on: October 06, 2015, 10:02:13 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

  • Member
  • *****
  • Posts: 1378
Re: OS Info for Windows 8 and 10
« Reply #44 on: October 06, 2015, 10:32:38 AM »
Quote from: dedndave
we just need to test it on a windows 8.1 system

- yes, it says 6.3

Quote from: jj2007
I thought the TIB was modified by the compatibility settings

- so did I ?
I am NaN ;)