News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

[API] GetVersionEx

Started by ThatsTheLive, May 10, 2009, 02:24:11 PM

Previous topic - Next topic

ThatsTheLive

Hi,

I just need a quick help.

I want to differ between XP and Vista with GetVersionEx.
But, I don't get it how to declare "OSVERSIONINFO"
I thought like this:

GetOS      OSVERSIONINFO       <>

But it won't work...

A CodeSnippet how to differ between Vista and XP would be nice...

Slugsnack

was going to write it out for you.. but way too many cases.  have a look at this :
http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx

Vortex

Hi ThatsTheLive,

This is the definition of the structure found in windows.inc :


OSVERSIONINFOA STRUCT
  dwOSVersionInfoSize   DWORD      ?
  dwMajorVersion        DWORD      ?
  dwMinorVersion        DWORD      ?
  dwBuildNumber         DWORD      ?
  dwPlatformId          DWORD      ?
  szCSDVersion          BYTE 128 dup (?)
OSVERSIONINFOA ENDS


Did you try this one in the uninitialized data (.data?) section?

GetOS      OSVERSIONINFO       <?>

ecube

That structures out of date and doesn't support Vista+ here's the updated version

http://www.masm32.com/board/index.php?topic=8802.0

dedndave

is it just me, or is he missing an "A" at the end of "OSVERSIONINFOA"

ecube

funny the link I posted above with the update structure for vista had a bug in it, peoples comments from awhile ago were mentioning but didn't know why. I glanced at the code two seconds ago and fixed the bug :P. I was moving the SIZEOF of the old structure into the new so the additional variables weren't being used.

Slugsnack

No when you leave out the A it assumes the ASCII form of it.  eg. MessageBox -> MessageBoxA by assembler

E^cube that thread regards the OSVERSIONINFOEX structure instead..

Just made this :


Am running Windows Server 2008 SP2 final MSDN/TechNet release.  As you can see the structure defines okay and GetVersionEx call appears to work

UtillMasm


donkey

Quote from: Slugsnack on May 10, 2009, 03:21:32 PM
No when you leave out the A it assumes the ASCII form of it.  eg. MessageBox -> MessageBoxA by assembler

The assembler does not "assume ASCII", the function is relabeled to its ANSI version by your include files, you could just as easily have the function relabeled to a unicode variant though I believe MASM32 is ANSI only.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Slugsnack

yeah sorry meant ANSI.  it assumes that from the inc files.

MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
MessageBox equ <MessageBoxA>


ragdog

Hi

I have a question to detect if vista,2008,or win7



GetWinOS proc
Local info:OSVERSIONINFOEXnew
       mov info.dwOSVersionInfoSize,SIZEOF OSVERSIONINFO
    invoke GetVersionEx, ADDR info

.if info.dwPlatformId == VER_PLATFORM_WIN32_NT
    .if( info.dwMajorVersion == 6 && info.dwMinorVersion == 1  )
        .if info.wProductType == VER_NT_WORKSTATION
            invoke MessageBox,0,CTEXT ("Windows 7"),0,MB_OK
           .else
                invoke MessageBox,0,CTEXT ("Windows Server 2008"),0,MB_OK
        .endif
   .endif
.endif
ret
GetWinOS endp


This vista detect if not this proplem only this

I look by msdn http://msdn.microsoft.com/en-us/library/ms724429%28VS.85%29.aspx
And translate this to masm

if( osvi.wProductType == VER_NT_WORKSTATION )
                StringCchCat(pszOS, BUFSIZE, TEXT("Windows 7 "));
            else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2008 R2 " ));

I have installe win7 ultimate and my code detect win2008 why?

Thanks

dedndave

the descriptive text they provide in the function definition is a little bit meaningless, sometimes   :P
it is best to look at version numbers to determine the version

if you go to the following thread...
download the last version in the first post
then, to see the results from several members, browse the entire thread
the first page of the thread is earlier versions of the test software
the last few pages are primarily concerned with ID'ing older OS's
so pages 2 and 3 of the thread are most useful
this will help you figure out which values to examine for the detection you want

http://www.masm32.com/board/index.php?topic=11963.0

ragdog

Can i only detect it over the registry?

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
ProductName

works this of all os winxp - win7?

Thanks

dedndave

you can do it that way, but using GetVersionEx is probably easier because of virtualized registry in newer OS's
i am not sure if that portion of the registry is virtualized or not
some values, however, may not be returned by the API function
it depends on which values you need to use in order to provide the level of detection you need
of course, using an API function is always simpler than reading registry values - lol