Mail Archives: djgpp/1997/12/08/02:13:26
There seems to be a problem with the ___djgpp_hw_exception trick and
windows 95 (of course). The below program crashes my DOS box everytime.
Sometimes it takes a while, but it's very consistent. As far as I can
tell, I'm doing everything by the book. I hook the PIT timer, I don't
re-program it, I chain to the old handler, yada yada yada...
I've traced through the crashed location with Win-Ice, and it's inside of VMM,
inside the Build_Int_Stack_Frame function. I *think* the bug is caused by
a small window in the Win95 DPMI server where it expects a valid %SS in
your code. I'm not real sure though.
Is there a reliable way to raise signals this way under win95? I've
written code to hook the interrupt gates directly, but I'm saving that as
a last resort.
Josh Turpen
44699 AT ef DOT gc DOT maricopa DOT edu
compile with: gcc -o test1.exe test1.c test1asm.S
------------------test1.c----------------------------
#include <stdio.h>
#include <dpmi.h>
#include <signal.h>
#include <sys/segments.h>
extern void int_handler(void);
void sig_handler(int signum);
int tick;
int old_sel, old_off;
void main()
{
__dpmi_paddr old, new;
void (*old_handler)(int);
old_handler = signal(SIGILL, sig_handler);
__dpmi_get_protected_mode_interrupt_vector(0x8, &old);
old_sel = old.selector;
old_off = old.offset32;
new.offset32 = (long) int_handler;
new.selector = _my_cs();
__dpmi_set_protected_mode_interrupt_vector(0x8, &new);
while(!kbhit())
{
printf("Tick %d\n", tick);
}
__dpmi_set_protected_mode_interrupt_vector(0x8, &old);
signal(SIGILL, old_handler);
}
void sig_handler(signum)
{
tick++;
}
-------------------------end test1.c--------------------
--------------------------test1asm.S--------------------
.globl _int_handler
_int_handler:
pushl $0
pushl $0
pushl %eax
pushl %ds
.byte 0x2e
movw ___djgpp_ds_alias, %ds
movl $0x99, %eax
call ___djgpp_hw_exception
movl _old_sel, %eax
movl %eax, 12(%esp)
movl _old_off, %eax
movl %eax, 8(%esp)
popl %ds
popl %eax
lret
------------------------end test1asm.S---------------------
- Raw text -