Ignore:
Timestamp:
Jul 3, 2001, 3:17:42 PM (24 years ago)
Author:
bird
Message:

Improoved Unhandled exception message.

File:
1 edited

Legend:

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

    r5905 r6146  
    1 /* $Id: exceptions.cpp,v 1.53 2001-06-04 21:18:39 sandervl Exp $ */
     1/* $Id: exceptions.cpp,v 1.54 2001-07-03 13:17:42 bird Exp $ */
    22
    33/*
     
    6565#include "oslibexcept.h"
    6666#include "exceptstackdump.h"
     67
     68#include "WinImageBase.h"
     69#include "WinDllBase.h"
     70#include "WinExeBase.h"
    6771
    6872#define DBG_LOCALLOG    DBG_exceptions
     
    524528LONG WIN32API UnhandledExceptionFilter(PWINEXCEPTION_POINTERS lpexpExceptionInfo)
    525529{
    526   char  message[72];
    527   DWORD rc;
    528 
     530  char      szModName[16];
     531  char      message[128];
     532  ULONG     iObj;
     533  ULONG     offObj;
     534  HMODULE   hmod;
     535  DWORD     rc;
     536
     537#if 0 //not in use...
    529538  // @@@PH: experimental change to have more control over exception handling
    530539#pragma pack(4)
     
    550559                                      {"~terminate process",  103, BS_PUSHBUTTON | BS_TEXT | BS_AUTOSIZE} }
    551560                                  };
     561#endif
    552562
    553563  dprintf(("KERNEL32: Default UnhandledExceptionFilter, CurrentErrorMode=%X", CurrentErrorMode));
     
    563573  }
    564574
    565   sprintf(message,
    566           "Unhandled exception 0x%08lx at address 0x%08lx.",
    567           lpexpExceptionInfo->ExceptionRecord->ExceptionCode,
    568           lpexpExceptionInfo->ExceptionRecord->ExceptionAddress);
     575
     576  if (DosQueryModFromEIP(&hmod, &iObj, sizeof(szModName), szModName, &offObj, (ULONG)lpexpExceptionInfo->ExceptionRecord->ExceptionAddress))
     577      sprintf(message,
     578              "Unhandled exception 0x%08lx at address 0x%08lx. (DQMFEIP rc=%d)",
     579              lpexpExceptionInfo->ExceptionRecord->ExceptionCode,
     580              lpexpExceptionInfo->ExceptionRecord->ExceptionAddress);
     581  else
     582  {
     583      if (iObj == -1)
     584      {   /* fault in DosAllocMem allocated memory, hence PE loader.. */
     585          Win32ImageBase * pMod;
     586          if (WinExe && WinExe->insideModule((ULONG)lpexpExceptionInfo->ExceptionRecord->ExceptionAddress))
     587              pMod = WinExe;
     588          else
     589              pMod = Win32DllBase::findModuleByAddr((ULONG)lpexpExceptionInfo->ExceptionRecord->ExceptionAddress);
     590          if (pMod != NULL)
     591          {
     592              szModName[0] = '\0';
     593              strncat(szModName, pMod->getModuleName(), sizeof(szModName) - 1);
     594          }
     595      }
     596      sprintf(message,
     597              "Unhandled exception 0x%08lx at address 0x%08lx.\r"
     598              "Mod: %s obj: 0x%2lx off:0x%08lx",
     599              lpexpExceptionInfo->ExceptionRecord->ExceptionCode,
     600              lpexpExceptionInfo->ExceptionRecord->ExceptionAddress,
     601              szModName, iObj, offObj);
     602  }
     603
    569604/*
    570605  rc = WinMessageBox2(HWND_DESKTOP,
Note: See TracChangeset for help on using the changeset viewer.