Mail Archives: djgpp/1998/07/20/17:16:55
Thanks Shelby Cain.
In the following program, `test.c',  I do nothing than intercepting DOS
interrupt and then passing it back to DOS without any change.  But I
cannot get it work under Window95.  It seems whenever you chain into DOS
in DJGPP,  functions that executing other program,   like spawn*. exec*
and system(), cease to work.  But other functions work fine.
/***START test.c ***/
#include <dpmi.h>
#include <go32.h>
#include <crt0.h>
#include <stdlib.h>
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
_go32_dpmi_seginfo  old_int21_vector;
_go32_dpmi_registers  my_int21_regs;
_go32_dpmi_seginfo  my_int21_info;
/*
 * My int 21h handler
 */
static
void call_dos(_go32_dpmi_registers *r)
{
 r->x.cs = old_int21_vector.rm_segment;
 r->x.ip = old_int21_vector.rm_offset;
 _go32_dpmi_simulate_fcall_iret(r);
}
int grab_dos() {
    _go32_dpmi_get_real_mode_interrupt_vector(0x21, &old_int21_vector);
    my_int21_info.pm_offset = (int) call_dos;
if(_go32_dpmi_allocate_real_mode_callback_iret(&my_int21_info,&my_int21_regs)
        || _go32_dpmi_set_real_mode_interrupt_vector(0x21,
&my_int21_info) )
    {
        return 1;
    }
    return 0;
}
void release_dos(void)
{
 _go32_dpmi_set_real_mode_interrupt_vector(0x21, &old_int21_vector);
 _go32_dpmi_free_real_mode_callback(&my_int21_info);
}
int main()
{
 if( grab_dos() == 0 ) {
  system("dir");
  release_dos();
 }
 return 0;
}
/*** END test.c ***/
Shelby Cain wrote:
> You have to make sure that you only intercept the particular function
> (AH=??) that you are interested in... all other functions must be
> passed to
> the original Int 21h handler.
>
> Jin wrote in message <35B36E78 DOT 2BC87A6C AT yahoo DOT com>...
> >Hi:
> >
> >I need to hook DOS interrupt before running other program, so I can
> >monitor
> >the program's console output without redirection (with redirection,
> the
> >output
> >will not be displayed on the console).  The problem is, after hooking
>
> >DOS,
> >the functions spawn*, exec* and system no longer work.
> >
> >Is there anyone tell me how to make the following codes work?
> >
> >Thanks in advance.
> >
> >
> >JIN
> >
> >
> >
> >
- Raw text -