Ignore:
Timestamp:
Aug 27, 1999, 6:51:01 PM (26 years ago)
Author:
sandervl
Message:

Implemented multiple views of memory mapped files + some bugfixes to PE loader code

File:
1 edited

Legend:

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

    r710 r712  
    1 /* $Id: exceptions.cpp,v 1.16 1999-08-27 10:44:21 phaller Exp $ */
     1/* $Id: exceptions.cpp,v 1.17 1999-08-27 16:50:59 sandervl Exp $ */
    22
    33/*
     
    868868                                   PVOID                        p)
    869869{
    870   /*********************************
    871    * Internally handled exceptions *
    872    *********************************/
    873 
    874   /* Access violation at a known location */
    875   if (pERepRec->ExceptionNum == XCPT_ACCESS_VIOLATION)
    876   {
    877     Win32MemMap *map;
    878     BOOL fWriteAccess = FALSE;
    879 
    880     if(pERepRec->ExceptionInfo[1] == 0 &&
    881        pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN)
    882       goto continueFail;
    883 
    884     map = Win32MemMap::findMap(pERepRec->ExceptionInfo[1]);
    885      if(map == NULL)
    886       goto continueFail;
    887 
    888     switch(pERepRec->ExceptionInfo[0])
    889     {
    890       case XCPT_READ_ACCESS:
    891         if(map->hasReadAccess() == FALSE)
    892           goto continueFail;
    893       break;
    894 
    895       case XCPT_WRITE_ACCESS:
    896         if(map->hasWriteAccess() == FALSE)
    897            goto continueFail;
    898         fWriteAccess = TRUE;
    899         break;
    900 
    901       case XCPT_EXECUTE_ACCESS:
    902         if(map->hasExecuteAccess() == FALSE)
    903           goto continueFail;
    904         break;
    905 
    906      default:
    907        goto continueFail;
    908    }
    909 
    910    //Might want to consider mapping more than one page if access is at
    911    //a high offset in the page
    912    //@@@PH: mapping 16k or 32k might be significally faster in terms of transfer speed
    913    if(map->commitPage((LPVOID)pERepRec->ExceptionInfo[1], 1, fWriteAccess) == TRUE)
    914       return (XCPT_CONTINUE_EXECUTION);
    915 
    916    //no break;
    917   }
    918 continueFail:
    919 
    920 
    921   /************************
    922    * Pass-thru exceptions *
    923    ************************/
    924 
    925870  //  pERegRec->prev_structure = 0;
    926871  dprintfException(pERepRec, pERegRec, pCtxRec, p);
     
    929874  switch(pERepRec->ExceptionNum)
    930875  {
    931     case XCPT_FLOAT_DENORMAL_OPERAND:
    932     case XCPT_FLOAT_DIVIDE_BY_ZERO:
    933     case XCPT_FLOAT_INEXACT_RESULT:
    934     case XCPT_FLOAT_INVALID_OPERATION:
    935     case XCPT_FLOAT_OVERFLOW:
    936     case XCPT_FLOAT_STACK_CHECK:
    937     case XCPT_FLOAT_UNDERFLOW:
    938       dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception, fix and continue\n"));
     876  case XCPT_FLOAT_DENORMAL_OPERAND:
     877  case XCPT_FLOAT_DIVIDE_BY_ZERO:
     878  case XCPT_FLOAT_INEXACT_RESULT:
     879  case XCPT_FLOAT_INVALID_OPERATION:
     880  case XCPT_FLOAT_OVERFLOW:
     881  case XCPT_FLOAT_STACK_CHECK:
     882  case XCPT_FLOAT_UNDERFLOW:
     883        dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception, fix and continue\n"));
    939884        pCtxRec->ctx_env[0] |= 0x1F;
    940885        pCtxRec->ctx_stack[0].losig = 0;
    941886        pCtxRec->ctx_stack[0].hisig = 0;
    942887        pCtxRec->ctx_stack[0].signexp = 0;
    943       return (XCPT_CONTINUE_EXECUTION);
    944 
    945     case XCPT_PROCESS_TERMINATE:
    946     case XCPT_ASYNC_PROCESS_TERMINATE:
    947       SetExceptionChain((ULONG)0);
    948       return (XCPT_CONTINUE_SEARCH);
    949 
    950     case XCPT_ACCESS_VIOLATION:
    951     case XCPT_BREAKPOINT:
    952     case XCPT_ARRAY_BOUNDS_EXCEEDED:
    953     case XCPT_DATATYPE_MISALIGNMENT:
    954     case XCPT_ILLEGAL_INSTRUCTION:
    955     case XCPT_PRIVILEGED_INSTRUCTION:
    956     case XCPT_INVALID_LOCK_SEQUENCE:
    957     case XCPT_INTEGER_DIVIDE_BY_ZERO:
    958     case XCPT_INTEGER_OVERFLOW:
    959     case XCPT_SINGLE_STEP:
    960     case XCPT_GUARD_PAGE_VIOLATION:
    961     case XCPT_UNABLE_TO_GROW_STACK:
    962     case XCPT_IN_PAGE_ERROR:
    963     case XCPT_SIGNAL:
    964       dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
    965       pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
    966       pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
    967       pCtxRec->ctx_RegEax = pERepRec->ExceptionNum;
    968       pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip;
    969       return (XCPT_CONTINUE_EXECUTION);
    970 
    971     default: //non-continuable exceptions
     888
     889        return (XCPT_CONTINUE_EXECUTION);
     890
     891  case XCPT_PROCESS_TERMINATE:
     892  case XCPT_ASYNC_PROCESS_TERMINATE:
     893        SetExceptionChain((ULONG)0);
     894        return (XCPT_CONTINUE_SEARCH);
     895
     896  case XCPT_ACCESS_VIOLATION:
     897  {     
     898   Win32MemMap *map;
     899   BOOL  fWriteAccess = FALSE;
     900   ULONG offset, accessflag;
     901
     902        if(pERepRec->ExceptionInfo[1] == 0 && pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN) {
     903                goto continueFail;
     904        }
     905        switch(pERepRec->ExceptionInfo[0]) {
     906        case XCPT_READ_ACCESS:
     907                accessflag = MEMMAP_ACCESS_READ;
     908                break;
     909        case XCPT_WRITE_ACCESS:
     910                accessflag = MEMMAP_ACCESS_WRITE;
     911                fWriteAccess = TRUE;
     912                break;
     913        case XCPT_EXECUTE_ACCESS:
     914                accessflag = MEMMAP_ACCESS_EXECUTE;
     915                break;
     916        default:
     917                goto continueFail;
     918        }
     919
     920        map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
     921        if(map == NULL) {
     922                goto continueFail;
     923        }
     924        if(map->commitPage(offset, fWriteAccess) == TRUE)
     925                return (XCPT_CONTINUE_EXECUTION);
     926
     927        //no break;
     928  }
     929continueFail:
     930
     931  case XCPT_BREAKPOINT:
     932  case XCPT_ARRAY_BOUNDS_EXCEEDED:
     933  case XCPT_DATATYPE_MISALIGNMENT:
     934  case XCPT_ILLEGAL_INSTRUCTION:
     935  case XCPT_PRIVILEGED_INSTRUCTION:
     936  case XCPT_INVALID_LOCK_SEQUENCE:
     937  case XCPT_INTEGER_DIVIDE_BY_ZERO:
     938  case XCPT_INTEGER_OVERFLOW:
     939  case XCPT_SINGLE_STEP:
     940  case XCPT_GUARD_PAGE_VIOLATION:
     941  case XCPT_UNABLE_TO_GROW_STACK:
     942  case XCPT_IN_PAGE_ERROR:
     943  case XCPT_SIGNAL:
     944        dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
     945        pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
     946        pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
     947        pCtxRec->ctx_RegEax = pERepRec->ExceptionNum;
     948        pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip;
     949        return (XCPT_CONTINUE_EXECUTION);
     950
     951  default: //non-continuable exceptions
    972952        return (XCPT_CONTINUE_SEARCH);
    973953  }
     
    1019999 USHORT sel = GetFS();
    10201000
    1021     SetExceptionChain(val);
     1001    SetExceptionChain(val);   
    10221002    SetFS(sel);
    10231003}
Note: See TracChangeset for help on using the changeset viewer.