i have this code, i understand alot of asm, but am still not getting a few things, in the following code:



; -------------------------------------------
      .486
      .model flat, stdcall
      option casemap :none
      include \masm32\include\windows.inc
      include \masm32\include\gdi32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
; -------------------------------------------

GetDrives    PROTO

; -------------------------------------------

.data

exts DB "txt"
Ram DB "Ram Drive",0
HDD DB "Hard Drive",0
CD DB "CDRom Drive",0
Net DB "Network Drive",0
Rem DB "Floppy/Removable Drive",0
Unk DB "Unknown Drive",0

DriveFmt db "%s = %s",0

.data?

buffer db 256 dup(?)

; -------------------------------------------

.code

START:

INVOKE GetDrives
INVOKE ExitProcess,0

GetDrives PROC
    LOCAL DRIVES[106]:BYTE
    INVOKE GetLogicalDriveStrings, sizeof DRIVES, ADDR DRIVES
    lea esi, DRIVES
    mov ecx,eax ; ECX = LENGTH OF THE STRING
    .WHILE ecx > 0 ; Scan (DRIVES)
        lea ebx,
        push ecx ; GetDriveType modifies ECX
        INVOKE GetDriveType, ebx ; drive type
        .IF eax  == DRIVE_FIXED
          INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr HDD
          invoke MessageBox,0,addr buffer,esi,0
        .ELSEIF eax  == DRIVE_CDROM
            INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr CD 
            invoke MessageBox,0,addr buffer,esi,0
        .ELSEIF eax  == DRIVE_RAMDISK
            INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr Ram
            invoke MessageBox,0,edi,addr buffer,0
        .ELSEIF eax  == DRIVE_REMOTE
            INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr  Net
            invoke MessageBox,0,addr buffer,esi,0
        .ELSEIF eax  == DRIVE_REMOVABLE
            INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr  Rem
            invoke MessageBox,0,addr buffer,esi,0
        .ELSE  ;its a unknown drive
            INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr  Unk
            invoke MessageBox,0,addr buffer,esi,0
        .ENDIF
        pop ecx ; revive ecx
        add esi, 4
        sub ecx, 4
    .ENDW
    ret
GetDrives endp
END START

-------------------------------------------


1.) buffer db 256 dup(?) - why a buffer variable, and why is it not initializaed?
2.) DriveFmt db "%s = %s",0 - this reminds me of python, but i still dont seem to get what this does? its not in my masm reference
3.) INVOKE wsprintf,addr buffer,addr DriveFmt,esi,addr  Rem - how does wsprintf work? why do i need a buffer once again, and what is addr?

thanks in advance. i've read a good manual and a couple tutorials but i still dont grasp a few things
Posted on 2005-10-18 19:15:21 by marla
1) So that we can fill it up later.
2 and 3) Do you use sprintf of C or related programming language? Usage of wsprintf is similiar to sprint. You can check up on the usage of wsprintf. here
addr is address of the variable. Remember your lesson 101 in pointers?
Posted on 2005-10-18 21:05:02 by roticv