Mail Archives: djgpp/2000/09/13/22:55:16
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 <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 ***/
______________________________________
===================================================================
ÐÂÀËÃâ·Ñµç×ÓÓÊÏä http://mail.sina.com.cn
ÐÂÀËÍÆ³ö°ÂÔ˶ÌÐÅÏ¢ÊÖ»úµã²¥·þÎñ
http://sms.sina.com.cn/
- Raw text -