Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 11:57

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [ASM] Get OS Version
PostPosted: 16 May 2008 23:49 

Joined: 14 Aug 2007 11:17
Posts: 24
just few lines of MASM to get infos about the current OS:

Code:
TITLE GetOSVersion

.586
.model flat,stdcall
option casemap:none
assume fs:nothing

include windows.inc
include user32.inc
include kernel32.inc

includelib user32.lib
includelib kernel32.lib

WIN_2K equ 0h
WIN_XP equ 1h
WIN_2K3 equ 2h
WIN_NT equ 4h
WIN_VISTA equ 6h

.data

mbtitle BYTE "GetOSVersion",0h
winNT BYTE "found winNT!",0h
win2K BYTE "found win2K!",0h
win2K3 BYTE "found win2K3!",0h
winXP BYTE "found winXP!",0h
winVista BYTE "found winVista!",0h

.code

main proc

   push MB_OK
   push offset mbtitle

   mov esi, fs:[30h] ; PEB
   mov eax, [esi + 0a4h] ; majorV
   cmp eax, WIN_NT
   jbe @winNT
   cmp eax, WIN_VISTA
   jz @winVista
   mov ebx, [esi + 0a8h] ; minorV
   cmp ebx, WIN_2K
   jz @win2K
   cmp ebx, WIN_XP
   jz @winXP
   cmp ebx, WIN_2K3
   jz @win2K3

@winNT:
   push offset winNT
   jmp @cont
   
@win2K:
   push offset win2K
   jmp @cont
   
@win2K3:
   push offset win2K3
   jmp @cont
   
@winXP:
   push offset winXP
   jmp @cont
   
@winVista:
   push offset winVista
   jmp @cont
   
@cont:
   push 0
   call MessageBox

   push 0
   call ExitProcess

main endp

end main


It's also possible to add win9x... this is your homework :)


Top
 Profile  
 
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: