home *** CD-ROM | disk | FTP | other *** search
- Hard Disk Write Protection
- (PC Magazine Vol 6 No 1 Jan 13, 1987 User-to-User)
-
- A User-to-User article (PC Mag Vol 5 No 15 July 23, 1986)
- described a method to disable all access to the hard disk. The
- PROTECT.COM program created by PROTECT.BAS or PROTECT.ASM is a much
- better method. It simulates a write-protect tab by allowing read
- access but not write access to the hard disk. The floppy drives
- aren't affected. To apply the write-protect tab, just type PROTECT
- at the DOS prompt. Typing PROTECT again will alternately switch the
- protection off and on.
- The first time the program runs, it grabs interrupt 13h so that
- it can monitor all requests for disk I/O. When a disk drive operation
- is requested, the program checks to see if a fixed disk drive was
- selected. If so, the error code for write protection is returned and
- DOS displays it usual error message. All other disk accesses are
- allowed to proceed normally.
- Once the program has been installed, it can turn itself off or on
- by searching through memory for the original copy and then resetting
- its switch. When the program is switched off, all disk operations are
- allowed to proceed normally.
- Editor's Note: This works by allowing writes only to drives A:
- and B:. If you have a 3 1/2-inch drive installed as D: or a RAMdisk
- as E;, PROTECT will prevent you from writing to these as well. To
- adapt the program so that it can write to these drives but not to your
- hard disk, add the appropriate:
-
- CMP DL,03H
- JZ CONTINUE
-
- 100 'PROTECT.BAS by Tom Kihlken. RUN from BASIC to create PROTECT.COM.
- 110 CLS:PRINT "Checking DATA ...."
- 120 FOR B=1 TO 13:FOR C=1 TO 17:READ A$:IF C<17 THEN 140
- 130 Z#=Z#+VAL(A$)
- 140 NEXT:NEXT:IF Z#=18272 THEN RESTORE:GOTO 170
- 150 PRINT "Error. Check the last number in"
- 160 PRINT "each DATA statement; then redo.":END
- 170 FOR B=1 TO 13:FOR C=1 TO 16:READ A$:TTL=TTL+VAL("&H"+A$)
- 180 NEXT:READ S:IF S=TTL THEN 200
- 190 PRINT "DATA error in line";B*10+240;" -- check and redo.":END
- 200 TTL=0:NEXT:RESTORE
- 210 OPEN "PROTECT.COM" AS #1 LEN=1:FIELD #1,1 AS D$
- 220 FOR B=1 TO 13:FOR C=1 TO 16:READ A$:LSET D$=CHR$(VAL("&H"+A$))
- 230 PUT #1:NEXT:READ DUMMY$:NEXT:CLOSE
- 240 PRINT "PROTECT.COM created.":END
- 250 DATA EB,2D,90,00,00,00,00,0F,80,FC,03,74,0A,80,FC,05,1333
- 260 DATA 74,05,2E,FF,2E,03,01,2E,80,3E,07,01,00,75,F3,80,1204
- 270 DATA FA,00,74,EE,80,FA,01,74,E9,B4,03,F9,CA,02,00,BA,2154
- 280 DATA 08,01,8C,C8,8E,C0,48,8E,D8,8B,F2,8B,FA,B9,04,00,2072
- 290 DATA FC,F3,A7,75,07,80,3E,07,01,0F,75,30,3D,01,00,75,1343
- 300 DATA E5,2E,C6,06,07,01,00,B8,13,35,CD,21,2E,89,1E,03,1197
- 310 DATA 01,2E,8C,06,05,01,0E,1F,BA,98,01,B4,09,CD,21,BA,1196
- 320 DATA 08,01,B8,13,25,CD,21,BA,2F,01,CD,27,F6,16,07,01,1241
- 330 DATA 80,3E,07,01,00,74,06,BA,B0,01,EB,04,90,BA,98,01,1405
- 340 DATA B4,09,0E,1F,CD,21,CD,20,48,61,72,64,20,44,69,73,1412
- 350 DATA 6B,20,50,72,6F,74,65,63,74,69,6F,6E,20,4F,6E,24,1459
- 360 DATA 48,61,72,64,20,44,69,73,6B,20,50,72,6F,74,65,63,1463
- 370 DATA 74,69,6F,6E,20,4F,66,66,24,00,00,00,00,00,00,00,793
-
-
- ; PROTECT.ASM
-
- CSEG SEGMENT
- ASSUME CS:CSEG
- ORG 100H
- START: JMP INITIALIZE
- OLDINT13 DD ?
- SWITCH DB 0FH
- NEWINT13 PROC FAR
- CMP AH,03H
- JZ CHECKSTAT
- CMP AH,05H
- JZ CHECKSTAT
- CONTINUE: JMP CS:[OLDINT13]
- CHECKSTAT: CMP SWITCH,00H
- JNZ CONTINUE
- CMP DL,00H
- JZ CONTINUE
- CMP DL,01H
- JZ CONTINUE
- ABORT: MOV AH,03H
- STC
- RET 2
- NEWINT13 ENDP
- INITIALIZE: MOV DX,OFFSET NEWINT13
- MOV AX,CS
- MOV ES,AX
- NEXTSEG: DEC AX
- MOV DS,AX
- MOV SI,DX
- MOV DI,DX
- MOV CX,0004H
- CLD
- REPE CMPSW
- JNZ NOTFOUND
- CMP DS:SWITCH,0FH
- JNZ TOGGLESW
- NOTFOUND: CMP AH,0001H
- JNZ NEXTSEG
- MOV SWITCH,00H
- MOV AX,3513H
- INT 21H
- MOV WORD PTR CS:[OLDINT13],BX
- MOV WORD PTR CS:[OLDINT13+2],ES
- PUSH CS
- POP DS
- MOV DX,OFFSET PROTECT_ON
- MOV AH,09H
- INT 21H
- MOV DX,OFFSET NEWINT13
- MOV AX,2513H
- INT 21H
- MOV DX,OFFSET INITIALIZE
- INT 27H
- TOGGLESW: NOT DS:SWITCH
- CMP DS:SWITCH,00H
- JZ ON
- MOV DX,OFFSET PROTECT_OFF
- JMP EXIT
- ON: MOV DX,OFFSET PROTECT_ON
- EXIT: MOV AH,09H
- PUSH CS
- POP DS
- INT 21H
- INT 20H
- PROTECT_ON DB "Hard Disk Protection On$"
- PROTECT_OFF DB "Hard Disk Protection Off$"
- CSEG ENDS
- END START
-