home *** CD-ROM | disk | FTP | other *** search
- PAGE 62,130
- TITLE TIBTAZ.ASM - Trap (Int3) Branch To Absolute Zero
- ;******************************************************************************
- ;Written by Bruce T. Findlay, March 1992. Contributed to the Public Domain.
- ;
- ;This program changes the vector for Interrupt 0 ("divide by zero"), such that
- ; the prior handler gets control for genuine quotient-cannot-be-represented
- ; problems, but that an attempt to directly execute the vector will bring up
- ; the debugger of choice (read: Periscope).
- ;It is a very small TSR; executables that provide their own divide-by-zero
- ; handler will defeat TIBTAZ. Assembly programmers making use of jump tables
- ; filled in at run time will get the greatest benefit.
- ;
-
- Public EnvSeg, TIBTAZ, cnfe, PRHEX, PHG, PGMNAME, CRLF
-
- CSEG SEGMENT PARA PUBLIC 'CODE'
- ASSUME CS:CSEG, DS:CSEG, ES:CSEG
-
- ORG 02Ch
- EnvSeg dw ?
-
- ORG 0100H ;a not-so traditional COM program
- TIBTAZ: MOV AL,0H ;read old vector
- MOV AH,035H
- INT 021H
-
- mov dx, es ;save just-read seg
- push ds
- pop es ;make Assume true again
- mov di, 0CCh ;address of new "handler" (in our PSP)
- cld
- mov al, 0EAh ;JMP rel16 op code
- stosb
- mov ax, bx ;offset of old handler
- stosw
- mov ax, dx ;and segment
- stosw
-
- mov DX, 0CCh ;offset of new version (DS is the seg)
- MOV AL,0H
- MOV AH,025H
- INT 021H ;assign it
-
- ;release environment (!)
- mov ax, [EnvSeg] ;segment of environment
- mov es, ax ;where DOS expects it
- mov ah, 049h ;free mem func
- int 021h
- jc cnfe ;br as we could not free environment
- xor ax, ax
- mov [EnvSeg], ax ;mark w/zero so no one else reads it
- cnfe:
-
- ;now name program & PSP on the way out
- LEA DX,PGMNAME
- MOV AH,9
- INT 021H
- MOV BX,CS ;ugly, but it works.
- MOV CL,4
- MOV AL,BH
- SHR AL,CL
- CALL PRHEX
- MOV AL,BH
- CALL PRHEX
- MOV AL,BL
- SHR AL,CL
- CALL PRHEX
- MOV AL,BL
- CALL PRHEX
- lea dx, CRLF
- mov ah, 9
- int 021h
-
- LEA DX,TIBTAZ
- INT 027H
-
- PRHEX: AND AL,00FH
- ADD AL,030H
- CMP AL,03AH
- JB PHG
- ADD AL,7
- PHG: MOV DL,AL
- MOV AH,2
- INT 021H
- RET
-
- PGMNAME DB "TIBTAZ - Trap (Int3) Branch To Absolute Zero! PSP: $"
- CRLF DB 13, 10, 36
-
- CSEG ENDS
- END TIBTAZ ;necessary for .COM files
-
-
-