Find file routine for Windows, in asm.
0b7f4f98ac3878c2534bdee8d0045cfa8a21c3084b6b3c175293850771857d70
; Copyright © 2003 Rosiello Security
; All rights reserved.
;
; http://www.rosiello.org
; ------------------------------------------------------
; Find utility for Windows.
;
; Fix "COMFILE DB '*.COM',0" when you have
; to look for something different from *.COM files.
; ------------------------------------------------------
TITLE FIND FILES *.COM IN THE LOCAL DIRECTORY
.MODEL SMALL
.STACK 200h
.DATA
COMFILE DB '*.COM',0
CAPO DB 10,13,"$"
DTA DB 1AH dup (?)
.CODE
MAIN SEGMENT BYTE
ASSUME CS:MAIN,DS:MAIN,SS:NOTHING
START:
mov ax, @DATA
mov ds, ax
mov dx,offset dta ;point to temporary DTA buffer
mov ah,1ah ;set new disk transfer area
int 21h ;call dos
CALL FIND_FILE
mov ax,4c00h ;Returns control to DOS
int 21h
FIND_FILE:
mov dx,offset COMFILE
mov cx,3FH ;search for any file, no matter what the attributes
mov ah,4EH ;do DOS search first function
int 21H ;interrupt to DOS
FF_LOOP:
or al,al ;FILE Found ?
jnz EXIT ;no - jump to EXIT
FOUND:
mov bx,offset dta
add bx,30d ;move up to filename
mov cx,12d ;display 12-byte filename
READER:
mov al,[bx] ;get one byte
cmp al,0 ;end of filename reached?
je CONTINUE
mov ah,0eh ;display byte function
int 10h ;call bios Interrupt
inc bx
loop READER
CONTINUE:
mov ah,9
mov dx,offset CAPO
int 21h ;print "\n" after the name of the file
SEARCH_NEXT:
mov ah,4FH ;search for another file
int 21H ;interrupt to dos
jmp FF_LOOP ;go back up and see what happened
EXIT:
mov dx,80H ;fix the DTA
mov ah,1AH
int 21H ;interrupt to DOS
ret
ENDS MAIN
END START