home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MEMORIA / WDPAT102.ZIP / WDPATCH.ASM next >
Encoding:
Assembly Source File  |  1989-07-07  |  3.2 KB  |  118 lines

  1.     Page    55,132
  2.         .186
  3.     Title    WDPatch V1.2 Copyright 1986, 1987 Scott Samet
  4. Driver_Text    Segment
  5.     Assume    CS:Driver_Text,DS:Nothing,ES:Nothing
  6. Driver    Proc    FAR
  7. ; Standard MS-DOS Driver Header, used by all drivers
  8.     DD    -1            ; Pointer to Next Driver
  9.     DW    08000h            ; Attribute Bits: Block Device
  10.     DW    Strategy        ; Offset of Strategy Routine
  11.     DW    Interrupt        ; Offset of Interrupt Routine
  12.     DB      '$WDPATCH'              ; Eight bytes name
  13.  
  14. ; Definition of the Standard MS-DOS Request Header
  15. RH    Struc
  16. RHLen    DB    ?            ; Length of this RH
  17. RHUnit    DB    ?            ; Unit number for this request
  18. RHCmd    DB    ?            ; Command Code
  19. RHStat    DW    ?            ; Bit 15 = Error, Bits 0-7 = Code
  20.     DB 8 dup (?)            ; Reserved Area
  21.  
  22. RH0Unit    DB    ?            ; Number of Units
  23. RH0Brk    DD    ?            ; Break Addr (End of Driver + 1)
  24. RH0BPB    DD    ?            ; BPB Array Ptr
  25.  
  26. ;RHMed    DB    ?            ; Media Descriptor Byte
  27. ;RHAddr    DD    ?            ; Data Transfer Address
  28. ;RHCnt    DW    ?            ; Byte/Sector Count
  29. ;RHSec    DW    ?            ; Starting Sector
  30. RH    Ends
  31.  
  32. RH0BrkO Equ    Word Ptr RH0Brk
  33. RH0BrkS Equ    Word Ptr RH0Brk+2
  34. RH0BPBO    Equ    Word Ptr RH0BPB
  35. RH0BPBS    Equ    Word Ptr RH0BPB+2
  36.  
  37. ; Save area used to communicate between Strategy and Interrupt Routine
  38. RHOfs    DW    ?            ; offset of RH address
  39. RHSeg    DW    ?            ; segment of RH address
  40. RHPtr    Equ    DWord Ptr RHOfs        ; Same location, as DWord Ptr
  41.  
  42. ; Strategy Routine:
  43. ;   Called to set up an I/O Operation.  ES:BX points to a Request Header.
  44. ;   ES:BX is saved for use by the interrupt routine.
  45. Strategy:
  46.     Mov    RHSeg,ES
  47.     Mov    RHOfs,BX
  48.     Ret
  49.  
  50. ; Interrupt Routine:
  51. ;   Called to start the I/O Operation preset by the strategy call.
  52. ;   The saved ES:BX Pointer is used to find the Request Header.
  53.  
  54. Interrupt:
  55.         PushA
  56.  
  57.     LDS    BX,RHPtr        ; Restore pointer to Request Header
  58.     Mov    AL,[BX.RhCmd]        ; Get Command Code from Request Header
  59.     Or    AL,AL            ; Is this an install request?
  60.     JE    Install            ; -Yes- go handle it
  61.     Mov    AX,8103h        ; -No- Get Error, Done & Unknown Cmd Status
  62.     Mov    [BX.RHStat],AX        ; Set flags in Request Header Status
  63. Exit:   PopA
  64.     Ret                ; Done
  65.  
  66.  
  67. Int41:  DB 16 Dup (0)
  68. Int46:  DB 16 Dup (0)
  69.  
  70. Install:
  71.         Mov     BX,41h*4
  72.         Mov     DX,Offset Int41
  73.         Call    Reloc
  74.         Mov     BX,46h*4
  75.         Mov     DX,Offset Int46
  76.         Call    Reloc
  77.  
  78.     LDS    BX,RHPtr          ; Restore pointer to Request Header
  79.         Mov     [BX.RHStat],0100h        ; Error Status
  80.  
  81.     Mov    DX,Offset Install        ; Set DX = Break offset
  82.         Mov     [BX.RH0BrkO],DX         ; CS:AX = Break Address (end of
  83.         Mov     [BX.RH0BrkS],CS            ;                    memory + 1)
  84.  
  85.         Push    CS
  86.         Pop     DS
  87.         Mov     DX,Offset CRite
  88.         Mov     AH,9
  89.         Int     21h
  90.         JMP     Exit
  91.  
  92. ; DS /src
  93.  
  94. Reloc   Proc    Near
  95.         Xor     AX,AX
  96.         Mov     DS,AX
  97.         LDS     SI,[BX]      ; DS:SI -> old param
  98.         Push    CS
  99.         Pop     ES
  100.         Mov     DI,DX        ; ES:DI -> new param
  101.         CLD
  102.         Mov     CX,16
  103.         REP MOVSB            ; Move it
  104.         Xor     AX,AX
  105.         Mov     DS,AX
  106.         Mov     [BX],DX
  107.         Push    CS
  108.         Pop     [BX+2]
  109.         Ret
  110. Reloc   EndP
  111.  
  112.  
  113. CRite     DB    0Dh,0Ah,'WDPatch V1.0 Copyright 1989 Scott Samet',0Dh,0Ah,'$'
  114. Driver    EndP
  115. Driver_Text    EndS
  116.     End
  117.  
  118.