News:

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

My Completely Useless Library

Started by baltoro, January 31, 2011, 11:45:05 PM

Previous topic - Next topic

baltoro

One of the most annoying aspects of programming a complex application in Windows is creating an application that is compatible with all modern Windows Operating System versions. Typically, you test for specific functionality by calling LoadLibrary and GetProcAddress (this is the Microsoft recommended technique). So, as a demonstration project, I have coded a library that exports a number of functions that determine such information as: user and domain name, the user SID, whether the current user has administrative privileges, the processor features, and the Windows operating system version. The zip archive contains a compiled DLL and a simple executable that executes the library functions, the assembly language files for both, OBJ files, and resource file.   
The code is primitive, but it works. It does NOT alter any security token information, or make any registry entries. It merely generates information. In an real program, you probably would not write this kind of code because it is so tedious, but, the code demonstrates a number of useful techniques for determining important system and processor information. It is seriously bloated. And, since I run on Windows XP Professional, I have not had the opportunity to test it on Windows Seven. Also, I have NOT tried to create a context for the User Account Control (UAC) feature of Vista and Windows 7, since I had no realistic way to test it. Improvements could clearly be made. And, I designed the library so that it could be easily customized, and re-compiled to work from within an executable (all you have to do is copy and paste relevant code to a new location, and compile normally). To see how it works, launch the executable, and select the menu item, "Produce Operating System Data", and then select the menu item, "Execute Library Functions",...otherwise the application does nothing. The app will create a folder named, "Information", with a text file inside that lists the information written by the DLL's exported functions. Let me know if something doesn't work as expected.

Added after reviewing the comments of Magnum and Dave (see below).
This zip is the improved version (with 8 DUMB errors fixed).   
Baltoro

Magnum

It looks good.

I am running XP Home Edition in case you wanted to differentiate the different versions.

The Installed Operating System is: Windows XP Professional.
The Build Number of the Operating System is: 2600
The Latest Service Pack installed is: Major: 2, Minor: 0
Have a great day,
                         Andy

dedndave

Quote(SSE3) Streaming SIMD Extensions 3 instruction set is NOT available on computer processor.

my CPU supports SSE3

it correctly reports XP Media Center Edition, though

baltoro

Thanks for the feedback.
I was going to use the CPUID instruction for all those feature flags, but, naturally, I assumed, "IsProcessorFeaturePresent" would work as advertised. I'm curious, Dave, do you have an Intel processor?
Baltoro

dedndave

yes - a prescott w/htt

there are numerous routines on the forum for this kind of thing
let me start off by saying, if you want to identify processors, you will come away from CPUID docs with a headache
but, if you simply want to test to see if a specific feature is supported, it isn't so bad
Hutch, Jochen, Alex, and myself, as well as others, have all taken a stab at it - lol

here is one of my more recent attempts....
http://www.masm32.com/board/index.php?topic=13044.0
as it happens, i am working on an updated version of that code
i am also working on some OS identification code that uses the function you mention
it will be interesting to see which OS's support which flags   :bg

at any rate, feel free to d/l that program and do whatever you like with the code
besides the code, that thread provides a nice database, as it tells you what the member CPU's report

this post has a few other links you may find interesting
http://www.masm32.com/board/index.php?topic=14871.msg124635#msg124635
in that list, you will find an updated "signature" list that you may find useful
i took the intel list and the amd list and made some corrections to create it

baltoro

#5
Dave,
Thanks again,...and, dumb question on my part,...I realized after I looged off.
The links to the previous threads on the subject is tremendous,...thanks.
...Will update the code with better detection and stuff.
Baltoro

Magnum

Quote from: baltoro on February 01, 2011, 06:07:59 PM
Dave,
Thanks again,...and, dumb question on my part,...I realized after I looged off.
...Will update the code with better detection and stuff.

There are no dumb questions.

Asking questions shows others a willingness to learn on your part.





Have a great day,
                         Andy

baltoro

#7
...Actually, that one WAS pretty dumb,...I had spent most of the morning reading the Intel 64 and IA-32 Architecture and Software Developer's Manuals, where they describe the SSE3 instruction set as a proprietary technology of Intel processors. I just wasn't sure what the IsProcessorFeaturePresent function would return for an AMD processor.
Baltoro

dedndave

while it may be proprietary intel property, they can license it to amd
i think amd chips support sse3 - don't quote me, though   :P

baltoro

#9
Dave,
I looked at the assembly code and it should work as it exists,...but, I checked the MSDN documentation for: IsProcessorFeaturePresent, and it states that: for the SSE3 instruction set, this feature is not supported, for Windows Server 2003 and Windows XP/2000. I didn't use the CPUID instruction for that,...I'd have gotten a different value if I did.
EDIT:
As for Magnum, there is code to check for the Windows XP Home Edition and write the info to file. I looked it over again, and checked the documentation,...and, I had made a REALLY DUMB error,...eight times. If you had not pointed it out, it would never have occurred to me. I made the assumption that the WORD flag value I was using in a CMP was just a single flag. It's not,...it can be a number of them combined into one WORD value. So, I changed the code to handle it in an unambiguous way, Should work now. Thanks for testing it. The version in the original post has been updated with the improved code.
Baltoro

Magnum

Have a great day,
                         Andy

dedndave

right - they mean that the feature flag is not supported in the function
from what i can see, SSE3 works under XP   :P

Antariy

Hi, Baltoro!

The updated one:

Quote
(SSE3) Streaming SIMD Extensions 3 instruction set is NOT available on computer processor.

Actually at time of WinXP /SP1/SP2 there is no SSE3 - that's the reason for "not supported" - XP just do not know about stuff asked - my guess :bg

Quote
The processor does NOT support (PAE) Physical addresses greater than 32-bit.

It is support. Most likely that this part of code returning PAE *status* rather that availability. PAE is turned off, but it is present, and is 36 bit width actually.

Probably OS functions you use returns not true hardware status, but status of current configuration, so things mentioned are *not* bugs.

Rest of the report is right - I'm under WinXP Pro, too.

baltoro

Alex,
Excellent,...thanks,...you're correct. The functions: IsProcessorFeaturePresent, has some limitations, which I was just TOO LAZY to work around. As both you and Dave have pointed out,...the CPUID instruction is clearly more reliable for determining processor features.
Baltoro

Antariy

Quote from: baltoro on February 03, 2011, 05:44:07 PM
Alex,
Excellent,...thanks,...you're correct. The functions: IsProcessorFeaturePresent, has some limitations, which I was just TOO LAZY to work around. As both you and Dave have pointed out,...the CPUID instruction is clearly more reliable for determining processor features.

My post is not kind of "excellent" :bg
Sorry for being said twice (salut, Dave! :bg)