home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / diskutil / rwp100b.zoo / rwp.asm < prev    next >
Encoding:
Assembly Source File  |  1990-04-01  |  8.3 KB  |  202 lines

  1.             Title Resident Write Protect Protect
  2.             Page 82,132
  3.  
  4. ;-------------- CONSTANTS
  5.  
  6. DISP_BUFFER     equ     0B800H  ; color graphics buffer
  7. ACTIVE          equ     1
  8. INACTIVE        equ     0
  9. CR              equ     13
  10. LF              equ     10
  11. KEYBOARD_INTR   equ     9h      ; keyboard interrupt vector
  12. DISK_INTR       equ     13h     ; BIOS disk interrupt vector
  13. DOS_WRITE       equ     26h     ; DOS write interrupt vector
  14. FREE_INT1       equ     60h     ; Program signiture will be attached to a
  15. FREE_INT_LAST   equ     67h     ;   vector in this range
  16. DISK_ENTRY      equ     DISK_INTR*4     ;
  17. KEYBOARD_ENTRY  equ     KEYBOARD_intr*4 ; Abs Locations in int table of vectors
  18. DOS_WRITE_ENTRY equ     DOS_WRITE*4     ;
  19.  
  20.                 .286    ; allow 286 instructions
  21.  
  22. ;-------------- Dummy segment pointing to the interrupt table
  23.  
  24. INT_TABLE       SEGMENT AT 0
  25. INT_TABLE       ENDS
  26.  
  27. ;-------------- BEGINING
  28.  
  29. code            SEGMENT
  30.                 assume  cs:code
  31.                 org     44                      ;here is the environment
  32. environ_addr    dw      ?                       ; pointer
  33.                 org     100h                    ;make this a .COM file
  34. RWP:            jmp     beginning               ;install interrupt
  35.  
  36. ;-------------- DATA
  37.  
  38.                 include RWP-WIND.INC    ; window screen definition
  39.  
  40. option          db      0
  41. DOption         db      0,0,1,1   ; default disk protection levels
  42. old_pos         dw      ?         ; old cursor position
  43. COMMUNICATE:    jmp     comm_routine
  44. program_name    db      'RWP Ver 1.0ß',0
  45. copyright       db      '(C)1990 R Hall'
  46. status          db      0         ; flag to tell if keyboard int is
  47.                                   ; currently being serviced
  48. old_disk_intr   dw      ?,?       ; pointer to old INT 13h
  49. old_keyboard_intr dw    ?,?       ; pointer to old INT 9h
  50. old_dos_write   dw      ?,?       ; pointer to old INT 26h
  51. ident_intr      db      DOS_WRITE
  52. keyboard_status dw      ?
  53.  
  54. IDENT_LENGTH    equ     OFFSET copyright - OFFSET program_name
  55.  
  56. ;-------------- Resident Procedures ------------------
  57.  
  58.                 include RWP-SWAP.INC    ; proc to swap window & screen
  59.                 include RWP-MENU.INC    ; proc to get options from keyboard
  60.                 include RWP-INT.INC     ; procs that take over the interrupts
  61.  
  62. LastByteToSave:                 ; all above this line stays resident,
  63.                                 ; all below goes away after termination.
  64.  
  65. ;============================================================================
  66.  
  67.  
  68. ;-------------- Non-Resident data -----
  69.  
  70. start_up_msg    db      lf,cr,'┌────────────────────────────────────────┐'
  71.                 db      lf,cr,'│ -=< Resident Write Protect (C)1990 >=- │'
  72.                 db      lf,cr,'│            Version 1.00ß               │'
  73.                 db      lf,cr,'│            by Randy Hall               │'
  74.                 db      lf,cr,'│ ────────────────────────────────────── │'
  75.                 db      lf,cr,'│         RWP is now installed           │'
  76.                 db      lf,cr,'│   Press Left shift & Alt to activate   │'
  77.                 db      lf,cr,'└────────────────────────────────────────┘'
  78.                 db      lf,lf,cr,'$'
  79. already_msg     db      lf,cr,'┌──────────────────────────────┐'
  80.                 db      lf,cr,'│  RWP was already installed.  │'
  81.                 db      lf,cr,'└──────────────────────────────┘'
  82.                 db      lf,lf,cr,'$'
  83. no_ident_warning db     lf,cr,'┌─────────────────────────────────────────┐'
  84.                 db      lf,cr,'│Warning -- Many resident utilities are   │'
  85.                 db      lf,cr,'│already installed.  RWP will not warn you│'
  86.                 db      lf,cr,'│if you install it more than once.        │'
  87.                 db      lf,cr,'└─────────────────────────────────────────┘'
  88.                 db      lf,lf,cr,'$'
  89.  
  90. ;-------------- Non-Resident code -----
  91.  
  92. beginning:      assume  ds:code
  93.                 push    cs                      ; set up segments
  94.                 push    ds
  95.  
  96. ;-------------- See if RWP is installed already
  97.  
  98.                 mov     al,free_int1            ;scan the interrupt table
  99. check_loop:     mov     ah,35h                  ;free range for RWP
  100.                 int     21h                     ;marker
  101.                 cmp     bx,0                    ;see if interrupt is in use
  102.                 jne     compare_strings         ;yes, see if it is marker
  103.                 mov     cx,es                   ;now check segment
  104.                 cmp     cx,0
  105.                 jne     compare_strings         ;else, this vector is free
  106.                 mov     ident_intr,al           ;remember it
  107.                 jmp     cont_loop
  108.  
  109. compare_strings: mov    di,bx                   ;es:di points to target
  110.                 add     di,3                    ;don't look at jump
  111.                 mov     si,offset program_name  ;ds:si points to name
  112.                 mov     cx,ident_length         ;see if target points to
  113.                 repe cmpsb                      ;same string as name
  114.                 jcxz    already_installed       ;matched => installed
  115.  
  116. cont_loop:      inc     al                      ;look at next interrupt
  117.                 cmp     al,free_int_last        ;time to stop?
  118.                 jne     check_loop              ;no, keep checking
  119.                 cmp     ident_intr,DOS_WRITE    ;a free interrupt?
  120.                 jne     not_installed           ;yes, so install it
  121.  
  122.                 mov     dx,offset no_ident_warning
  123.                 mov     ah,9
  124.                 int     21h
  125.                 jmp     not_installed
  126.  
  127. ;-------------- Already installed, so print a message and terminate
  128.  
  129. already_installed: mov  dx,offset already_msg   ;display message
  130.                 mov     ah,9
  131.                 int     21h
  132.                 mov     ax,4C01h                ;indicate error & terminate
  133.                 int     21h
  134.  
  135. ;-------------- Not installed, so continue
  136.  
  137. not_installed:  mov     dx,offset start_up_msg  ;print message that
  138.                 mov     ah,9                    ;RWP has been installed
  139.                 int     21h
  140.  
  141. ;-------------- Read old interrupts
  142.  
  143.                 mov     al,disk_intr            ;read old disk interrupt
  144.                 mov     ah,35h
  145.                 int     21h
  146.                 mov     old_disk_intr,bx        ;save it
  147.                 mov     old_disk_intr+2,es
  148.  
  149.                 mov     al,dos_write            ;read old int
  150.                 mov     ah,35h
  151.                 int     21h
  152.                 mov     old_dos_write,bx        ;save it
  153.                 mov     old_dos_write+2,es
  154.  
  155.                 mov     al,keyboard_intr        ;read old int
  156.                 mov     ah,35h
  157.                 int     21h
  158.                 mov     old_keyboard_intr,bx    ;save it
  159.                 mov     old_keyboard_intr+2,es
  160.  
  161. ;-------------- Free environment
  162.  
  163.                 mov     ax,environ_addr         ;find environment
  164.                 mov     es,ax                   ;free it
  165.                 mov     ah,73
  166.                 int     21h
  167.  
  168. ;-------------- Redirect interrupts
  169.  
  170.                 mov     dx,offset communicate   ;set up communication
  171.                 mov     al,ident_intr           ;identifier interrupt
  172.                 mov     ah,25h
  173.                 int     21h
  174.  
  175.                 mov     dx,offset new_keyboard  ; redirect keyboard interrupt
  176.                 mov     al,keyboard_intr
  177.                 mov     ah,25h
  178.                 int     21h
  179.  
  180.                 mov     dx,offset new_disk_intr ; redirect disk interrupt
  181.                 mov     al,disk_intr
  182.                 mov     ah,25h
  183.                 int     21h
  184.  
  185.                 mov     dx,offset new_dos_write ; redirect DOS disk
  186.                 mov     al,dos_write            ; write interrupt
  187.                 mov     ah,25h
  188.                 int     21h
  189.  
  190. ;-------------- Terminate and stay resident
  191.  
  192.                 mov     dx,offset LastByteToSave ; keep everything up to
  193.                 mov     cl,4                     ; the last resident byte
  194.                 shr     dx,cl
  195.                 inc     dx
  196.                 mov     al,0                    ; no error
  197.                 mov     ah,49                   ; terminate
  198.                 int     21h
  199.  
  200. code            ends
  201.                 end RWP
  202.