1 #ifndef _WHEATYEXCEPTIONREPORT_
2 #define _WHEATYEXCEPTIONREPORT_
7 # define countof(array) (sizeof(array) / sizeof(array[0]))
10 # define countof _countof
11 #endif // _MSC_VER < 1400
13 enum BasicType
// Stolen from CVCONST.H in the DIA 2.0 SDK
35 const char* const rgBaseType
[] =
37 " <user defined> ", // btNoType = 0,
38 " void ", // btVoid = 1,
39 " char* ", // btChar = 2,
40 " wchar_t* ", // btWChar = 3,
43 " int ", // btInt = 6,
44 " unsigned int ", // btUInt = 7,
45 " float ", // btFloat = 8,
46 " <BCD> ", // btBCD = 9,
47 " bool ", // btBool = 10,
50 " long ", // btLong = 13,
51 " unsigned long ", // btULong = 14,
61 " unsigned __int128 ",
62 " <currency> ", // btCurrency = 25,
63 " <date> ", // btDate = 26,
64 " VARIANT ", // btVariant = 27,
65 " <complex> ", // btComplex = 28,
66 " <bit> ", // btBit = 29,
67 " BSTR ", // btBSTR = 30,
68 " HRESULT " // btHresult = 31
71 class WheatyExceptionReport
75 WheatyExceptionReport( );
76 ~WheatyExceptionReport( );
78 // entry point where control comes on an unhandled exception
79 static LONG WINAPI
WheatyUnhandledExceptionFilter(
80 PEXCEPTION_POINTERS pExceptionInfo
);
82 static void printTracesForAllThreads();
84 // where report info is extracted and generated
85 static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo
);
86 static void PrintSystemInfo();
87 static BOOL
_GetWindowsVersion(TCHAR
* szVersion
, DWORD cntMax
);
88 static BOOL
_GetProcessorName(TCHAR
* sProcessorName
, DWORD maxcount
);
91 static LPTSTR
GetExceptionString( DWORD dwCode
);
92 static BOOL
GetLogicalAddress( PVOID addr
, PTSTR szModule
, DWORD len
,
93 DWORD
& section
, DWORD_PTR
& offset
);
95 static void WriteStackDetails( PCONTEXT pContext
, bool bWriteVariables
, HANDLE pThreadHandle
);
97 static BOOL CALLBACK
EnumerateSymbolsCallback(PSYMBOL_INFO
,ULONG
, PVOID
);
99 static bool FormatSymbolValue( PSYMBOL_INFO
, STACKFRAME
*, char * pszBuffer
, unsigned cbBuffer
);
101 static char * DumpTypeIndex( char *, DWORD64
, DWORD
, unsigned, DWORD_PTR
, bool & , char*);
103 static char * FormatOutputValue( char * pszCurrBuffer
, BasicType basicType
, DWORD64 length
, PVOID pAddress
);
105 static BasicType
GetBasicType( DWORD typeIndex
, DWORD64 modBase
);
107 static int __cdecl
_tprintf(const TCHAR
* format
, ...);
109 // Variables used by the class
110 static TCHAR m_szLogFileName
[MAX_PATH
];
111 static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter
;
112 static HANDLE m_hReportFile
;
113 static HANDLE m_hProcess
;
116 extern WheatyExceptionReport g_WheatyExceptionReport
; // global instance of class
117 #endif //WheatyExceptionReport