Mail Archives: djgpp/1995/03/10/14:25:21
The original problem: To somehow make a protected mode driver callable
via software interrupts from a real mode program...
1st attempt: Set up interrupt traps and used system() to execute real
mode application (command.com, then a short test program)... found out that
system() swaps the protected mode application out of memory.
As per suggestions from DJ... I used stubedit to reserve memory for my
program (1024k virtual, 640k Conventional), also found right way to set up a
real mode interrupt (0x66) that calls a protected mode handler
(_go32_dpmi_alloc_real_mode_callback_iret)
"TSR" compiles, runs, and exits gracefully, so long as no software
interrupts occur... my test application does a "geninterrupt(0x66)" POOF
the system hangs, requiring a hard reset
I also tried writing my own version of the system() function, which
works using Int21 Func4B... this also worked until I tested the interrupt
So the question is... Am I still getting swapped out??? or is there a
glitch in my interrupt handler setup.... or should I get a copy of V2 before
proceeding ????? Source to Interrupt Handler follows:
#include <stdio.h>
#include <pc.h>
#include <sys/types.h>
#include <dpmi.h>
#include <conio.h>
#include <dos.h>
volatile int new_tc;
_go32_dpmi_registers regs;
union REGS inp,out;
struct SREGS sregs;
void handler(_go32_dpmi_registers *regs)
{
new_tc++;
}
typedef struct
{
char fname[32];
short envaddr;
long cmdline;
long fcb1ptr;
long fcb2ptr;
} execdata;
int main()
{
_go32_dpmi_seginfo old_handler, new_handler, info;
execdata edat;
printf("grabbing interrupt\n");
_go32_dpmi_get_real_mode_interrupt_vector(0x66, &old_handler);
new_handler.pm_offset = (int)handler;
_go32_dpmi_allocate_real_mode_callback_iret(&new_handler,®s);
_go32_dpmi_set_real_mode_interrupt_vector(0x66, &new_handler);
printf("Trapping interrupts, type EXIT to stop.\n");
strcpy(edat.fname,"command");
edat.envaddr = 0;
edat.cmdline = 0;
edat.fcb1ptr = 0;
edat.fcb2ptr = 0;
info.size = 4;
_go32_dpmi_allocate_dos_memory(&info);
_dos_memput(&edat,64,&info);
inp.x.ax = 0x4300;
inp.x.bx = 32;
inp.x.dx = 0;
sregs.ds = info.rm_segment;
sregs.es = info.rm_segment;
intdosx(&inp,&out,&sregs);
_go32_dpmi_free_dos_memory(&info);
printf("releasing interrupt\n");
_go32_dpmi_set_real_mode_interrupt_vector(0x66, &old_handler);
_go32_dpmi_free_real_mode_callback(&new_handler);
printf("Test count = %i\n",new_tc);
return 0;
}
Any suggestions???
John Barrett
jbarrett AT dallas DOT sgp DOT slb DOT com
- Raw text -