Mail Archives: djgpp/2002/03/05/11:15:14
Ok, I made this real mode int 0xD exception handler.
I test it with a program that makes EBX equal 0x10000 and then does a
(using intel syntax here) mov [ebx], eax which in real mode causes int
0xD to be called.
Now the first thing I have my handler do is print a message...so far so
good. Now the problem. IP points to the opcode that caused int 0xD to
be called. I want to increase IP by 4 so that it'll skip the mov[ebx],
eax. The way I tried doesn't work.
If someone would look at the "Print_Error_Message" routine at the end of
this message, and tell me what I'm doing wrong and what I need to do,
I'd greatly appreciate it. Thanks.
#include <sys/farptr.h>
#include <stdio.h>
#include <crt0.h>
#include <dpmi.h>
#include <go32.h>
unsigned char SChar;
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
static __dpmi_regs callback_regs;
static _go32_dpmi_seginfo info;
void Print_Error_Message(_go32_dpmi_registers *r);
main()
{
unsigned short Offset, Segment;
Offset = _farpeekw(_dos_ds, 0x34);
Segment = _farpeekw(_dos_ds, 0x36);
printf("\nOld 0DH Segment%X\nOld 0DH Offset%X\n", Segment,
Offset);
__dpmi_regs r;
info.pm_offset = (long)Print_Error_Message;
_go32_dpmi_allocate_real_mode_callback_iret(&info,
&callback_regs);
_go32_dpmi_set_real_mode_interrupt_vector(0xD, &info);
/* This is needed for my 486 */
r.x.ax = 0x250D;
r.x.ds = info.rm_segment;
r.x.dx = info.rm_offset;
__dpmi_int(0x21, &r);
/*****************************/
Offset = _farpeekw(_dos_ds, 0x34);
Segment = _farpeekw(_dos_ds, 0x36);
printf("\nNew 0DH Segment%X\nNew 0DH Offset%X\n", Segment,
Offset);
/* __djgpp_exception_toggle(); */ /* Only needed if
exceptions linked */
r.x.ax = 0x3100;
r.x.dx = 16;
__dpmi_int(0x21, &r);
}
void Print_Error_Message(_go32_dpmi_registers *r)
{
__dpmi_regs reg;
printf("You Have Caused A General Protection Fault.\n");
r->x.ip+= 4;
//reg.x.ax = 0x4c00;
//__dpmi_int(0x21, ®);
}
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
- Raw text -