Ignore:
Timestamp:
Sep 8, 2000, 8:07:52 PM (25 years ago)
Author:
sandervl
Message:

exception changes, implemented enumresourcelanguages + put back some old code

File:
1 edited

Legend:

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

    r3872 r4224  
    1 /* $Id: exceptions.cpp,v 1.42 2000-07-20 18:06:59 sandervl Exp $ */
     1/* $Id: exceptions.cpp,v 1.43 2000-09-08 18:07:49 sandervl Exp $ */
     2
     3/* WARNING: Compiling this module with ICC with optimizations turned on   */
     4/* currently breaks this module. To get correct code, it is not necessary */
     5/* to turn all optimizations off, just use the -Op- flag.                 */
    26
    37/*
     
    6771#include "exceptstackdump.h"
    6872
    69 #define DBG_LOCALLOG    DBG_exceptions
     73#define DBG_LOCALLOG    DBG_exceptions
    7074#include "dbglocal.h"
    7175
     
    8084void KillWin32Process(void);
    8185
     86#ifdef DEBUG
     87void PrintWin32ExceptionChain(PWINEXCEPTION_FRAME pframe);
     88#else
     89#define PrintWin32ExceptionChain(a)
     90#endif
    8291
    8392/*****************************************************************************
     
    142151  dprintf(("KERNEL32: RaiseException(%08xh)\n",
    143152           dwExceptionCode));
     153
     154  memset(&record, 0, sizeof(record));
    144155
    145156  /* compose an exception record */
     
    182193  if(rc == ExceptionContinueSearch && UnhandledExceptionFilter != NULL)
    183194  {
     195    dprintf(("KERNEL32: RaiseException calling UnhandledExceptionFilter.\n"));
     196
    184197    ExceptionInfo.ExceptionRecord = &record;
    185198    ExceptionInfo.ContextRecord   = &context;
    186199
    187200    rc = UnhandledExceptionFilter(&ExceptionInfo);
     201    //FIXME: UnhandledExceptionFilter does NOT return the same values as
     202    //       other filters!!
    188203  }
    189204
     
    196211  }
    197212
     213  dprintf(("KERNEL32: RaiseException returns.\n"));
    198214  return;
    199215}
     216
     217
    200218//******************************************************************************
    201219//******************************************************************************
     
    212230  pframe      = (PWINEXCEPTION_FRAME)winteb->except;
    213231
     232  dprintf(("KERNEL32: RtlDispatchException entered"));
     233
     234  PrintWin32ExceptionChain(pframe);
     235
    214236  // walk the exception chain
    215237  while( (pframe != NULL) && (pframe != ((void *)0xFFFFFFFF)) )
    216238  {
    217         dispatch=0;
    218 
    219         dprintf(("Calling exception handler %x", pframe->Handler));
     239        dprintf(("KERNEL32: RtlDispatchException - pframe=%08X, pframe->Prev=%08X", pframe, pframe->Prev));
     240        if (pframe == pframe->Prev) {
     241            dprintf(("KERNEL32: RtlDispatchException - Invalid exception frame!!"));
     242            return 0;
     243        }
     244
     245        dispatch=0;
     246
    220247        /* Check frame address */
    221248        if (((void*)pframe < winteb->stack_low) ||
     
    223250            (int)pframe & 3)
    224251        {
     252            dprintf(("Invalid stack! low=%08X, top=%08X, pframe = %08X",
     253                    winteb->stack_low, winteb->stack_top, pframe));
     254
    225255            pRecord->ExceptionFlags |= EH_STACK_INVALID;
    226256            break;
    227257        }
    228258
    229         rc = pframe->Handler(pRecord,
     259        dprintf(("KERNEL32: RtlDispatchException - calling exception handler %08X", pframe->Handler));
     260
     261        rc = pframe->Handler(pRecord,
    230262                             pframe,
    231263                             pContext,
    232264                             dispatch);
     265
     266        dprintf(("KERNEL32: RtlDispatchException - exception handler returned %#x", rc));
     267        PrintWin32ExceptionChain(pframe);
    233268
    234269        if (pframe == nested_frame)
     
    239274        }
    240275
    241         dprintf(("exception handler returned %x", rc));
    242276
    243277        switch(rc)
    244278        {
    245279        case ExceptionContinueExecution:
    246             if (!(pRecord->ExceptionFlags & EH_NONCONTINUABLE)) return rc;
     280            if (!(pRecord->ExceptionFlags & EH_NONCONTINUABLE)) {
     281                dprintf(("KERNEL32: RtlDispatchException returns %#x (ContinueExecution)", rc));
     282                return rc;
     283            }
    247284            break;
    248285        case ExceptionContinueSearch:
     
    256293        }
    257294
     295        dprintf(("KERNEL32: RtlDispatchException - going from frame %08X to previous frame %08X", pframe, pframe->Prev));
     296        if (pframe == pframe->Prev) {
     297            dprintf(("KERNEL32: RtlDispatchException - Invalid exception frame!!"));
     298            break;
     299        }
    258300        pframe = pframe->Prev;
    259301  }
     302  dprintf(("KERNEL32: RtlDispatchException returns %#x", rc));
     303  PrintWin32ExceptionChain(pframe);
    260304  return rc;
    261305}
     
    284328  WINEXCEPTION_RECORD record, newrec;
    285329  WINCONTEXT          context;
    286   int                 rc;
    287 
    288   dprintf(("KERNEL32: RtlUnwind %x %x\n", pEndFrame, pRecord));
     330  DWORD               rc;
     331
     332  dprintf(("KERNEL32: RtlUnwind pEndFrame=%08X, unusedEip=%08X, pRecord=%08X, returnEax=%#x\n", pEndFrame, unusedEip, pRecord, returnEax));
     333
    289334
    290335  memset(&context, 0, sizeof(context));
     
    310355  if(!pRecord)
    311356  {
     357    memset(&record, 0, sizeof(record));
    312358    record.ExceptionCode    = STATUS_UNWIND;
    313359    record.ExceptionFlags   = 0;
     
    324370  TEB *winteb = GetThreadTEB();
    325371  frame       = (PWINEXCEPTION_FRAME)winteb->except;
     372
     373  PrintWin32ExceptionChain(frame);
    326374
    327375  while ((frame != (PWINEXCEPTION_FRAME)0xffffffff) && (frame != pEndFrame))
     
    334382            newrec.ExceptionRecord  = pRecord;
    335383            newrec.NumberParameters = 0;
    336             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    337             DosExit(EXIT_THREAD, 0);
     384            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     385            DosExit(EXIT_THREAD, 0);
    338386        }
    339387        if (((void*)frame < winteb->stack_low) ||
     
    345393            newrec.ExceptionRecord  = pRecord;
    346394            newrec.NumberParameters = 0;
    347             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    348             DosExit(EXIT_THREAD, 0);
     395            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     396            DosExit(EXIT_THREAD, 0);
    349397        }
    350398
    351399        /* Call handler */
    352         dprintf(("Calling exception handler %x", frame->Handler));
    353         switch(frame->Handler(pRecord, frame, &context, &dispatch ))
     400        dprintf(("KERNEL32: RtlUnwind - calling exception handler %08X", frame->Handler));
     401        rc = frame->Handler(pRecord, frame, &context, &dispatch);
     402        dprintf(("KERNEL32: RtlUnwind - handler returned %#x", rc));
     403        switch (rc)
    354404        {
    355405        case ExceptionContinueSearch:
     
    363413            newrec.ExceptionRecord  = pRecord;
    364414            newrec.NumberParameters = 0;
    365             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    366             DosExit(EXIT_THREAD, 0);
     415            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     416            DosExit(EXIT_THREAD, 0);
    367417            break;
    368418        }
     419        dprintf(("KERNEL32: RtlUnwind (before)- frame=%08X, frame->Prev=%08X", frame, frame->Prev));
    369420        SetExceptionChain((DWORD)frame->Prev);
    370421        frame = frame->Prev;
    371   }
     422        dprintf(("KERNEL32: RtlUnwind (after) - frame=%08X, frame->Prev=%08X", frame, frame->Prev));
     423  }
     424
     425
     426  /* Note: I _think_ that on Win32, RtlUnwind unwinds exception handlers up  */
     427  /*  and _including_ the handler in pEndFrame argument. My reasons are:     */
     428  /*   - MSVCRT sometimes calls RtlUnwind with the address of the very first */
     429  /*     exception handler - could be just inefficient code                  */
     430  /*   - after a call to RtlUnwind, MSVCRT in some cases tries to restore    */
     431  /*     the original exception handler. If RtlUnwind didn't remove it,      */
     432  /*     the exception chain gets looped, spelling very bad mojo!            */
     433  if (frame == pEndFrame)
     434  {
     435        /* Just repeat what we did in the while loop above */
     436        /* Check frame address */
     437        if (pEndFrame && (frame > pEndFrame))
     438        {
     439            newrec.ExceptionCode    = STATUS_INVALID_UNWIND_TARGET;
     440            newrec.ExceptionFlags   = EH_NONCONTINUABLE;
     441            newrec.ExceptionRecord  = pRecord;
     442            newrec.NumberParameters = 0;
     443            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     444            DosExit(EXIT_THREAD, 0);
     445        }
     446        if (((void*)frame < winteb->stack_low) ||
     447            ((void*)(frame+1) > winteb->stack_top) ||
     448            (int)frame & 3)
     449        {
     450            newrec.ExceptionCode    = STATUS_BAD_STACK;
     451            newrec.ExceptionFlags   = EH_NONCONTINUABLE;
     452            newrec.ExceptionRecord  = pRecord;
     453            newrec.NumberParameters = 0;
     454            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     455            DosExit(EXIT_THREAD, 0);
     456        }
     457
     458        /* Call handler */
     459        dprintf(("KERNEL32: RtlUnwind - calling exception handler %08X", frame->Handler));
     460        rc = frame->Handler(pRecord, frame, &context, &dispatch);
     461        dprintf(("KERNEL32: RtlUnwind - handler returned %#x", rc));
     462        switch (rc)
     463        {
     464        case ExceptionContinueSearch:
     465            break;
     466        case ExceptionCollidedUnwind:
     467            frame = dispatch;
     468            break;
     469        default:
     470            newrec.ExceptionCode    = STATUS_INVALID_DISPOSITION;
     471            newrec.ExceptionFlags   = EH_NONCONTINUABLE;
     472            newrec.ExceptionRecord  = pRecord;
     473            newrec.NumberParameters = 0;
     474            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     475            DosExit(EXIT_THREAD, 0);
     476            break;
     477        }
     478        dprintf(("KERNEL32: RtlUnwind (before)- frame=%08X, frame->Prev=%08X", frame, frame->Prev));
     479        SetExceptionChain((DWORD)frame->Prev);
     480        frame = frame->Prev;
     481        dprintf(("KERNEL32: RtlUnwind (after) - frame=%08X, frame->Prev=%08X", frame, frame->Prev));
     482  }
     483
     484  dprintf(("KERNEL32: RtlUnwind returning.\n"));
     485  PrintWin32ExceptionChain(frame);
    372486  return(0);
    373487}
     
    415529                                  };
    416530
    417   dprintf(("KERNEL32: UnhandledExceptionFilter\n"));
    418 
    419   if(CurrentUnhExceptionFlt && !(CurrentErrorMode & (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX)))
     531  dprintf(("KERNEL32: Default UnhandledExceptionFilter, CurrentErrorMode=%X", CurrentErrorMode));
     532
     533  // We must not care about ErrorMode here!! The app expects that its own
     534  // UnhandledExceptionFilter will be cared even if it never touched ErrorMode.
     535  if(CurrentUnhExceptionFlt) // && !(CurrentErrorMode & (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX)))
    420536  {
     537    dprintf(("KERNEL32: Calling user UnhandledExceptionFilter"));
    421538    rc = CurrentUnhExceptionFlt(lpexpExceptionInfo);
    422539    if(rc != WINEXCEPTION_CONTINUE_SEARCH)
     
    492609  LPTOP_LEVEL_EXCEPTION_FILTER old = CurrentUnhExceptionFlt;
    493610
    494   dprintf(("KERNEL32: SetUnhandledExceptionFilter to %X\n",
     611  dprintf(("KERNEL32: SetUnhandledExceptionFilter to %08X\n",
    495612           lpTopLevelExceptionFilter));
    496613
     
    524641
    525642  if(fEntry == FALSE) {
    526         fEntry = TRUE;
    527         ExitProcess(666);
    528         return;
     643        fEntry = TRUE;
     644        ExitProcess(666);
     645        return;
    529646  }
    530647  //Restore original OS/2 TIB selector
     
    857974
    858975  if (pCtxRec->ContextFlags & CONTEXT_CONTROL)         /* check flags */
    859     dprintf(("   SS:ESP=%04x:%08x EFLAGS=%08x\n"
    860              "       CS:EIP=%04x:%08x EBP   =%08x\n",
     976    dprintf(("   SS:ESP=%04x:%08x EFLAGS=%08x\n",
    861977             pCtxRec->ctx_SegSs,
    862978             pCtxRec->ctx_RegEsp,
    863              pCtxRec->ctx_EFlags,
     979             pCtxRec->ctx_EFlags));
     980    dprintf(("   CS:EIP=%04x:%08x EBP   =%08x\n",
    864981             pCtxRec->ctx_SegCs,
    865982             pCtxRec->ctx_RegEip,
     
    867984
    868985  if (pCtxRec->ContextFlags & CONTEXT_INTEGER)         /* check flags */
    869     dprintf(("   EAX=%08x EBX=%08x ESI=%08x\n"
    870              "       ECX=%08x EDX=%08x EDI=%08x\n",
     986    dprintf(("   EAX=%08x EBX=%08x ESI=%08x\n",
    871987             pCtxRec->ctx_RegEax,
    872988             pCtxRec->ctx_RegEbx,
    873              pCtxRec->ctx_RegEsi,
     989             pCtxRec->ctx_RegEsi));
     990    dprintf(("   ECX=%08x EDX=%08x EDI=%08x\n",
    874991             pCtxRec->ctx_RegEcx,
    875992             pCtxRec->ctx_RegEdx,
     
    877994
    878995  if (pCtxRec->ContextFlags & CONTEXT_SEGMENTS)        /* check flags */
    879     dprintf(("   DS=%04x     ES=%08x"
    880              "       FS=%04x     GS=%04x\n",
     996    dprintf(("   DS=%04x     ES=%08x",
    881997              pCtxRec->ctx_SegDs,
    882               pCtxRec->ctx_SegEs,
     998              pCtxRec->ctx_SegEs));
     999    dprintf(("   FS=%04x     GS=%04x\n",
    8831000              pCtxRec->ctx_SegFs,
    8841001              pCtxRec->ctx_SegGs));
     
    9361053                                   PVOID                        p)
    9371054{
     1055  //MN: If EH_NESTED_CALL is set, an exception occurred during the execution
     1056  //    of this exception handler. We better bail out ASAP or we'll likely
     1057  //    recurse infinitely until we run out of stack space!!
     1058  if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
     1059      return XCPT_CONTINUE_SEARCH;
     1060
    9381061  //SvL: Check if exception inside debug fprintf -> if so, clear lock so
    9391062  //     next dprintf won't wait forever
    9401063  CheckLogException();
     1064
    9411065
    9421066  /* Access violation at a known location */
     
    9501074  case XCPT_FLOAT_STACK_CHECK:
    9511075  case XCPT_FLOAT_UNDERFLOW:
    952         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    953         dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception\n"));
    954         if(fIsOS2Image == FALSE)  //Only for real win32 apps
    955         {
    956                 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == FALSE)
    957                 {
    958                         pCtxRec->ctx_env[0] |= 0x1F;
    959                         pCtxRec->ctx_stack[0].losig = 0;
    960                         pCtxRec->ctx_stack[0].hisig = 0;
    961                         pCtxRec->ctx_stack[0].signexp = 0;
    962                 }
    963                 dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n"));
    964                 return (XCPT_CONTINUE_EXECUTION);
    965         }
    966         else
    967         {
    968                 dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n"));
    969                 return (XCPT_CONTINUE_SEARCH);
    970         }
     1076        dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1077        dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception\n"));
     1078        if(fIsOS2Image == FALSE)  //Only for real win32 apps
     1079        {
     1080                if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == FALSE)
     1081                {
     1082                        pCtxRec->ctx_env[0] |= 0x1F;
     1083                        pCtxRec->ctx_stack[0].losig = 0;
     1084                        pCtxRec->ctx_stack[0].hisig = 0;
     1085                        pCtxRec->ctx_stack[0].signexp = 0;
     1086                }
     1087                dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n"));
     1088                return (XCPT_CONTINUE_EXECUTION);
     1089        }
     1090        else
     1091        {
     1092                dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n"));
     1093                return (XCPT_CONTINUE_SEARCH);
     1094        }
    9711095
    9721096  case XCPT_PROCESS_TERMINATE:
    9731097  case XCPT_ASYNC_PROCESS_TERMINATE:
    974         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    975         SetExceptionChain((ULONG)-1);
    976         return (XCPT_CONTINUE_SEARCH);
     1098        dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1099        SetExceptionChain((ULONG)-1);
     1100        return (XCPT_CONTINUE_SEARCH);
    9771101
    9781102  case XCPT_ACCESS_VIOLATION:
    979   {     
     1103  {
    9801104   Win32MemMap *map;
    9811105   BOOL  fWriteAccess = FALSE;
    9821106   ULONG offset, accessflag;
    9831107
    984         if(pERepRec->ExceptionInfo[1] == 0 && pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN) {
    985                 goto continueFail;
    986         }
    987         switch(pERepRec->ExceptionInfo[0]) {
    988         case XCPT_READ_ACCESS:
    989                 accessflag = MEMMAP_ACCESS_READ;
    990                 break;
    991         case XCPT_WRITE_ACCESS:
    992                 accessflag = MEMMAP_ACCESS_WRITE;
    993                 fWriteAccess = TRUE;
    994                 break;
    995         case XCPT_EXECUTE_ACCESS:
    996                 accessflag = MEMMAP_ACCESS_EXECUTE;
    997                 break;
    998         default:
    999                 goto continueFail;
    1000         }
    1001 
    1002         map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
    1003         if(map == NULL) {
    1004                 goto continueFail;
    1005         }
    1006         if(map->commitPage(offset, fWriteAccess) == TRUE)
    1007                 return (XCPT_CONTINUE_EXECUTION);
    1008 
    1009         //no break;
     1108        if(pERepRec->ExceptionInfo[1] == 0 && pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN) {
     1109                goto continueFail;
     1110        }
     1111        switch(pERepRec->ExceptionInfo[0]) {
     1112        case XCPT_READ_ACCESS:
     1113                accessflag = MEMMAP_ACCESS_READ;
     1114                break;
     1115        case XCPT_WRITE_ACCESS:
     1116                accessflag = MEMMAP_ACCESS_WRITE;
     1117                fWriteAccess = TRUE;
     1118                break;
     1119        case XCPT_EXECUTE_ACCESS:
     1120                accessflag = MEMMAP_ACCESS_EXECUTE;
     1121                break;
     1122        default:
     1123                goto continueFail;
     1124        }
     1125
     1126        map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
     1127        if(map == NULL) {
     1128                goto continueFail;
     1129        }
     1130        if(map->commitPage(offset, fWriteAccess) == TRUE)
     1131                return (XCPT_CONTINUE_EXECUTION);
     1132
     1133        //no break;
    10101134  }
    10111135continueFail:
     
    10141138#ifdef DEBUGSTACK
    10151139  if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
    1016         ULONG *stackptr;
    1017         APIRET rc;
    1018         int    i;
    1019         ULONG  ulOffset, ulModule, ulObject;
    1020         CHAR   szModule[CCHMAXPATH];
    1021 
    1022         stackptr = (ULONG *)pCtxRec->ctx_RegEsp;
    1023         dprintf(("Stack DUMP:"));
    1024         for(i=0;i<16;i++) {
    1025                 rc = DosQueryModFromEIP(&ulModule,
    1026                                         &ulObject,
     1140        ULONG *stackptr;
     1141        APIRET rc;
     1142        int    i;
     1143        ULONG  ulOffset, ulModule, ulObject;
     1144        CHAR   szModule[CCHMAXPATH];
     1145
     1146        stackptr = (ULONG *)pCtxRec->ctx_RegEsp;
     1147        dprintf(("Stack DUMP:"));
     1148        for(i=0;i<16;i++) {
     1149                rc = DosQueryModFromEIP(&ulModule,
     1150                                        &ulObject,
    10271151                                        sizeof(szModule),
    10281152                                        szModule,
     
    10301154                                        (ULONG)*stackptr);
    10311155
    1032                 if (rc == NO_ERROR)
    1033                         dprintf(("0x%8x: 0x%8x %s (#%u), obj #%u:%08x", stackptr, *stackptr, szModule, ulModule, ulObject, ulOffset));
    1034                 else    dprintf(("0x%8x: 0x%8x", stackptr, *stackptr));
    1035                 stackptr++;
    1036         }
    1037         dprintf(("Stack DUMP END"));
     1156                if (rc == NO_ERROR)
     1157                        dprintf(("0x%8x: 0x%8x %s (#%u), obj #%u:%08x", stackptr, *stackptr, szModule, ulModule, ulObject, ulOffset));
     1158                else    dprintf(("0x%8x: 0x%8x", stackptr, *stackptr));
     1159                stackptr++;
     1160        }
     1161        dprintf(("Stack DUMP END"));
    10381162  }
    10391163#endif
     
    10521176CrashAndBurn:
    10531177#ifdef DEBUG
    1054         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    1055         if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
    1056                 dbgPrintStack(pERepRec, pERegRec, pCtxRec, p);
    1057         }
     1178        dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1179        if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
     1180                dbgPrintStack(pERepRec, pERegRec, pCtxRec, p);
     1181        }
    10581182#endif
    1059         if(fIsOS2Image == FALSE)  //Only for real win32 apps
    1060         {
    1061                 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == TRUE)
    1062                 {
    1063                         return (XCPT_CONTINUE_EXECUTION);
    1064                 }
    1065         }
    1066         else    return XCPT_CONTINUE_SEARCH; //pass on to OS/2 RTL or app exception handler
    1067 
    1068         dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
    1069         pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
    1070         pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
    1071         pCtxRec->ctx_RegEax = pERepRec->ExceptionNum;
    1072         pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip;
    1073         return (XCPT_CONTINUE_EXECUTION);
     1183        if(fIsOS2Image == FALSE)  //Only for real win32 apps
     1184        {
     1185                if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == TRUE)
     1186                {
     1187                        return (XCPT_CONTINUE_EXECUTION);
     1188                }
     1189        }
     1190        else    return XCPT_CONTINUE_SEARCH; //pass on to OS/2 RTL or app exception handler
     1191
     1192        dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
     1193        pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
     1194        pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
     1195        pCtxRec->ctx_RegEax = pERepRec->ExceptionNum;
     1196        pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip;
     1197        return (XCPT_CONTINUE_EXECUTION);
    10741198
    10751199  //@@@PH: growing thread stacks might need special treatment
    10761200  case XCPT_GUARD_PAGE_VIOLATION:
    1077     dprintf(("KERNEL32: OS2ExceptionHandler: trying to grow stack (continue)\n"));
     1201    dprintf(("KERNEL32: OS2ExceptionHandler: trying to grow stack (continue search)"));
    10781202    return (XCPT_CONTINUE_SEARCH);
    10791203
     
    10811205      if(pERepRec->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC)          /* resolve signal information */
    10821206      {
    1083         SetExceptionChain((ULONG)-1);
    1084         return (XCPT_CONTINUE_SEARCH);
     1207        SetExceptionChain((ULONG)-1);
     1208        return (XCPT_CONTINUE_SEARCH);
    10851209      }
    10861210      goto CrashAndBurn;
    10871211
    10881212  default: //non-continuable exceptions
    1089         dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1213        dprintfException(pERepRec, pERegRec, pCtxRec, p);
    10901214        return (XCPT_CONTINUE_SEARCH);
    10911215  }
     
    11291253  dprintf(("Exception chain list:"));
    11301254  while(pExceptRec != 0 && (ULONG)pExceptRec != -1) {
    1131         dprintf(("record %x", pExceptRec));
    1132         pExceptRec = pExceptRec->prev_structure;
     1255        dprintf(("record %x", pExceptRec));
     1256        pExceptRec = pExceptRec->prev_structure;
    11331257  }
    11341258  SetFS(sel);
    11351259}
     1260
     1261void PrintWin32ExceptionChain(PWINEXCEPTION_FRAME pframe)
     1262{
     1263  dprintf(("Win32 exception chain:"));
     1264  while ((pframe != NULL) && ((ULONG)pframe != 0xFFFFFFFF)) {
     1265        dprintf(("Record at %08X, Prev at %08X, handler at %08X", pframe, pframe->Prev, pframe->Handler));
     1266        if (pframe == pframe->Prev) {
     1267            dprintf(("Chain corrupted! Record at %08X pointing to itself!", pframe));
     1268            break;
     1269        }
     1270        pframe = pframe->Prev;
     1271  }
     1272}
     1273
    11361274#endif
    11371275
     
    11731311
    11741312    if(sel == 0x150b) {
    1175         SetFS(sel);
    1176         return FALSE;
     1313        SetFS(sel);
     1314        return FALSE;
    11771315    }
    11781316    pExceptRec = (PEXCEPTIONREGISTRATIONRECORD)QueryExceptionChain();
    11791317    if(pExceptRec->ExceptionHandler != OS2ExceptionHandler) {
    1180         SetFS(sel);
    1181         return FALSE;
     1318        SetFS(sel);
     1319        return FALSE;
    11821320    }
    11831321    SetFS(sel);
Note: See TracChangeset for help on using the changeset viewer.