Ignore:
Timestamp:
Oct 9, 1999, 5:03:47 PM (26 years ago)
Author:
sandervl
Message:

Exception handling changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/exceptions.cpp

    r1221 r1224  
    1 /* $Id: exceptions.cpp,v 1.22 1999-10-09 13:33:23 sandervl Exp $ */
     1/* $Id: exceptions.cpp,v 1.23 1999-10-09 15:03:10 sandervl Exp $ */
    22
    33/*
     
    6464#include "mmap.h"
    6565#include <wprocess.h>
     66#include "oslibexcept.h"
    6667
    6768//Global Process Unhandled exception filter
     
    130131                               DWORD es,  DWORD fs,   DWORD gs,  DWORD ss)
    131132{
    132   PWINEXCEPTION_FRAME   pframe, dispatch, nested_frame;
    133133  WINEXCEPTION_RECORD   record;
    134   WINEXCEPTION_RECORD   newrec;
    135134  WINEXCEPTION_POINTERS ExceptionInfo;
    136135  WINCONTEXT            context;
     
    175174  }
    176175
     176  rc = RtlDispatchException(&record, &context);
     177
     178  // and finally, the unhandled exception filter
     179  if(rc == ExceptionContinueSearch && UnhandledExceptionFilter != NULL)
     180  {
     181    ExceptionInfo.ExceptionRecord = &record;
     182    ExceptionInfo.ContextRecord   = &context;
     183
     184    rc = UnhandledExceptionFilter(&ExceptionInfo);
     185  }
     186
     187  // terminate the process
     188  if(rc != ExceptionContinueExecution ||
     189     record.ExceptionFlags & EH_NONCONTINUABLE)
     190  {
     191    dprintf(("KERNEL32: RaiseException terminating process.\n"));
     192    DosExit(EXIT_PROCESS, 0);
     193  }
     194
     195  return;
     196}
     197//******************************************************************************
     198//******************************************************************************
     199DWORD RtlDispatchException(WINEXCEPTION_RECORD *pRecord, WINCONTEXT *pContext)
     200{
     201  PWINEXCEPTION_FRAME   pframe, dispatch, nested_frame;
     202  int                   rc;
     203
    177204  // get chain of exception frames
    178   rc     = ExceptionContinueSearch;
     205  rc  = ExceptionContinueSearch;
    179206
    180207  nested_frame = NULL;
     
    193220            (int)pframe & 3)
    194221        {
    195             record.ExceptionFlags |= EH_STACK_INVALID;
     222            pRecord->ExceptionFlags |= EH_STACK_INVALID;
    196223            break;
    197224        }
    198225
    199         rc = pframe->Handler(&record,
     226        rc = pframe->Handler(pRecord,
    200227                             pframe,
    201                              &context,
    202                              &dispatch);
     228                             pContext,
     229                             dispatch);
    203230
    204231        if (pframe == nested_frame)
     
    206233            /* no longer nested */
    207234            nested_frame = NULL;
    208             record.ExceptionFlags &= ~EH_NESTED_CALL;
     235            pRecord->ExceptionFlags &= ~EH_NESTED_CALL;
    209236        }
    210237
     
    214241        {
    215242        case ExceptionContinueExecution:
    216             if (!(record.ExceptionFlags & EH_NONCONTINUABLE)) return;
    217             DosExit(EXIT_PROCESS, 0);
     243            if (!(pRecord->ExceptionFlags & EH_NONCONTINUABLE)) return rc;
    218244            break;
    219245        case ExceptionContinueSearch:
     
    221247        case ExceptionNestedException:
    222248            if (nested_frame < dispatch) nested_frame = dispatch;
    223             record.ExceptionFlags |= EH_NESTED_CALL;
     249            pRecord->ExceptionFlags |= EH_NESTED_CALL;
    224250            break;
    225251        default:
    226             DosExit(EXIT_PROCESS, 0);
    227252            break;
    228253        }
     
    230255        pframe = pframe->Prev;
    231256  }
    232 
    233   // and finally, the unhandled exception filter
    234   if(rc == ExceptionContinueSearch && UnhandledExceptionFilter != NULL)
    235   {
    236     ExceptionInfo.ExceptionRecord = &record;
    237     ExceptionInfo.ContextRecord   = &context;
    238 
    239     rc = UnhandledExceptionFilter(&ExceptionInfo);
    240   }
    241 
    242   // terminate the process
    243   if(rc != ExceptionContinueExecution)
    244   {
    245     dprintf(("KERNEL32: RaiseException terminating process.\n"));
    246     DosExit(EXIT_PROCESS, 0);
    247   }
    248 
    249   return;
    250 }
    251 
    252 
     257  return rc;
     258}
    253259/*****************************************************************************
    254260 * Name      : int _Pascal OS2RtlUnwind
     
    934940                                   PVOID                        p)
    935941{
    936   //  pERegRec->prev_structure = 0;
    937942  dprintfException(pERepRec, pERegRec, pCtxRec, p);
    938943
     
    948953  case XCPT_FLOAT_UNDERFLOW:
    949954        dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception, fix and continue\n"));
    950         pCtxRec->ctx_env[0] |= 0x1F;
    951         pCtxRec->ctx_stack[0].losig = 0;
    952         pCtxRec->ctx_stack[0].hisig = 0;
    953         pCtxRec->ctx_stack[0].signexp = 0;
    954 
    955         return (XCPT_CONTINUE_EXECUTION);
     955        if(fIsOS2Image == FALSE)  //Only for real win32 apps
     956        {
     957                if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == FALSE)
     958                {
     959                        pCtxRec->ctx_env[0] |= 0x1F;
     960                        pCtxRec->ctx_stack[0].losig = 0;
     961                        pCtxRec->ctx_stack[0].hisig = 0;
     962                        pCtxRec->ctx_stack[0].signexp = 0;
     963                }
     964                return (XCPT_CONTINUE_EXECUTION);
     965        }
     966        else    return (XCPT_CONTINUE_SEARCH);
    956967
    957968  case XCPT_PROCESS_TERMINATE:
     
    10081019  case XCPT_IN_PAGE_ERROR:
    10091020CrashAndBurn:
     1021        if(fIsOS2Image == FALSE)  //Only for real win32 apps
     1022        {
     1023                if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == TRUE)
     1024                {
     1025                        return (XCPT_CONTINUE_EXECUTION);
     1026                }
     1027        }
    10101028        dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
    10111029        pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
Note: See TracChangeset for help on using the changeset viewer.