Ignore:
Timestamp:
Jul 7, 2009, 7:40:22 PM (16 years ago)
Author:
vladest
Message:

Added functionality, required for Flash10 to kernel32

File:
1 edited

Legend:

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

    r21302 r21329  
    352352
    353353  // walk the exception chain
    354   while( (pFrame != NULL) && (pFrame != ((void *)0xFFFFFFFF)) )
     354  while( (pFrame != NULL) && ((ULONG)((ULONG)pFrame & 0xFFFFF000) != 0xFFFFF000) )
    355355  {
    356356        dprintf(("KERNEL32: RtlDispatchException - pframe=%08X, pframe->Prev=%08X", pFrame, pFrame->Prev));
     
    492492  PrintWin32ExceptionChain(frame);
    493493
    494   while ((frame != (PWINEXCEPTION_FRAME)0xffffffff) && (frame != pEndFrame))
     494  while (((ULONG)((ULONG)frame & 0xFFFFF000) != 0xFFFFF000) && (frame != pEndFrame))
    495495  {
    496496        /* Check frame address */
     
    711711//               any local buffers also can be made static to save
    712712//               stack space and possibly avoid out of stack exception.
    713     if(pERepRec->ExceptionNum == XCPT_GUARD_PAGE_VIOLATION)   
     713    if(pERepRec->ExceptionNum == XCPT_GUARD_PAGE_VIOLATION)
    714714    {
    715715        strcpy(szTrapDump, "Guard Page Violation");
    716716        return;
    717717    }
    718    
     718
    719719    PSZ    pszExceptionName = "<unknown>";        /* points to name/type excpt */
    720720    APIRET rc               = XCPT_CONTINUE_SEARCH;        /* excpt-dep.  code */
     
    963963        static char szSYMInfo[260];
    964964        static char Name[260];
    965        
     965
    966966        DosQueryModuleName(ulModule, sizeof(Name), Name);
    967967
     
    12941294
    12951295            map = Win32MemMapNotify::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
    1296             if(!map) 
     1296            if(!map)
    12971297                goto continueFail;
    12981298
     
    13091309    }
    13101310continueFail:
     1311
     1312    /*
     1313     * vladest: OK, try to implement write AUTOCOMMIT
     1314     * last chance after MMAP commit is failed
     1315     */
     1316    if (XCPT_ACCESS_VIOLATION == pERepRec->ExceptionNum &&
     1317        (/*pERepRec->ExceptionInfo[0] == XCPT_READ_ACCESS ||*/
     1318         pERepRec->ExceptionInfo[0] == XCPT_WRITE_ACCESS) &&
     1319        pERepRec->ExceptionInfo[1] != XCPT_DATA_UNKNOWN)
     1320    {
     1321        ULONG offset, accessflag;
     1322
     1323        DosQueryMem((PVOID) pERepRec->ExceptionInfo[1],
     1324                    &offset, &accessflag);
     1325        dprintf(("KERNEL32: OS2ExceptionHandler: failed address info 0x%X size 0x%X. flag %X\n",
     1326                 pERepRec->ExceptionInfo[1], offset, accessflag));
     1327        /* check for valid address */
     1328        if (!pERepRec->ExceptionInfo[1] ||
     1329            pERepRec->ExceptionInfo[1] == 0xAAAAAAAA ||
     1330            !offset || offset == 0xAAAAAAAA)
     1331            goto CrashAndBurn;
     1332        /* memory committed, but no write access */
     1333        if (accessflag & PAG_GUARD)
     1334            accessflag &=~PAG_GUARD;
     1335
     1336        DosSetMem((PVOID) pERepRec->ExceptionInfo[1], offset,
     1337                  accessflag | PAG_WRITE | PAG_COMMIT);
     1338        dprintf(("KERNEL32: OS2ExceptionHandler: commiting 0x%X size 0x%X\n",
     1339                 pERepRec->ExceptionInfo[1], offset));
     1340        goto continueexecution;
     1341    }
     1342
    13111343
    13121344////#define DEBUGSTACK
     
    13441376        USHORT *eip = (USHORT *)pCtxRec->ctx_RegEip;
    13451377
    1346         if(teb && eip && *eip == SETTHREADCONTEXT_INVALID_LOCKOPCODE) 
     1378        if(teb && eip && *eip == SETTHREADCONTEXT_INVALID_LOCKOPCODE)
    13471379        {
    13481380            //Is this a pending SetThreadContext exception?
    13491381            //(see detailed description in the HMDeviceThreadClass::SetThreadContext method)
    1350             if(teb->o.odin.context.ContextFlags) 
     1382            if(teb->o.odin.context.ContextFlags)
    13511383            {
    13521384                dprintfException(pERepRec, pERegRec, pCtxRec, p);
     
    14881520        //Make sure we detect a stack overflow condition before the system does
    14891521        if(!fIsOS2Image &&
    1490             pERepRec->ExceptionInfo[1]  >= stackbottom && 
     1522            pERepRec->ExceptionInfo[1]  >= stackbottom &&
    14911523            pERepRec->ExceptionInfo[1]  <  stacktop
    1492            ) 
     1524           )
    14931525        {//this is a guard page exception for the thread stack
    14941526            APIRET rc;
    14951527            ULONG ulAddress, cbSize, ulMemFlags;
    1496  
     1528
    14971529            //round down to page boundary
    14981530            ulAddress = pERepRec->ExceptionInfo[1] & ~0xFFF;
     
    15061538#endif
    15071539
    1508             if(ulAddress == stackbottom + PAGE_SIZE) 
     1540            if(ulAddress == stackbottom + PAGE_SIZE)
    15091541            {//we don't have any stack left, throw an XCPT_UNABLE_TO_GROW_STACK
    15101542             //exception
     
    15501582        if(ret == TRUE)
    15511583            goto continueexecution;
    1552             }           
     1584            }
    15531585        }
    15541586
     
    15651597//#ifdef DEBUG
    15661598//        dprintfException(pERepRec, pERegRec, pCtxRec, p);
    1567 //#endif     
     1599//#endif
    15681600        goto continuesearch;
    15691601    }
     
    16531685  PEXCEPTIONREGISTRATIONRECORD pExceptRec = (PEXCEPTIONREGISTRATIONRECORD)QueryExceptionChain();
    16541686
    1655   while(pExceptRec != 0 && (ULONG)pExceptRec != -1) 
     1687  while(pExceptRec != 0 && (ULONG)pExceptRec != -1)
    16561688  {
    1657         if(pExceptRec->ExceptionHandler == OS2ExceptionHandler) 
     1689        if(pExceptRec->ExceptionHandler == OS2ExceptionHandler)
    16581690        {
    16591691            fFound = TRUE;
     
    16621694        pExceptRec = pExceptRec->prev_structure;
    16631695  }
    1664   if(!fFound) 
     1696  if(!fFound)
    16651697  {
    16661698      OS2SetExceptionHandler(pExceptionRegRec);
     
    16701702//*****************************************************************************
    16711703// Remove exception handler if it was registered previously
    1672 // 
     1704//
    16731705//*****************************************************************************
    16741706void WIN32API ODIN_UnsetExceptionHandler(void *pExceptionRegRec)
     
    16781710  BOOL   fFound = FALSE;
    16791711
    1680   while(pExceptRec != 0 && (ULONG)pExceptRec != -1) 
     1712  while(pExceptRec != 0 && (ULONG)pExceptRec != -1)
    16811713  {
    1682         if(pExceptRec == pExceptionRegRec) 
     1714        if(pExceptRec == pExceptionRegRec)
    16831715        {
    16841716            fFound = TRUE;
     
    16911723  pExceptRec = (PEXCEPTIONREGISTRATIONRECORD)QueryExceptionChain();
    16921724
    1693   if(fFound && pExceptRec != (PEXCEPTIONREGISTRATIONRECORD)pExceptionRegRec) 
     1725  if(fFound && pExceptRec != (PEXCEPTIONREGISTRATIONRECORD)pExceptionRegRec)
    16941726  {
    16951727      dprintf(("ERROR: ODIN_UnsetExceptionHandler: INSIDE!!!: exc rec %p, head %p\n", pExceptionRegRec, pExceptRec));
Note: See TracChangeset for help on using the changeset viewer.