Ignore:
Timestamp:
Mar 6, 2003, 11:22:27 AM (22 years ago)
Author:
sandervl
Message:

KSO: logging changes; fast PID & TID retrieval; added functions to set/clear the odin environment (fs, exception handler)

File:
1 edited

Legend:

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

    r9893 r9910  
    1 /* $Id: exceptions.cpp,v 1.71 2003-03-03 16:41:03 sandervl Exp $ */
     1/* $Id: exceptions.cpp,v 1.72 2003-03-06 10:22:26 sandervl Exp $ */
    22
    33/*
     
    610610                szModName, iObj, offObj);
    611611    }
    612    
     612
    613613/*  This is very dangerous. Can hang PM.
    614614    rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, message, "Application Error",
     
    715715    char   szLineException[128];
    716716    char   szLineExceptionType[128];
    717    
     717
    718718    szLineException[0]  = 0;                                              /* initialize */
    719719    szLineExceptionType[0] = 0;                                              /* initialize */
     
    813813    case XCPT_DATATYPE_MISALIGNMENT:
    814814        strcpy(szLineException, "Datatype Misalignment");
    815         sprintf(szLineExceptionType, "R/W %08x alignment %08x at %08x.", pERepRec->ExceptionInfo[0], 
     815        sprintf(szLineExceptionType, "R/W %08x alignment %08x at %08x.", pERepRec->ExceptionInfo[0],
    816816                pERepRec->ExceptionInfo[1], pERepRec->ExceptionInfo[2]);
    817817        break;
     
    914914    }
    915915
    916     sprintf(szTrapDump, "---[Exception Information]------------\n   %s", szLineException);
    917 
    918     strcat(szTrapDump, " (");
     916    sprintf(szTrapDump, "---[Exception Information]------------\n   %s (", szLineException);
    919917
    920918    if (fExcptSoftware == TRUE)            /* software or hardware generated ? */
     
    935933    strcat(szTrapDump, ")\n");                                    /* add trailing brace */
    936934
     935    if (szLineExceptionType[0])
     936        sprintf(szTrapDump + strlen(szTrapDump), "   %s\n", szLineExceptionType);
    937937
    938938    rc = DosQueryModFromEIP(&ulModule, &ulObject, sizeof(szModule),
     
    947947        strcat(szTrapDump, szLineException);
    948948    }
    949     else 
     949    else
    950950    {   /* fault in DosAllocMem allocated memory, hence PE loader.. */
    951951        Win32ImageBase * pMod;
     
    10071007
    10081008        sprintf(szLineException, "   Env[0]=%08x Env[1]=%08x Env[2]=%08x Env[3]=%08x\n",
    1009                  pCtxRec->ctx_env[0], pCtxRec->ctx_env[1], 
     1009                 pCtxRec->ctx_env[0], pCtxRec->ctx_env[1],
    10101010                 pCtxRec->ctx_env[2], pCtxRec->ctx_env[3]);
    10111011        strcat(szTrapDump, szLineException);
     
    10531053//Override filename of exception log (expects full path)
    10541054//*****************************************************************************
    1055 void WIN32API SetCustomExceptionLog(LPSTR lpszLogName) 
     1055void WIN32API SetCustomExceptionLog(LPSTR lpszLogName)
    10561056{
    10571057    strcpy(szExceptionLogFileName, lpszLogName);
     
    10591059//*****************************************************************************
    10601060//*****************************************************************************
    1061 void WIN32API SetExceptionLogging(BOOL fEnable) 
     1061void WIN32API SetExceptionLogging(BOOL fEnable)
    10621062{
    10631063    fExceptionLoggging = fEnable;
     
    10881088                 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
    10891089                 0L);                            /* No extended attribute */
    1090    
     1090
    10911091    if(rc == NO_ERROR) {
    10921092        DosSetFilePtr(hFile, 0, FILE_END, &ulBytesWritten);
     
    10951095
    10961096            lpszExeName = WinExe->getModuleName();
    1097            
     1097
    10981098            if(lpszExeName) {
    10991099                DosWrite(hFile, "\n", 2, &ulBytesWritten);
     
    13401340
    13411341        dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
    1342        
     1342
    13431343        pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
    13441344        pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
     
    13511351    {
    13521352        //NOTE:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1353         //Don't print anything here -> fatal hang if exception occurred 
     1353        //Don't print anything here -> fatal hang if exception occurred
    13541354        //inside fprintf
    13551355        //NOTE:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    13561356
     1357        Win32MemMap *map;
     1358        BOOL  fWriteAccess = FALSE, ret;
     1359        ULONG offset, accessflag;
     1360
     1361        switch(pERepRec->ExceptionInfo[0]) {
     1362        case XCPT_READ_ACCESS:
     1363                accessflag = MEMMAP_ACCESS_READ;
     1364                break;
     1365        case XCPT_WRITE_ACCESS:
     1366                accessflag = MEMMAP_ACCESS_WRITE;
     1367                fWriteAccess = TRUE;
     1368                break;
     1369        default:
     1370                goto continueGuardException;
     1371        }
     1372
     1373        map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
     1374        if(map == NULL) {
     1375            goto continueGuardException;
     1376        }
     1377        ret = map->commitGuardPage(pERepRec->ExceptionInfo[1], offset, fWriteAccess);
     1378        map->Release();
     1379        if(ret == TRUE)
     1380            goto continueexecution;
     1381
     1382continueGuardException:
    13571383        goto continuesearch;
    13581384    }
Note: See TracChangeset for help on using the changeset viewer.