From: "Shelby Cain" References: <35B36E78 DOT 2BC87A6C AT yahoo DOT com> Subject: Re: Problem hooking DOS int 21h Date: Mon, 20 Jul 1998 12:01:27 -0500 Lines: 87 Message-ID: Newsgroups: comp.os.msdos.djgpp NNTP-Posting-Host: [207.43.206.174] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 > > >/***START test.c ***/ > >#include >#include >#include >#include > > >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; > >/* > * This function is called only within our 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; >} > > >