News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

DOS devices & QueryDosDevice

Started by jj2007, December 03, 2014, 07:15:49 AM

Previous topic - Next topic

jj2007

I wanted to check if a drive was present, with QueryDosDevice, and saw only one drive S:
So I launched Olly and checked. Under XP, 170+ "devices", under Win7 a bit more 8)

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals buflen=80000, buffer[80000]:BYTE
  Init
  SetGlobals
  lea esi, buffer
  invoke QueryDosDevice, 0, esi, buflen
  .if !eax
      Inkey Err$()            ; unlikely
  .else
      push esi
      xchg eax, ecx
      .Repeat
            lodsb
            .if !al
                  mov byte ptr [esi-1], 10      ; replace zero delimiter with LF
            .endif
            dec ecx
      .Until Sign?
      pop esi
      StringToArray esi, dd$()      ; translate buffer to string array
      QSort dd$()            ; make it alphabetical
      For_ ecx=0 To eax-2      ; last one is an empty string
            Print Str$("\n%i\t",ecx+1), Left$(dd$(ecx), 60)      ; some are too long for the console
      Next
      Inkey Str$("\n%i DOS devices found", ecx)
  .endif
  Exit
end start