Date: Mon, 12 Jan 1998 18:21:46 -0500 (EST) Message-Id: <199801122321.SAA13895@delorie.com> From: DJ Delorie To: djgpp-workers AT delorie DOT com Subject: [MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk: Hooking interrupt 9 : a DIFF] Precedence: bulk ------- Start of forwarded message ------- From: "Anthony.Appleyard" Organization: Materials Science Centre To: dj AT delorie DOT com Date: Mon, 12 Jan 1998 16:43:04 GMT Subject: Hooking interrupt 9 : a DIFF Reply-to: Anthony DOT Appleyard AT umist DOT ac DOT uk Priority: normal X-mailer: Pegasus Mail v3.31 Herewith suggested alterations to make it easier for a user to hook interrupt 9 to get the keyboard events raw:- My version of djgpp v2 is dated thus:- directory D:\DJGPPV2\SRC\LIBC\GO32, has 25 entries, 112450 bytes EXCEPTN.S 10598 1995 Dec 10 15.36.18 GO32CBRK.C 652 1995 May 7 21.21.42 Suggested alterations to DJGPP\SRC\LIBC\GO32\GO32CBRK.C :- ================================================================== *** go32cbrk.old Mon Jan 12 15:48:04 1998 - --- go32cbrk.c Mon Jan 12 15:49:10 1998 *************** *** 2,7 **** - --- 2,9 ---- #include #include + extern void (*userskeyboardhandler)(int X); + void _go32_want_ctrl_break(int yes) /* Yes means counting */ { int ctrl_break_counting = __djgpp_hwint_flags & 2; ================================================================== Suggested alterations to DJGPP\SRC\LIBC\GO32\EXCEPTN.S:- ================================================================== *** _ex.old Mon Jan 12 14:54:06 1998 - --- _ex.s Mon Jan 12 16:33:10 1998 *************** *** 284,293 **** - --- 284,324 ---- iret .align 4 + .global _userskeyboardhandler + _userskeyboardhandler: .int 0 /* void (*userskeyboardhandler)(int X); */ + /* If not 0, the interrupt 9 hook routine will call this function with:- */ + /* X &255 == keyboard event */ + /* (X>> 8)&255 == keyboard shift status as if from (AH=2, int 16h) */ + /* (X>>16)&255 == keyboard extended shift status as if from (AH=12h, int 16h) */ + _calluserskeyboardhandler: + pushl %ebx /* save EBX */ + movl _userskeyboardhandler,%ebx + testl %ebx,%ebx /* if zero, there is no function */ + je NOUSERHDLR + pushl %eax + pushw %fs + pushf + sti /* disable interrupts */ + movw __go32_info_block+26,%ax + movw %ax,%fs /* FS = _dos_ds */ + .byte 0x64 /* use segment reg FS */ + movw 0417,%ax /* [0x417] [0x418] are shift status */ + sall $8,%eax /* move EAX one byte up */ + inb $0x60,%al /* read keyboard event into AL */ + pushl %eax /* parameter for call */ + call *%ebx /* call the function */ + popf + popw %fs + popl %eax + NOUSERHDLR: + popl %ebx + ret + .global ___djgpp_kbd_hdlr ___djgpp_kbd_hdlr: pushl %eax pushl %ds + call _calluserskeyboardhandler .byte 0x2e /* CS: */ testb $1, ___djgpp_hwint_flags /* Disable? */ jne Lkbd_chain *************** *** 318,323 **** - --- 349,355 ---- ___djgpp_kbd_hdlr_pc98: pushl %eax pushl %ds + call _calluserskeyboardhandler .byte 0x2e /* CS: */ testb $1, ___djgpp_hwint_flags /* Disable? */ jne Lkbd_chain ------- End of forwarded message -------