greetings all !!! i've got a rather clumsy question, and here it is: how could i see with code that wich windows version do i've got, is it xp, 98 or 2k ? I would really need some help on this topic, regards..
Posted on 2005-06-20 03:20:24 by berril
http://www.asmcommunity.net/board/index.php?topic=20278.msg155282#msg155282
Posted on 2005-06-20 03:44:33 by dcskm4200
I do it through the Windows Registry.  There are a lot of other better ways im sure.  I just cut and pasted this to give you an idea.

PUSH offset r_Disp_Key
PUSH offset hOpenKey
PUSH 0
PUSH KEY_READ
PUSH REG_OPTION_VOLATILE
PUSH 0
PUSH 0
PUSH eax
PUSH HKEY_LOCAL_MACHINE
CALL __reg__RegCreateKeyExA
Posted on 2005-06-20 03:46:17 by ib386
ib386 if you are going to paste code at least make it sensible, that code wont help at all, considering you havent stated what the key you are going to access is (eax is pointing to it presumably) and using RegCreateKeyExA is a bad method considering you will create the key if it doesnt exist, use RegOpenKeyExA instead, means you dont crap all over peoples registries
Posted on 2005-06-20 05:17:29 by evlncrn8
follow the board link posted by dcskm4200, and try using the board search engine :)
Posted on 2005-06-20 06:26:07 by f0dder
You are right evlncrn8. I learned that long ago.  That was just an accident, while rushing. i got to be more careful.


This sould povide an better idea...


.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib


include \masm32\include\advapi32.inc
includelib \masm32\lib\advapi32.lib


.data
s_NT_CurrentVersion    db "SOFTWARE\Microsoft\Windows NT\CurrentVersion",0
s_ProductName          db "ProductName",0

s_REG_SZ                db "REG_SZ",0
s_REG_BINARY            db "REG_BINARY",0
s_REG_DWORD            db "REG_DWORD",0

.data?

r_Disp_Key  dd ?

hOpenKey            dd ?

r_Size  dd ?
r_BUFFER_256  db  256 dup(?)

.code
start:



.code




PUSH offset r_Disp_Key
PUSH offset hOpenKey
PUSH 0
PUSH KEY_READ
PUSH REG_OPTION_VOLATILE
PUSH 0
PUSH 0
PUSH offset s_NT_CurrentVersion
PUSH HKEY_LOCAL_MACHINE
CALL RegCreateKeyExA

    mov r_Size,255


PUSH offset r_Size
PUSH offset r_BUFFER_256
PUSH offset s_REG_SZ
PUSH 0
PUSH offset s_ProductName
PUSH hOpenKey
CALL RegQueryValueEx

cmp eax, 0 ; ERROR_SUCCESS
jne NO_KEY_1

      invoke MessageBox,0,addr r_BUFFER_256,0,0

NO_KEY_1:

  PUSH NULL
  CALL ExitProcess

end start




;PUSH offset hOpenKey
;PUSH KEY_READ
;PUSH 0
;PUSH offset s_NT_CurrentVersion
;PUSH HKEY_LOCAL_MACHINE
;CALL RegOpenKeyEx
Posted on 2005-06-20 08:24:03 by ib386
I did it again :shock:

Just use the RegOpenKeyEx code at bottom.  I used all of this for testing quite awhile back switching back and forth.
Posted on 2005-06-20 08:28:49 by ib386
I forgot about 9x  you will have to check to be sure unless someone here can help with this.

s_9x_CurrentVersion    db "SOFTWARE\Microsoft\Windows\CurrentVersion",0
s_ProductName          db "ProductName",0

You will have to build code up to do a cmp.  I can't find it and i got to run right now.  Just another option is all i am trying to say.
Posted on 2005-06-20 08:47:51 by ib386
Isn't "GetVersionEx" much simplier?
Posted on 2005-06-20 13:31:57 by ti_mo_n
Yes it is but looking into your own reg is free.  Not useing GetVersionEx is an personal problem for me because long before reading the post above i do remember reading something neg about it.  But you are not me, and he and myself could be wrong.  I am no expert.  I got a long way to go to meet many of these true ASM guys.
Posted on 2005-06-20 15:10:54 by ib386