Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
WheatyExceptionReport.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef _WHEATYEXCEPTIONREPORT_
7#define _WHEATYEXCEPTIONREPORT_
8
9#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
10
11#include <dbghelp.h>
12
13#if _MSC_VER < 1400
14# define countof(array) (sizeof(array) / sizeof(array[0]))
15#else
16# include <stdlib.h>
17# define countof _countof
18#endif // _MSC_VER < 1400
19
20enum BasicType // Stolen from CVCONST.H in the DIA 2.0 SDK
21{
23 btVoid = 1,
24 btChar = 2,
26 btInt = 6,
27 btUInt = 7,
29 btBCD = 9,
30 btBool = 10,
31 btLong = 13,
32 btULong = 14,
34 btDate = 26,
37 btBit = 29,
38 btBSTR = 30,
40};
41
42const char* const rgBaseType[] =
43{
44 " <user defined> ", // btNoType = 0,
45 " void ", // btVoid = 1,
46 " char* ", // btChar = 2,
47 " wchar_t* ", // btWChar = 3,
48 " signed char ",
49 " unsigned char ",
50 " int ", // btInt = 6,
51 " unsigned int ", // btUInt = 7,
52 " float ", // btFloat = 8,
53 " <BCD> ", // btBCD = 9,
54 " bool ", // btBool = 10,
55 " short ",
56 " unsigned short ",
57 " long ", // btLong = 13,
58 " unsigned long ", // btULong = 14,
59 " __int8 ",
60 " __int16 ",
61 " __int32 ",
62 " __int64 ",
63 " __int128 ",
64 " unsigned __int8 ",
65 " unsigned __int16 ",
66 " unsigned __int32 ",
67 " unsigned __int64 ",
68 " unsigned __int128 ",
69 " <currency> ", // btCurrency = 25,
70 " <date> ", // btDate = 26,
71 " VARIANT ", // btVariant = 27,
72 " <complex> ", // btComplex = 28,
73 " <bit> ", // btBit = 29,
74 " BSTR ", // btBSTR = 30,
75 " HRESULT " // btHresult = 31
76};
77
79{
80public:
81
84
85 // entry point where control comes on an unhandled exception
87 PEXCEPTION_POINTERS pExceptionInfo);
88
90private:
91 // where report info is extracted and generated
92 static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo);
93 static void PrintSystemInfo();
94 static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
95 static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
96
97 // Helper functions
98 static LPTSTR GetExceptionString(DWORD dwCode);
99 static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,
100 DWORD& section, DWORD_PTR& offset);
101
102 static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
103
104 static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID);
105
106 static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer);
107
108 static char* DumpTypeIndex(char*, DWORD64, DWORD, unsigned, DWORD_PTR, bool&, char*);
109
110 static char* FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);
111
112 static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
113
114 static int __cdecl _tprintf(const TCHAR* format, ...);
115
116 // Variables used by the class
117 static TCHAR m_szLogFileName[MAX_PATH];
118 static TCHAR m_szDumpFileName[MAX_PATH];
119 static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
120 static HANDLE m_hReportFile;
121 static HANDLE m_hDumpFile;
122 static HANDLE m_hProcess;
123};
124
125extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class
126#endif // _WIN32
127#endif // _WHEATYEXCEPTIONREPORT_
WheatyExceptionReport g_WheatyExceptionReport
const char *const rgBaseType[]
static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle)
static TCHAR m_szLogFileName[MAX_PATH]
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase)
static int __cdecl _tprintf(const TCHAR *format,...)
static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len, DWORD &section, DWORD_PTR &offset)
static void PrintSystemInfo()
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID)
static TCHAR m_szDumpFileName[MAX_PATH]
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter
static BOOL _GetWindowsVersion(TCHAR *szVersion, DWORD cntMax)
static LONG WINAPI WheatyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
static LPTSTR GetExceptionString(DWORD dwCode)
static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo)
static char * DumpTypeIndex(char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool &, char *)
static char * FormatOutputValue(char *pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress)
static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME *, char *pszBuffer, unsigned cbBuffer)
static BOOL _GetProcessorName(TCHAR *sProcessorName, DWORD maxcount)
static void printTracesForAllThreads()