home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / IDXUTIL6.ZIP / CD_CHECK.ASM next >
Assembly Source File  |  1993-09-19  |  5KB  |  102 lines

  1.                 page    66,132
  2. ;============================================================================
  3. ; CD_CHECK.COM
  4.  
  5.                 code    segment
  6.         assume    cs:code
  7.  
  8.                 org     100h
  9.  
  10. main:        jmp    initialize
  11. int21h          dd      -1                      ;Int 21 vector (DOS)
  12.  
  13. ;============================================================================
  14. ; DOSINT processes calls to interrupt 21h
  15. ;============================================================================
  16. dosint        proc    far
  17.         assume    cs:code,ds:nothing,es:nothing
  18.                 cmp     ah,4eh                  ;Check for find first
  19.                 jne     goto_dos                ;No, nevermind
  20.                 push    di                      ;Save DI
  21.                 mov     di,dx                   ;copy DX pointer to index reg
  22.                 cmp     byte ptr [di],'@'       ;is it our 'fake' drive?
  23.                 jne     goto_dos_2              ;No, nevermind
  24.                 cmp     byte ptr [di+1],':'     ;is it our 'fake' drive
  25.                 jne     goto_dos_2              ;No, nevermind
  26.                 push    es                      ;Yes, Save ES
  27.                 push    ds                      ;Point ES to DS for scasb
  28.                 pop     es
  29.                 push    si                      ;Save SI
  30.                 push    cx                      ;Save CX
  31.                 push    bx                      ;Save BX
  32.                 mov     cx,64
  33.                 cld
  34.                 mov     al,0                    ;find the length
  35.                 repne   scasb                   ;di points past the 0
  36.                 mov     si,di                   ;Save pointer
  37.                 mov     cx,si                   ;calculate path length
  38.                 sub     cx,dx                   ;  as SI-DX
  39.                 jcxz    exit                    ;Abort if length 0
  40.                 std                             ;Scan backwords
  41.                 mov     al,'\'                  ;find the last '\'
  42.                 repne   scasb                   ;
  43.                 je      got_it                  ;  Found one
  44.                 mov     di,dx                   ;otherwise,point to drive letter
  45. got_it:         inc     di                      ;back up the pointer
  46.                 inc     di                      ;  to the actual filename
  47.                 mov     cx,si                   ;calculate the length
  48.                 sub     cx,di                   ;  as SI-DI
  49.                 jcxz    exit                    ;Abort if length 0
  50.                 push    cx                      ;Save Filename length
  51.                 push    di                      ;Save Filename Pointer
  52.                 mov     ah,2fh                  ;Get DTA address [ES:BX]
  53.                 pushf
  54.                 call    cs:[int21h]             ;call the old INT 21
  55.                 mov     di,bx                   ;Copy DTA to DI
  56.                 cld                             ;Copy forward
  57.                 mov     cx,1eh                  ;fill the first 30 bytes
  58.                 xor     al,al                   ;  with zeros
  59.                 rep     stosb                   ;Stuff 0's, point to filename
  60.                 pop     si                      ;Restore Filename Pointer
  61.                 pop     cx                      ;Restore Filename length
  62. loop1:          rep     movsb                   ;(ES:DI) < (DS:SI)
  63.                 xor     ax,ax                   ;Yes, say the file exists
  64.                 pop     bx                      ;Restore BX
  65.                 pop     cx                      ;Restore CX
  66.                 pop     si                      ;Restore SI
  67.                 pop     es                      ;Restore ES
  68.                 pop     di                      ;Restore DI
  69.                 iret                            ;Return
  70.  
  71. exit:           pop     bx                      ;Restore BX
  72.                 pop     cx                      ;Restore CX
  73.                 pop     si                      ;Restore SI
  74.                 pop     es                      ;Restore ES
  75. goto_dos_2:     pop     di                      ;Restore DI
  76. goto_dos:       jmp     cs:[int21h]             ;else pass the call to DOS
  77.  
  78. dosint          endp
  79.  
  80. ;----------------------------------------------------------------------------
  81. ; Initialization routine.
  82. ;----------------------------------------------------------------------------
  83. initialize    proc    near
  84.         assume    cs:code,ds:code,es:code
  85.                 mov     ax,3521h                ;Get interrupt 21 (DOS)
  86.         int    21h                     ;  vector.
  87.         mov    word ptr [int21h],bx
  88.         mov    word ptr [int21h+2],es
  89.         mov    ax,2521h                ;Point int 21 to internal
  90.         mov    dx,offset dosint        ;  routine.
  91.         int    21h
  92.                 mov     ax,ds:[2ch]             ;Get environment segment.
  93.                 mov     es,ax
  94.                 mov     ah,49h                  ;Free up environment.
  95.                 int     21h
  96. tsr:            mov     dx,OFFSET initialize
  97.         mov    ax,3100h        ;Terminate and stay resident
  98.                 int     27h
  99. initialize    endp
  100. code        ends
  101. end        main
  102.