home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
dskutl
/
protect.arc
/
PROTECT.ASM
next >
Wrap
Assembly Source File
|
1988-05-11
|
4KB
|
128 lines
;
; PROTECT.ASM - Write protect tab simulation for hard disk
;
CSEG SEGMENT
ASSUME CS:CSEG
ORG 100H
;
START: JMP INITIALIZE
;
OLDINT13 DD ? ; save original INT 13h vector
SWITCH DB 0Fh ; ON/OFF "switch" for write protect tab
;
; new protected INT 13h vector (BIOS disk I/O interrupt service)
;
NEWINT13 PROC FAR
CMP AH, 03h ; check for disk write function
JZ CHECKSTAT ; trap write request
;
CMP AH, 05h ; disk format function
JZ CHECKSTAT ; trap format request
;
CMP AH, 0Bh ; write long function (AT, PS/2)
JZ CHECKSTAT ; trap write long request
;
CONTINUE: JMP CS:[OLDINT13] ; service disk I/O request
;
CHECKSTAT: CMP SWITCH, 00h ; protect switch ON ?
JNZ CONTINUE ; no, skip disk I/O trap
;
CMP DL, 00h ; floppy A: selected ?
JZ CONTINUE ; yes, skip disk I/O trap
;
CMP DL, 01h ; floppy B: selected ?
JZ CONTINUE ; yes, skip disk I/O trap
;
ABORT: MOV AH, 03h ; set write protect error code
STC ; set failure status
RET 2 ; and return with existing flags
;
NEWINT13 ENDP
;
; PROTECT program installation
; search for PROTECT program in memory first
;
INITIALIZE: MOV DX, OFFSET NEWINT13 ; address to begin search
MOV AX, CS ; DS:SI points to Destination
MOV ES, AX ; ES:DI points to Source
;
NEXTSEG: DEC AX ; search previous segment
MOV DS, AX ; load new segment to search
MOV SI, DX ; | point to head of string
MOV DI, DX ; | point to head of string
;
; Confirmation that program is in memory occurs when four words match
;
MOV CX, 0004h ; set match at four words
CLD ; clear DF for auto-increment
REPE CMPSW
JNZ NOTFOUND ; no match, try next segment
;
; May have found PROTECT program. Copy is identified by SWITCH = 0Fh
;
CMP DS:SWITCH, 0Fh ; is this an installed copy ?
JNZ TOGGLESW ; if so, toggle switch
;
NOTFOUND: CMP AX, 0001h ; stop searching if in low memory
JNZ NEXTSEG
;
; Did not find PROTECT in memory. Must install program.
;
MOV SWITCH, 00h ; turn switch on
; Get old 13h vector from the BIOS
MOV AX, 3513h ; AH = 35h (Get interrupt vector func)
; AL = 13h (get vector 13h)
INT 21h ; invoke BIOS interrupt service
;
; Save old 13h vector
;
MOV WORD PTR CS:[OLDINT13], BX
MOV WORD PTR CS:[OLDINT13 + 2], ES ; old address saved
;
PUSH CS
POP DS ; Set DS to CS
;
; Print message on control console
;
MOV DX, OFFSET PROTECT_ON ; point to head of message
MOV AH, 09h ; AH = 09h (print string function)
;
INT 21h ; invoke BIOS interrupt service
;
; Create new 13h vector (pointing to this program)
;
MOV DX, OFFSET NEWINT13
; Set new INT 13h vector with BIOS
MOV AX, 2513h ; AH = 25h (Set interrupt vector func)
; AL = 13h (set vector 13h)
INT 21h ; invoke BIOS interrupt service
;
MOV DX, OFFSET INITIALIZE ; bytes to leave resident
INT 27h ; Terminate and stay resident
;
; -------- Installation completed --------
;
; Copy of program found in memory. Just toggle switch and exit.
;
TOGGLESW: NOT DS:SWITCH ; value of DS set during search
CMP DS:SWITCH, 00h ; is switch ON ?
JZ ON ; no, turn switch ON
;
MOV DX, OFFSET PROTECT_OFF ; point to head of message
JMP EXIT ; run to the nearest exit
ON: MOV DX, OFFSET PROTECT_ON ; point to head of message
EXIT: MOV AH, 09h ; (print string function)
PUSH CS
POP DS ; restore DS from CS
INT 21h ; put message on control console
INT 20h ; return to DOS
;
; Console Messages
;
PROTECT_ON DB "Fixed-disk write protect tab simulation is ON$"
PROTECT_OFF DB "Fixed-disk write protect tab simulation is OFF$"
;
CSEG ENDS
;
END START