flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > 400 Bytes SFN directory lister :-D


The "Hidden" attribute of files & dirs is:
Very useful
0%
 0%  [ 0 ]
Useful
50%
 50%  [ 2 ]
Useless
25%
 25%  [ 1 ]
CRAP :-((( a gift to viral developers :-(((
25%
 25%  [ 1 ]
Total Votes : 4

Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1904
Code:
;
; DIR BUG test - (CL) Copyleft 2007 Public domain - ABUSE at YOUR own risk !!!
; Compile with FASM
;

format binary ; .COM
org $0100
use16

     mov al,0
     mov [llend2],al

     mov  dx,tx1
     call ssprint
     jmp  @f
;---------

tx1: db 'DIR BUG test - (CL) Copyleft 2007 Public domain - ABUSE at YOUR own risk !!!'
     db 13,10,13,10
     db 'ADVSHR',13,10
     db '543210 A:2^5=32=$20 V:8 (HOT !!) R:2^0=1',13,10,13,10
     db 'Search attrib mask: ',0

@@:  mov ah,[$80]
     cmp ah,3          ; !!!
     jnz qq8           ; Default to $3F

     mov ax,[$82]      ; AL:HI - AH:LO | reversed !!!
     cmp ah,$40
     jb  @f            ; No letter
     sub ah,7
@@:  cmp al,$40
     jb  @f
     sub al,7
@@:  and ax,$0F0F
     shl al,4         ; AL has 4 UPPER bits !!!
     or  al,ah        ; Result in AL
     and al,$3F       ; Cut off potential f**king top bits
     jmp short qq7
;-----------------
qq8: mov al,$3F

qq7:
     push ax        ; "mask"
     mov  ah,al
     and  ah,$0F    ; & Low 4 bits // reversed
     shr  al,4      ; & High 4 bits
     add  ax,$3030  ; Convert 0 -> ASCII "0"
     cmp  al,$3A
     jb   @f        ; "b":below // OK, a number
     add  al, 7
@@:  cmp  ah, $3A
     jb   @f        ; "b":below // OK, a number
     add  ah, 7
@@:  mov  dl,al
     call ssputchar ; HI 4 bits || AX preserved
     mov  dl,ah     ; LO 4 bits in AH
     call ssputchar
     call ssdeol
     pop  ax        ; "mask"

     mov  cl,al
     mov  ch,0
     mov  ax,$4E00
     mov  dx,tx2
     int  $21       ; FindFirst
     jc   llend

qq3: mov al,[$95]   ; RHSVDA
     mov cx,6
     shl al,2       ; Pushing out on the top !!!

qq2: shl al,1
     jc @f          ; Attr present !!!
     mov dl,'-'     ; NOT present
     jmp short qq1
;-----------------

@@:  mov bl,cl
     mov bh,0
     mov dl,[tx3-1+bx]

qq1: call ssputchar

     loop qq2

     mov  dl,$20
     call ssputchar
     mov  dx,$9E
     call ssprint

     call sseol
     mov  ax,$4F00  ; Findnext
     int  $21
     jnc  qq3

llend: call ssdeol
       ret
;---------

tx2: db '*.*',0
tx3: db 'RHSVDA'

ssdeol: call sseol
; pass Very Happy

sseol: mov dl,13
       call ssputchar
       mov dl,10
; pass Very Happy

ssputchar: push ax
           push cx
           push es

           mov  ah,2  ; In: DL
           int  $21

           inc  byte [llend2]
           mov  al,[llend2]
           cmp  al,7
           jnz  qq5
           mov  al,0
           mov  [llend2],al

           pushw 0
           pop   es
           mov   ax,[es:$046C]
@@:        mov   cx,[es:$046C]
           cmp   ax,cx
           jz    @b

qq5:       pop  es
           pop  cx
           pop  ax
           ret
;-------------

ssprint: push bx  ; IN: DX ||| ASCIIZ: 0 instead of "$" !!!
         push ax
         push dx
         mov  bx,dx

llprlop:
         mov  dl,[bx]
         test dl,dl
         jz   @f
         call ssputchar
         inc  bx
         jmp  short llprlop
;--------------------------
@@:      pop dx
         pop ax
         pop bx
         ret
;-----------
llend2:
;END.
    


Download now (1'724 bytes .ZIP) : http://board.flatassembler.net/download.php?id=3914

Short ^^^ filenames only Shocked

LFN lister: http://board.flatassembler.net/topic.php?t=6010 (by Rugxulo)

Well, the reason why I coded it is a BUG in Enhanced DR-DOS in
directory handling, it is mainly for testing the bug Shocked

Syntax:

Code:
DIRBUG xy
    


xy is optional, it is the attribute mask in HEX, always 2 chars, no $ , defaults to (suboptimal) value of $3F Rolling Eyes


Last edited by DOS386 on 26 Aug 2008, 04:18; edited 2 times in total
Post 28 Jun 2007, 00:54
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2335
Location: Usono (aka, USA)
Quote:

Well, the reason why I coded it is a BUG in Enhanced DR-DOS in
directory handling, it is mainly for testing the bug.


What is it supposed to do? What do you want it to do? What other DOSes did you test against? (FreeDOS? MS-DOS? PC DOS? PTS-DOS? Datalight?)

P.S. Why this? Razz
Code:
           pushw 0 
           pop   es 
           mov   ax,[es:$046C] 
@@:        mov   cx,[es:$046C] 
           cmp   ax,cx 
           jz    @b
    
Post 28 Jun 2007, 07:26
View user's profile Send private message Visit poster's website Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
I run it under FreeDOS and MS-DOS and only SFN entries are returned - as expected.

But I won't touch the "Evil Doctor" anymore, sorry. I appreciate my health too much.
Post 29 Jun 2007, 17:23
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2335
Location: Usono (aka, USA)
Yeah, DR-DOS returns bogus junk because it's finding the volume label from VFAT entries. Just don't use $3F, use $37 instead. (I mean, if you aren't looking for the volume label, don't tell it you are!)

P.S. I still say you should use a .ZIP (stored) within a .ZIP (deflated) if you want to compress like solid method (instead of .TAR in .ZIP). But whatever. Razz
Post 12 Jul 2007, 19:29
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.