trying to figure out the easiest way to get the current service pack i could get the actual string in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion "CSDVersion" but its 2 different locations for 9x and nt
so then i found this


Hive: HKEY_LOCAL_MACHINE
Key: system\CurrentControlSet\control\windows
Name: CSDVersion
Type: REG_DWORD
Value: 0x100 SP1
Value: 0x200 SP2
Value: 0x300 SP3
Value: 0x400 SP4
Value: 0x500 SP5
Value: 0x600 SP6


    invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE,addr SubKey,0,KEY_READ,addr TheReturn

mov SPkeySize, 4
invoke RegQueryValueEx,TheReturn,addr szSPkey,0,0,addr SPData, addr SPkeySize ;the SP is in SPdata

now how would i code a .if statement to compare SPData to the 0x400 value to see if its service pack 4

or should i do a cmp SPData,Value

any other ways to get the service pack version?
:stupid:
Posted on 2003-12-21 02:55:31 by illwill
.if SPData==0400h

...
.endif

or



cmp SPData, 0400h
jne @f
...
@@:


GetVersionEx maybe?
Posted on 2003-12-21 03:15:47 by ENF


invoke GetVersionEx, addr sOSInfo
cmp sOSInfo.szCSDVersion,0
je no_service_pack
invoke MessageBox,0,addr sOSInfo.szCSDVersion,addr WinVers,0
jmp SPdone
no_service_pack:
invoke MessageBox,0,addr nopack,addr WinVers,0
SPdone:

seemed alot better then



.data
sz9xkey db "SOFTWARE\Microsoft\Windows\CurrentVersion\",0
NTkey db "SOFTWARE\Microsoft\Windows NT\CurrentVersion\",0
SubKey db "SYSTEM\ControlSet001\Control\Windows\",0
szSPkey db "CSDVersion",0
sp1 db "Service Pack 1",0
sp2 db "Service Pack 2",0
sp3 db "Service Pack 3",0
sp4 db "Service Pack 4",0
sp5 db "Service Pack 5",0
sp6 db "Service Pack 6",0
SPkeySize1 DWORD 255
.data?
SPData1 db 255 dup (?)
TheReturn DWORD ?
SPkeySize dd ?
SPData dd ?
.code
start:
mov eax, ds
test al, 4
jnz itz_9x
invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE,addr NTkey,0,KEY_READ,addr TheReturn
invoke RegQueryValueEx,TheReturn,addr szSPkey,0,0,addr SPData,addr SPkeySize ;the sp is in SPData1
invoke MessageBox,0,addr SPData,addr SPData,0
invoke RegCloseKey , TheReturn
jmp dizzone
itz_9x:
invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE,addr sz9xkey,0,KEY_READ,addr TheReturn
invoke RegQueryValueEx,TheReturn,addr szSPkey,0,0,addr SPData, addr SPkeySize ;the sp is in SPData
invoke MessageBox,0,addr SPData,addr SPData,0
invoke RegCloseKey , TheReturn
jmp dizzone



invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE,addr SubKey,0,KEY_READ,addr TheReturn
mov SPkeySize, 4
invoke RegQueryValueEx,TheReturn,addr szSPkey,0,0,addr SPData, addr SPkeySize ;the SP is in SPdata
.IF eax==ERROR_SUCCESS ;yay the key is there
cmp SPData, 0100h
jne @f
invoke MessageBox,0,addr SPData,addr sp1,0
jmp dizzone
@@:
cmp SPData, 0200h
jne @f
invoke MessageBox,0,addr SPData,addr sp2,0
jmp dizzone
@@:
cmp SPData, 0300h
jne @f
invoke MessageBox,0,addr SPData,addr sp3,0
jmp dizzone
@@:
cmp SPData, 0400h
jne @f
invoke MessageBox,0,addr SPData,addr sp4,0
jmp dizzone
@@:
cmp SPData, 0500h
jne @f
invoke MessageBox,0,addr SPData,addr sp5,0
jmp dizzone
@@:
invoke MessageBox,0,addr SPData,addr sp6,0
dizzone:
.ENDIF
invoke RegCloseKey , TheReturn
invoke ExitProcess,0
end start

:alright:
Posted on 2003-12-21 14:54:00 by illwill