News:

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

Main Menu

Retrieving Windows OS Version

Started by bluedevil, June 06, 2017, 01:40:10 AM

Previous topic - Next topic

nidud

#30
deleted

nidud

#31
deleted

bluedevil

@nidud: immediate reply
dude i just added "/D__UNICODE__" to assembler. And you know what happened? This line:
print addr rtlOsvx.szCSDVersion
gave the correct answer. But the rest of the application turn chinese :dazzled: ::)
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

nidud

#33
deleted

bluedevil

OK, thanks ppl for taking your time and sharing thoughts. I attached my code. I have tested on:
Win10 x64 - Host machine
Win07 x86 - Guest
WinXP x86 - Guest
All worked.
I could retrieve information from GetVersion, GetVersionEx, RtlGetVersion, PEB and Registry. Only retrieving version info from msvcrt.dll is wrong both in Win10 and Win7. But for me PEB is the fastest and reliable.
Thanks again  8) :eusa_dance:
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

jj2007

Quote from: blue_devil on June 14, 2017, 11:33:26 PMPEB is the fastest

How can we resist the temptation to time this one?This is Windows version 6.1, build 7601

54 ms   MbWinVersion
252 ms  RtlGetVersion

This is Windows version 6.1, build 7601

;)

bluedevil

Quote from: jj2007 on June 15, 2017, 12:06:49 AM
Quote from: blue_devil on June 14, 2017, 11:33:26 PMPEB is the fastest

How can we resist the temptation to time this one?This is Windows version 6.1, build 7601

54 ms   MbWinVersion
252 ms  RtlGetVersion

This is Windows version 6.1, build 7601

;)
:eusa_clap:
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

Siekmanski

GetVersionEx give the wrong windows version for Windows 8.1 ( it returns Windows 8 )
Creative coders use backward thinking techniques as a strategy.

bluedevil

Quote from: Siekmanski on June 15, 2017, 12:34:42 AM
GetVersionEx give the wrong windows version for Windows 8.1 ( it returns Windows 8 )

Yes because of M$**, right jj2007?
I could't manifest the console programs. msdn says:
Quote[GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions]

With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version. The value returned by the GetVersionEx function now depends on how the application is manifested.

Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases. To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.

it is not possible to manifest console programs right?
..Dreams make the future
But the past never lies..
BlueDeviL // SCT
My Code Site:
BlueDeviL Github

jj2007

Quote from: blue_devil on June 15, 2017, 12:53:31 AMit is not possible to manifest console programs right?

Why not?

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Print "Running with common controls version ", ComCtl32$()
  xchg MbWinVersion(), ecx
  Inkey Str$(" on Windows version %i.", MbWinVersion()), Str$(ecx)
EndOfCode


Running with common controls version 6.16 on Windows version 6.1

TWell

Manifest can be external too, so you can add it afterwards.
My.exe.manifest<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application>
     <!-- Windows 10 -->
     <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
     <!-- Application supports Windows 8.1 -->
     <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
     <!-- Application supports Windows 8 -->
     <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
     <!-- Application supports Windows 7 -->
     <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
     <!-- Application supports Windows Vista -->
     <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
  </application>
</compatibility>

</assembly>

nidud

#41
deleted

TWell

#42
That example program crash in Windows 8.1
But a program with same idea show 6.3

nidud

#43
deleted

Vortex

nidud's method works fine on Windows XP 64-bit :

include     GetOSvers.inc

.data

kernel32    db 'kernel32.dll',0
str1        db 'Major Operating System Version = %u',13,10
            db 'Minor Operating System Version = %u',13,10,0

.data?

buffer      db 128 dup(?)

.code

start:

    invoke  GetModuleHandle,ADDR kernel32
    test    eax,eax
    jz      @f
   
    add     eax,IMAGE_DOS_HEADER.e_lfanew[eax]

    movzx   ecx,IMAGE_NT_HEADERS.OptionalHeader.MajorOperatingSystemVersion[eax]
           
    movzx   edx,IMAGE_NT_HEADERS.OptionalHeader.MinorOperatingSystemVersion[eax]

    invoke  wsprintf,ADDR buffer,ADDR str1,ecx,edx
    invoke  StdOut,ADDR buffer
@@:
    invoke  ExitProcess,0

END start


GetOSvers.exe
Major Operating System Version = 5
Minor Operating System Version = 2