Assembly code snippets

Back to the snippets overview

Details

TitleGetWinVer
Authordickhead
Submitted by:dickhead
Date added:2003-11-26 11:27:28
Date modified:2003-11-26 11:27:28

Comments

Returns a dword number specifying the windoze version

Snippet

GetWinVer   PROC
            ; edx = dwVersion
            ; esi = dwMajorVersion
            ; edi = dwMinorVersion

            invoke      GetVersion
            mov         edx, eax
            invoke      _loword, eax
            mov         edi, eax
            invoke      _lobyte, eax
            mov         esi, eax
            invoke      _hibyte, edi
            mov         edi, eax


            .IF         edx < 80000000h
                .IF         esi == 3
                    mov         eax, WV_NT351
                .ELSEIF     esi == 4
                    mov         eax, WV_NT4
                .ELSEIF     esi == 5 && edi == 0
                    mov         eax, WV_2000
                .ELSEIF     esi == 5 && edi == 1
                    mov         eax, WV_XP
                .ELSEIF     esi == 5 && edi == 2
                    mov         eax, WV_SRV2003
                .ENDIF

            .ELSEIF     esi == 4

                ; Microsoft Windows 95/98/Me
                .IF         edi == 0
                    mov         eax, WV_95
                .ELSEIF     edi == 10
                    mov         eax, WV_98
                .ELSEIF     edi == 90
                    mov         eax, WV_ME
                .ENDIF
            .ELSE

                ; Unknown
                mov         eax, WV_UNKNOWN
                .ENDIF
            ret
GetWinVer ENDP