The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Parse on August 19, 2005, 01:42:11 PM

Title: Detect Windows OS
Post by: Parse on August 19, 2005, 01:42:11 PM
Hi,

What is the smallest way to detect whether the computer you're running on is win9x or winNT+.

call [GetVersion]
cmp eax, 80000000h
jb short win9x


that's what i've got So Far.

edit: Ok not the smallest way, but another way. I also use the checking of whether the RegisterServiceProcess Api can be found.

I'm looking for a better way. Oh, and not using GetVersionExA
Title: Re: Detect Windows OS
Post by: P1 on August 19, 2005, 02:05:19 PM
In real estate, it's location, location, location.

In programming, it's the need, the need, the need.

Please help us with the context of this request and the need.  Because I have seen too many times, where we are guessing at what you want, when we know the need, we can give a more appropiate answer.

Regards,  P1  :8)
Title: Re: Detect Windows OS
Post by: diablo2oo2 on August 19, 2005, 02:51:09 PM
one way is to check for an API which is only avaible on NT systems.

invoke GetModuleHandle,chr$("kernel32.dll")
invoke GetProcAddress,eax,chr$("UpdateResourceA")
.if eax==0
;not NT system...
.endif
Title: Re: Detect Windows OS
Post by: Parse on August 19, 2005, 03:29:04 PM
Quote from: P1 on August 19, 2005, 02:05:19 PM
In real estate, it's location, location, location.

In programming, it's the need, the need, the need.

Please help us with the context of this request and the need.  Because I have seen too many times, where we are guessing at what you want, when we know the need, we can give a more appropiate answer.

Regards,  P1  :8)

I'm just trying to optimize a program. It branches off at some point, where on one side it uses NT only Apis, and on the other 9x apis. It's just for fun and to learn something. I was hoping you guys could show me some cool secret asm tricks to do this.
Title: Re: Detect Windows OS
Post by: Petroizki on August 20, 2005, 04:29:59 AM
assume fs:nothing
cmp dword ptr fs:[30h], 0
js win9x


10 bytes...  :lol
Title: Re: Detect Windows OS
Post by: Mark Jones on August 20, 2005, 06:08:43 AM
Quote from: Petroizki on August 20, 2005, 04:29:59 AM
assume fs:nothing
cmp dword ptr fs:[30h], 0
js win9x


10 bytes...  :lol

Hi Petroizki, what does that compare against, Win9x and NT? What about 2K and XP? :)
Title: Re: Detect Windows OS
Post by: Petroizki on August 20, 2005, 06:22:38 AM
Quote from: Mark Jones on August 20, 2005, 06:08:43 AMHi Petroizki, what does that compare against, Win9x and NT? What about 2K and XP? :)
NT+ vs. 9x.
2k and XP are NT derived OS's, so they are identified as NT too. :wink