Message-ID: <20000914025420.6116.qmail@sina.com> From: computerboy To: djgpp AT delorie DOT com Subject: how hook int 21h from protect mode! Date: Thu Sep 14 02:54:20 2000 X-Mailer: SinaMail 3.0Beta (FireToad) X-Priority: 3 Reply-To: djgpp AT delorie DOT com hi, please help me , I'm new for djgpp, I want hook real mode int 21h at protect mode , I use a source from mailing list - test.c, but my pc hung, call_dos() seem reenter! can u give a simple and complete code for hook 21h! Very thinks >/***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; > >/* > * 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 ***/ ______________________________________ =================================================================== 新浪免费电子邮箱 http://mail.sina.com.cn 新浪推出奥运短信息手机点播服务 http://sms.sina.com.cn/