Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Dos Protected Mode Interface - <b>notes for dos extenders</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        NOTES FOR DOS EXTENDERS


            Many programs  that use  DPMI will be bound to DOS extenders
            so that  they will be able to run under any DOS environment.
            Existing DOS extenders support APIs that differ from the Int
            31h interface.   Usually,  DOS  extenders  use  an  Int  21h
            multiplex for their extended APIs.

            Extenders  that   support  DPMI   will  need  to  initialize
            differently when they are run under DPMI environments.  They
            will need  to enter  protected mode  using the  DPMI real to
            protected mode  entry point, install their own API handlers,
            and then load the DOS extended application program.


        Initialization of  Extenders


            DOS extenders  should check  for the presence of DPMI before
            attempting to  allocate memory or enter protected mode using
            any other  API.   DOS extenders should check for APIs in the
            following order:

                 DOS Protected Mode Interface
                 Virtual Control Program Interface
                 eXtended Memory Specification
                 Int 15h memory allocation

            When DPMI  services are  detected,  extenders  that  provide
            interfaces that  extend or are different from the basic DPMI
            interface will switch into protected mode and initialize any
            internal data  structures.   DPMI compatible  extenders that
            provide  no   API  extensions   should  simply  execute  the
            protected mode application in real mode.


        Installing API Extensions


            DOS  extenders  typically  use  Int  21h  to  implement  API
            extensions.  Under DPMI, a DOS extender will need to install
            an API  translation library  by hooking Int 21h via then get
            and set  protected mode interrupt vector functions.
            The DOS  extender library  then gets to see every DOS
            call executed  by the  application program.  If the API does
            not have any pointers then the interrupt can be reflected to
            the original  interrupt handler.   The  default handler will
            pass the  interrupt  to  real  mode.    Other  APIs  can  be
            explicitly mapped by the DOS extender.

            WARNING:   The translation  library code should be in locked
            memory to  prevent page  faults while  DOS is  in a critical
            section.   This could  happen, for  instance, if  a  program
            called DOS reentrantly from an Int 24h (critical error).


        Loading the Application Program


            Once the  API translation  library has been initialized, the
            DOS extender can load the application program using standard
            DOS calls.  Memory should be allocated using the DPMI memory
            allocation services.


        Providing API Extensions


            DPMI call  0A00h provides a standard mechanism for providing
            vendor specific extensions to the standard APIs.  To support
            extensions under a DPMI environment, the translation library
            should hook  the Int 31h chain (using the DOS get/set vector
            calls) and  watch for  call 0A00h.  When this call is issued
            with the  proper string  parameter, the  Int 31h  hook  code
            should modify  ES:(E)DI, clear  the carry flag on the stack,
            and iret  without passing  the call  down the Int 31h chain.
            If  the  string  passed  in  ES:(E)DI  does  not  match  the
            extensions supported  by the library then the call should be
            passed down the Int 31h chain.

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