Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-ses!hpcc01!azarian From: azarian@hpcc01.HP.COM (Randy Azarian) Newsgroups: comp.lang.pascal Subject: Re: Disabling Ctrl-Break Message-ID: <1780002@hpcc01.HP.COM> Date: 14 Aug 89 17:43:10 GMT References: <630@UALTAVM.BITNET> Organization: HP Corporate Computing Center Lines: 96 Here is the code in assembly, and a demonstration in Microsoft C. If anyone wants to convert the assembly interface to Microsoft Pascal, *I'd* be interested. ; Ctrl-C/Ctrl-Break handler DGROUP GROUP _DATA _TEXT SEGMENT byte public 'CODE' ASSUME cs:_TEXT,ds:DGROUP ; ; the interrupt 23H handler INT23Handler PROC far push ds ; preserve all registers used push ax ; in this interrupt handler mov ax,seg DGROUP ; set DS to the segment where mov ds,ax ; the flag is located inc word ptr _INT23flag ; increment the flag pop ax ; restore regs and return pop ds iret INT23Handler ENDP ; ; the C-callable installation routine: PUBLIC _Install _Install PROC near push bp ; the usual C prologue mov bp,sp push ds ; preserve DS push cs ; set DS:DX to point to ... pop ds ; mov dx,offset INT23Handler ; ... the interrupt handler mov ax,2523h ; AH = DOS function number ; AL = interrupt number ; call DOS to update the int 21h ; interrupt vector pop ds pop bp ; restore regs and return ret _Install ENDP _TEXT ENDS ; ; the flag set by the interrupt 23H handler when Ctrl-C is pressed: _DATA SEGMENT word public 'DATA' PUBLIC _INT23flag _INT23flag dw 0 ; flag (initial value = 0) _DATA ENDS END /***************************************************************************/ /* C program to demonstrate Ctrl-C/Ctrl-Break handler, int23 */ /* Loop until ENTER is pressed. When Ctrl-Break is pressed, */ /* a message to that effect is displayed. */ /***************************************************************************/ extern int INT23flag; /* flag set when Ctrl-C is pressed */ main() { int keycode; Install(); /* install the interrupt 23H handler */ do { while (INT23flag > 0) { printf("\nCtrl-C was pressed"); /* show a message */ --INT23flag; /* and decrement the flag */ } if ( kbhit() ) /* look for a keypress */ keycode = getch(); else keycode = 0; } while (keycode != 0x0D); /* loop until Enter is pressed */ }