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>set processor exception handler vector</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        Set Processor Exception Handler Vector


                 This function  allows protected  mode  applications  to
                 intercept processor  exceptions that are not handled by
                 the DPMI  environment.   Programs may  wish  to  handle
                 exceptions such  as not  present segment  faults  which
                 would otherwise generate a fatal error.

                 Every exception is first examined by the protected mode
                 operating system.   If  it can not handle the exception
                 it  then   reflects  it   through  the  protected  mode
                 exception handler  chain.   The final  handler  in  the
                 chain may  either reflect the exception as an interrupt
                 (as would  happen in real mode) or it may terminate the
                 current program.


            To Call

                 AX = 0203h
                 BL = Exception/fault number (00h-1Fh)
                 CX:(E)DX = Selector:Offset of exception handler

            Returns

                 If function was successful:
                 Carry flag is clear.

                 If function was not successful:
                 Carry flag is set.
                 The value passed in BL was invalid.

            Programmer's Notes

                 o    The value  passed in  CX must be a valid protected
                      mode code selector, not a real mode segment.
                 o    32-bit mode  programs must  supply a 32-bit offset
                      in the  EDX register.   If  your handler chains to
                      the next  exception handler  it must do so using a
                      32-bit interrupt stack frame.
                 o    The handler  should  return  using  a  far  return
                      instruction.   The original SS:(E)SP, CS:(E)IP and
                      flags on  the stack, including the interrupt flag,
                      will be restored.
                 o    All  fault   stack  frames  have  an  error  code.
                      However,  the   error  code   is  only  valid  for
                      exceptions 08h, 0Ah, 0Bh, 0Ch, 0Dh, and 0Eh.
                 o    The  handler   must  preserve   and  restore   all
                      registers.
                 o    The exception  handler will  be called on a locked
                      stack with  interrupts disabled.  The original SS,
                      (E)SP,  CS,  and  (E)IP  will  be  pushed  on  the
                      exception handler stack frame.
                 o    The handler  must either  return from  the call by
                      executing a far return or jump to the next handler
                      in the  chain (which  will execute a far return or
                      chain to the next handler).
                 o    The procedure  can modify any of the values on the
                      stack   pertaining   to   the   exception   before
                      returning.  This can be used, for example, to jump
                      to a  procedure by  modifying  the  CS:IP  on  the
                      stack.   Note that  the procedure  must not modify
                      the far  return address  on the  stack --  it must
                      return to  the original  caller.   The caller will
                      then restore the flags, CS:(E)IP and SS:(E)SP from
                      the stack frame.
                 o    If the  DPMI client  does not handle an exception,
                      or jumps  to the  default exception  handler,  the
                      host will  reflect the  exception as  an interrupt
                      for  exceptions   0,  1,   2,  3,  4,  5,  and  7.
                      Exceptions 6,  and 8-1Fh  will be treated as fatal
                      errors and the client will be terminated.
                 o    Exception  handlers   will  only   be  called  for
                      exceptions that occur in protected mode.


            Call-Back Stack Frames

                 Stack frame for 16-bit programs:

                      15       0


                          SS

                          SP

                        Flags

                          CS

                          IP

                       Err Code


                        Return
                          CS

                        Return
                          IP

                                 <-- SS:SP

                 Stack frame for 32-bit programs:

                 31            0


                           SS


                       ESP

                     EFlags

                           CS



                       EIP


                   Error Code

                         Ret CS





                   Return EIP


                                 <-- SS:ESP

                 Shaded fields should not be modified.  Other fields can
                 be  modified   before  returning   from  the  exception
                 handler.

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