home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCACHSRC.ZIP / DRIVER1.ASM < prev    next >
Assembly Source File  |  1990-01-31  |  3KB  |  88 lines

  1.  
  2.     ;DRIVER1.SYS           B.Kauler
  3.     ;simple device driver
  4.     ;.....
  5.     code_seg  segment para    public  'code'
  6.     main_proc proc    far
  7.       assume  cs:code_seg,es:code_seg,ds:code_seg
  8.       org 0   ;required for device drivers.
  9.     begin:
  10.     ;...........................................
  11.     ;this area is the DEVICE HEADER....
  12.     next_dev   dd -1      ;no other device drivers
  13.     attribute  dw 8000h   ;character device.
  14.     strategy   dw dev_str ;addr of 1st DOS call.
  15.     interrupt  dw dev_int ;addr of 2nd DOS call.
  16.     dev_name   db "driver1$" ;name of the driver.
  17.     ;...........................................
  18.     ;this is the LOCAL WORKSPACE AREA....
  19.     rh_off   dw ?  ;Request Header offset.
  20.     rh_seg   dw ?  ;Request Header segment.
  21.     messages db 07h
  22.              db "Simple character device driver"
  23.              db 0Dh,0Ah,07h,"$"
  24.     ;...........................................
  25.     ;this is the STRATEGY procedure area...
  26.     dev_str:
  27.         push   ds         ;save DS.
  28.         push   cs         ;to avoid segment
  29.         pop    ds         ;         override.
  30.         mov    rh_seg,es  ;save Req.Header seg.
  31.         mov    rh_off,bx  ;save Req.Head offset.
  32.         pop    ds         ;restore DS.
  33.         ret
  34.     ;..........................................
  35.     ;this is the INTERRUPT procedure.....
  36.     dev_int:
  37.         push    ds      ;save registers.
  38.         push    es      ;       /
  39.         push    ax      ;       /
  40.         push    bx      ;       /
  41.         push    cx      ;       /
  42.         push    dx      ;       /
  43.         push    di      ;       /
  44.         push    si      ;       /
  45.         push   cs       ;to avoid segment
  46.         pop    ds       ;    override.
  47.     ;I will not assume that the second call to the
  48.     ;driver will still have the addr. of the Req.
  49.     ;Hdr. in ES:BX. Load it from workspace...
  50.         mov     es,rh_seg
  51.         mov     bx,rh_off
  52.     ;perform branch based on the command passed in
  53.     ;the Request Header...
  54.         mov     al,es:[bx+2] ;get command code.
  55.         cmp     al,0         ;check for zero.
  56.         jne     errors
  57.     ;perform required action...
  58.         mov     dx,offset messages ;message
  59.         mov     ah,9               ;to screen.
  60.         int     21h                ;/
  61.       mov es:word ptr [bx+3],0100h ;return status.
  62.     ;it seems that DOS will also require to know
  63.     ;where the driver ends....
  64.         mov     ax,offset the_end ;end prog.
  65.         mov es:[bx+14],ax ;break-addr for DOS.
  66.         mov es:[bx+16],cs ;     /
  67.         jmp finish
  68.     errors:
  69.       mov es:word ptr [bx+3],8103h ;return status
  70.     finish:
  71.         pop si           ;restore all reg's.
  72.         pop di
  73.         pop dx
  74.         pop cx
  75.         pop bx
  76.         pop ax
  77.         pop es
  78.         pop ds
  79.         ret
  80.     the_end:
  81.     ;..........................................
  82.     main_proc    endp
  83.     code_seg     ends
  84.                  end    begin
  85.     ;*****end of device driver******
  86.     ;..........................................
  87.  
  88.