News:

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

OS Info Dump

Started by dedndave, July 28, 2009, 01:41:48 PM

Previous topic - Next topic

dsouza123

XP Pro SP2 x86 32 bit

DednDave OS Info Dump

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"ProductName"="Microsoft Windows XP"
"CurrentVersion"="5.1"
"CurrentBuildNumber"="2600"
"SubVersionNumber"=""
"CSDVersion"="Service Pack 2"
"BuildLab"="2600.xpsp_sp2_gdr.090206-1233"
"ProductId"="76487-OEM-XXXXXXX-XXXXX"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center]
"Ident"=(Key not found)

Wistrik

Hello,

My one and only installed OS: Windows Vista 64-bit Ultimate SP2


DednDave OS Info Dump

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"ProductName"="Windows (TM) Vista Ultimate"
"CurrentVersion"="6.0"
"CurrentBuildNumber"="6002"
"SubVersionNumber"=(Value not found)
"CSDVersion"=(Value not found)
"BuildLab"="6002.lh_sp2rtm.090410-1830"
"ProductId"=(Value not found)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center]
"Ident"="5.0"

Press any key to exit


Some notes:
- I don't have "SubVersionNumber" in my registry so the display is correct for that line.
- My "CSDVersion" is actually "Service Pack 2"
- In addition to "BuildLab" there is also "BuildLabEx" which for me is "6002.18005.amd64fre.lh_sp2rtm.090410-1830"
- My "ProductId" exists with a 5-3-7-5 digit grouping starting with 89587. There is no "OEM" string embedded.
- There is an "EditionId" which for me is "Ultimate".
- There is a "CSDBuildNumber" which for me is "1621".

On an interesting note, when I run this from within the archive (7zip manager), rather than running the one I extracted to a folder as above, I get:

DednDave OS Info Dump

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"ProductName"="Microsoft Windows XP"
"CurrentVersion"="5.1"
"CurrentBuildNumber"="2600"
"SubVersionNumber"=""
"CSDVersion"="Service Pack 2"
"BuildLab"="6002.lh_sp2rtm.090410-1830"
"ProductId"=(Value not found)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center]
"Ident"="5.0"

Press any key to exit


ToutEnMasm

Quote
DednDave OS Info Dump

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"ProductName"="Microsoft Windows XP"
"CurrentVersion"="5.1"
"CurrentBuildNumber"="2600"
"SubVersionNumber"=""
"CSDVersion"="Service Pack 3"
"BuildLab"="2600.xpsp_sp3_gdr.090206-1234"
"ProductId"="55711-640-XXXXXXX-XXXXX"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center]
"Ident"=(Key not found)

Press any key to exit


Why not use the GetVersionEx function ?,result follow


Quote
Microsoft Windows XP Professional Build Service Pack 3 2600

dedndave

Wistrik,
with Vista 64, the registry we are interested in is located in another hive
i can't recall the name - wow64 or something like that
some of the values are not readable because of uac
if you run the program as the administrator, it may give different results
right-click on the command prompt - run as administrator - then, with that console opened, run the OSinfo.exe program

this info is for win 7, but much of it may apply for vista 64, as well

The Windows XP Service Pack 2 (SP2) compatibility mode allows an application to work as it did on Windows XP SP2. To run an application in this mode, right-click the application's executable file or icon and open the Properties property sheet. Click the Compatibility tab and select Run this program in compatibility mode for Windows XP (Service Pack 2).

Security restrictions enforced by User Account Control (UAC) might prevent applications that require administrative privileges from running properly, even if the user is a member of the Administrators group. To override UAC, a user with administrative privileges can run an application with elevated privileges by right-clicking the application's executable file or icon and clicking Run as administrator on the popup menu. The system displays a UAC dialog box, and the user can then click Allow to run the application with appropriate privileges.

of course, not all programs will be run with elevated privileges (or in compatibility mode, for that matter)
we may be able to use Yves' suggestion to get more info


Yves,
cool - i will add that to the program, as well
i see it is somewhat complicated (of course - lol)

http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx

sinsi

If you want OS info then yes, GetVersion/GetVersionEx is better, but still a real hassle if you're talking about win95+  :bdg
(just think how hard it is to get info from cpuid eh?).

The registry api behaves differently depending on your exe being 32-bit or 64-bit (same with file api's)
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

i suppose that is another issue for GetVersionEx
a program that uses it won't run under OS's earlier that win2K
so - no need to ID them ? - lol
that is not what i wanted, really
i was hoping to write a routine that would run all the way back to win95

i guess it could be handled in a dll so that, once a minimum OS has been identified, the appropriate dll may be loaded
maybe there is a better way to select API's according to the current OS
i have already had a case where a program i wrote that uses AttachConsole would not function under win2K
it would be cool if i could selectively use that API call

UtillMasm

C:\>osinfo.exe

DednDave OS Info Dump

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"ProductName"="Windows 7 Ultimate"
"CurrentVersion"="6.1"
"CurrentBuildNumber"="7600"
"SubVersionNumber"=(Value not found)
"CSDVersion"=(Value not found)
"BuildLab"="7600.win7_rtm.090713-1255"
"ProductId"="00426-OEM-XXXXXXX-XXXXX"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center]
"Ident"="6.0"

Press any key to exit

C:\>

sinsi

>maybe there is a better way to select API's according to the current OS

Just use GetProcAddress to see if the function exists (GetDiskFreeSpace comes to mind, talking about 95).
You can fall back to a more primitive way (usually something without the 'Ex') or retire gracefully.
Light travels faster than sound, that's why some people seem bright until you hear them.

fearless

Looking at the API i think GetVersion will run on Win95. GetVersionEx is recommended for NT upwards it says in the old win32 api.hlp i have.

You could try GetProcAddress for 'GetVersionEx', if its there then use that, if not see if it has GetVersion, which is probably win95, 98, ME maybe? That combined with the reg keys will give you a good overview i think.

There is also the command VER, which i think goes back as far as DOS days. VER probably is a static exe that just lazily displays the version info when it was compiled, then again maybe MS werent that lazy and it actually goes off and fetches something, in WinXP etc it might just read the registry keys your program is reading. Could be another avenue to investigate.

Edit: just seen sinsi last post, sorry for duplicate idea/post.
ƒearless

dedndave

both GetVersion and GetProcAddress require win 2k minimum os
now, VER has some potential, i suppose
it is a console mode (internal) command - so no good for gui apps as it is
however, that gives me the thought of looking into command.com/command.exe/cmd.exe
i could have a look and see where they get the info
i have a machine set up for win98 (hafta knock the dust off it)
someplace, i have a win 95 cd, too - i can build a drive for that easy enough
i may even have win98se - seems logical, as i have another machine with that on it - lol
i never liked winME, so, if i had a cd for that, it was frisbee'd - lol - that'll teach me
i have never seen nor heard of anyone using os2 - lol

sinsi

>both GetVersion and GetProcAddress require win 2k minimum os

Don't believe msdn or the vista sdk - a whole slew of functions are now "2000 pro or better".
See if you can find the win32.hlp file - it used to come with the free version of delphi  :8)

Look at ReadFile - even now, the minimum is 2000! Suddenly, 95 can't ReadFile.

To run all of the windows versions on one computer, look at vmware (fast-ish, costs money) or even bochs (slow, free) and virtualpc (validation, free).
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

i suppose that brings up the point - where is it that older os's are documented - lol
damn ms - i know they aren't going to give you any info on win 95

sinsi

Windows® Server 2003 SP1 Platform SDK Web Install
That was pre-vista (I think) but had some 64-bit stuff for xppro and none of this 'minimum 2000' stuff.
I've got it backed up somewhere, so I'll dig it up tomorrow and have a squizz.
Light travels faster than sound, that's why some people seem bright until you hear them.

FORTRANS

Quote from: dedndave on July 29, 2009, 01:06:15 PM
i have never seen nor heard of anyone using os2 - lol

Hi Dave,

  Well, I use(d) OS/2 in various versions.  Currently, mostly to read
newsgroups.

  BTW Win 3.11/Win32S did not like your program at all.  (Not at
all surprising though.)

Steve

dedndave

sinsi - cool - i got the 2003 sdk - i will put it on a diff machine, though
i dont want to screw this one up - lol - i got it working great with all the right stuff

FORTRANS
Steve - your house must be a museum like mine - lol
i have never even heard of win32s