[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DosRealFarCall()              Make far call to real mode address
------------------------------------------------------------------------------

 Function : Make a far call to a real mode address

 Syntax   : USHORT _far _cdecl DosRealFarCall( REALPTR realfn,
            PREGS regs, REALPTR reserved, short wordcount, ...);

 realfn     Real mode address to call.

 regs       Pointer to REGS16 structure containing the register values to be
            passed to and returned from real mode.

 reserved   Reserved. Must be zero.

 wordcount  Count of word arguments to be passed to realfn on the stack. Zero
            indicates none and a negative count causes them to be passed
            using the Pascal calling convention.

 ...        Arguments to realfn if wordcount <> 0.

 Return   : Register values in regs structure.

 DosRealFarCall() allows real mode code to be called from protected mode via
 a far call. The real mode code must return via a far return instruction.
 Arguments may be passed on the stack or in registers via the REGS16
 structure. Return values are returned in the REGS16 structure.

 Example:

    #include <stdio.h>
    #include <blx286.h>
    void main(void)
    {
    REGS16         regs;
    BYTE           far *xmsdriver ;
    printf("This program attempts to get the XMS driver ");
    printf("version number\n");
    printf("using DosRealIntr() and DosRealFarCall()\n\n");
    /* Important to clear structure to zero */
    memset(&regs, 0, sizeof(REGS16)) ;
    regs.ax = 0x4300 ;
    if (DosRealIntr(0x2f, &regs, 0L, 0) == 0)
    /* XMS installation check */
       if ((regs.ax & 0xff)==0x80)
          {
          printf("XMS driver installed\n");
          /* Get driver entry point */
          regs.ax = 0x4310;
          if (DosRealIntr(0x2f, &regs, 0L, 0) == 0)
             {
             xmsdriver = MK_FP(regs.es, regs.bx);
             /* real mode entry point */
             printf("XMS real mode entry point is : %Fp\n", 
                xmsdriver);
             /* Clear register structure to zero */
             memset(&regs, 0, sizeof(REGS16));
             /* Get version function */
             regs.ax = 0;
             if (DosRealFarCall((REALPTR)xmsdriver, 
                &regs, 0L, 0) == 0)
                if(regs.ax != 0)
                   printf("XMS driver version : %04X\n", regs.ax);
                else
                   printf("XMS get version call failed\n");
             else
                printf("DosRealFarCall() failed\n");
             }
          else
             printf("DosRealIntr() call failed\n");
          }
       else
          printf("XMS driver not installed\n");
    else
       printf("DosRealIntr() call failed\n");
    }

See Also: DosRealIntr()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson