![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-15 05:26 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS开发编程 & 发展交流 (开发室) » How do I hook an interrupt handler in Watcom C? (under protected mode) |
| Printable Version 1,034 / 3 |
| Floor1 superham | Posted 2002-12-25 00:00 |
| 初级用户 Posts 2 Credits 112 | |
|
Thanks
|
|
| Floor2 hbnf | Posted 2003-09-04 00:00 |
| 初级用户 Posts 1 Credits 102 | |
|
Same as BC, _setvect(int, void())
|
|
| Floor3 lemonhall | Posted 2003-09-06 00:00 |
| 高级用户 Posts 183 Credits 639 | |
|
Hmm, not sure. Under protected mode you can't use INT 24 anymore. There was discussion under DJGPP about files on how to hook a short program under DPMI0.9, not sure whether that helps you.
|
|
| Floor4 ATLaS | Posted 2003-09-07 00:00 |
| 初级用户 Posts 29 Credits 169 | |
|
Under Watcom, hooking an interrupt in protected mode requires writing an interrupt wrapper yourself in assembly. In the Watcom installation directory\samples\goodies there are bimo.asm and bimodal.c, which are examples of setting protected-mode and real-mode interrupt service functions for the same interrupt vector. You can refer to them. The main thing is to consider protection of the data area and code segment under protected mode. If you want to simplify it, I tried using only int 31 to set the protected-mode interrupt, and on some machines it didn't work properly, though on some it did. You can give it a try.
void __interrupt __far (*oldISR)(void); void __interrupt __far newISR(void) { .... outp(0x20, 0x20); } union REGS r; void __far *fh; /* get old isr pointer */ r.x.eax = 0x0204; r.x.ebx = (unsigned long)vector; int386(0x31, &r, &r); oldISR = (void __interrupt *)MK_FP(r.x.ecx, r.x.edx); /* set new isr */ fh = (void __far *)newISR; r.x.eax = 0x0205; r.x.ebx = (unsigned long)vector; r.x.ecx = (unsigned long)FP_SEG(fh); r.x.edx = (unsigned long)FP_OFF(fh); int386(0x31, &r, &r); |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |