Message-ID: <01BB512C.115C67A0@psp3> From: Steve Higgins To: "'DJGPP Mail List'" Subject: Replacing stdin / stdout with my own versions. Date: Mon, 3 Jun 1996 09:07:01 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi all, I have a rather complex command line oriented program (similar to gdb) which uses stdin and stdout to get and show information. What I want to do is to write my own wrapper program which grabs stdin and stdout and presents a nicer user interface to the world, but talk to the low level app through these grabbed input and output. I started by writing a simple program to see if this is possible (see below). What it should do is grab the keyboard BIOS interrupt (0x16) and reply with a carrage return whenever a keypress is asked for. What seems to happen is that the program gets as far as getchar() and then waits for ever. I have also tried replacing the stdinInterrupt with void stdinInterrupt(_go32_dpmi_registers *r) { r->x.ip = OldStdinVector.rm_offset; r->x.cs = OldStdinVector.rm_segment; _go32_dpmi_simulate_fcall_iret(r); } With the same hanging problem. Does anyone have any idea what I am doing wrong? Has anyone done anything similar in the past - any source code? Thanks for any help Steve. /************ start of source code **************/ #include #include #include #include #include static _go32_dpmi_seginfo NewStdinVector; static _go32_dpmi_seginfo OldStdinVector; static _go32_dpmi_registers StdinRegs; int count = 0; void stdinInterrupt(_go32_dpmi_registers *r) { switch(r->h.ah) { case 0: /* get char (blocking) */ r->h.ah = 0x1C; /* scan code */ r->h.al = 0x0D; /* ascii code */ r->x.flags = 0; /* ZF = 0 means char ready (probably not needed) */ break; case 1: /* report whether character ready */ r->x.flags = 0; /* ZF = 0 means char ready */ break; case 2: /* get shift status */ r->h.al = 0; /* holds shift state */ break; } } #define INTVECTOR 0x16 void stdinInit() { /* Get the bios keyboard services interrupt vector. */ _go32_dpmi_get_real_mode_interrupt_vector(INTVECTOR,&OldStdinVector); NewStdinVector.pm_offset = (int) stdinInterrupt; _go32_dpmi_allocate_real_mode_callback_iret(&NewStdinVector,&StdinRegs); _go32_dpmi_set_real_mode_interrupt_vector(INTVECTOR,&NewStdinVector); } void stdinExit() { _go32_dpmi_set_real_mode_interrupt_vector(INTVECTOR,&OldStdinVector); _go32_dpmi_free_real_mode_callback(&NewStdinVector); } int main() { int ch; stdinInit(); ch = getchar(); putchar(ch); stdinExit(); return 0; }