Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>intdosx</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
intdosx

Usage

   #include <dos.h> /* register structures */
   int intdosx(union REGS *regsin,union REGS *regsout,
                struct SREGS *segregs);

Description

   Note-This function is not available under OS/2.

   This function performs a MS-DOS system call (int 0x21). Consult an MS-
   DOS manual for specific function and calling conventions.

   regsin   is a pointer to a structure containing the values of the
   registers AX, BX, CX, DX, SI and DI to be passed to the interrupt.

   regsout   is a pointer to a structure into which the return values of the
   registers will be written.

   The state of the carry flag can be determined from x.cflag in regsout.

   The segregs structure contains the segment register values passed to the
   interrupt for the intdosx. It is also used to return their values after
   the interrupt has been processed. The union REGS and struct SREGS are
   defined in dos.h.

   Under the X and P memory models intdos() and intdosx() carry out some
   filtering of parameters sent to the real mode interrupt. This filtering
   allows data stored in extended memory to be passed to the DOS function so
   that, for instance, much larger buffers than normal can be used with the

   DOS disk functions. Where pointers are passed to intdosx(), they are
   assumed to contain protected mode addresses. The filtering routine used
   for these functions assumes that all far pointers passed in registers to
   DOS have a segment address of DGROUP. If you use intdosx() and specify a
   selector other that DGROUP the results will be unpredictable.

   Some of the available DOS functions are not supported or only partially
   supported in the X and P memory models. Refer to the entry for int86()
   for more information.

Example 

   #include <dos.h>
   #include <stdlib.h>

   union REGS inregs, outregs;
   struct SREGS segregs;

   int main()
   {

       char far *string = "Print this string$";
       inregs.h.ah = 9;
       inregs.x.dx = FP_OFF(string);
       segregs.ds = FP_SEG(string);
       intdosx(&inregs,&outregs,&segregs);
       return EXIT_SUCCESS;
   }

Return Value

   The value that was in AX at the end of the interrupt.

See Also

   int86, int86, int86x, bdos int86x, bdos

The Interrupt Package

   The Interrupt package is designed to be a general purpose 80x86 interrupt
   handling package. New interrupt handlers can be defined for each vector.

   The function handling the interrupt controls whether the interrupt is
   chained to the previous interrupt vector or not.

   Zortech C++ has support for interrupt service routines in a different way
   to most other C and C++ compilers. It is done with library functions
   instead of a keyword. The advantage is that the library will create a
   stack for the interrupt service routine of a specified size, and the
   stack will conform to the constraints of the memory model used.

   These functions are not available under OS/2.

   There are several rules that must be followed when handling interrupts in
   C++. They are:

   1. No DOS calls or BIOS calls may be made during the handling of the
   interrupt, if the interrupt could occur when DOS or BIOS is executing.
   This is because DOS and BIOS are not re-entrant. Beware of functions like
   new and malloc which use DOS calls internally.

   2. Do not let the interrupt handler, or any function called by it, use

   more than the allocated stack space. If the handler is intended to be re-
   entrant, use a stacksize of zero to int_intercept so that a local stack
   is not created and the normal program stack is used instead.

   3. Do not call any function that is not re-entrant, for example be
   careful in your use of global variables. (Unpredictable results will
   occur.)

   4. Do not perform any I/O from within the interrupt handler, this is
   especially true for high level file I/O.

   5. When using variables set by interrupt handlers, declare the variables
   to be volatile.

   6. Turn off stack overflow checking for the handler.

   WARNING: Intercepting interrupts is an advanced technique and requires a
   good understanding of DOS and the IBM family of PCs to use it
   successfully.

Example

   #include <int.h>
   #include <stdio.h>
   #include <stdlib.h>

   volatile int ctrl_c_count = 0;

   #ifdef __cplusplus
   extern "C"
   #endif

   int do_ctrl_c(struct INT_DATA *pd)
   {
        ++ctrl_c_count;
        return 1;
   }

   int main()
   {

       int_intercept (0x23,do_ctrl_c,256);
   /* set handler */
       while(ctrl_c_count<3)
           printf("Number of Ctrl Cs is %d\n",ctrl_c_count);
       int_restore(0x23);
   /* reset old handler */
       return EXIT_SUCCESS;
   }





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson