TrinityCore
Loading...
Searching...
No Matches
WheatyExceptionReport Class Reference

#include <WheatyExceptionReport.h>

Classes

struct  EnumerateSymbolsCallbackContext
 

Public Member Functions

 WheatyExceptionReport ()
 
 WheatyExceptionReport (WheatyExceptionReport const &)=delete
 
 WheatyExceptionReport (WheatyExceptionReport &&)=delete
 
WheatyExceptionReport & operator= (WheatyExceptionReport const &)=delete
 
WheatyExceptionReport & operator= (WheatyExceptionReport &&)=delete
 
 ~WheatyExceptionReport ()
 
LONG UnhandledExceptionFilterImpl (PEXCEPTION_POINTERS pExceptionInfo) noexcept
 
void printTracesForAllThreads (bool bWriteVariables)
 

Static Public Member Functions

static LONG WINAPI WheatyUnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo)
 
static void __cdecl WheatyCrtHandler (wchar_t const *expression, wchar_t const *function, wchar_t const *file, unsigned int line, uintptr_t pReserved)
 

Private Types

typedef NTSTATUS(NTAPI * pRtlGetVersion) (PRTL_OSVERSIONINFOW lpVersionInformation)
 

Private Member Functions

void GenerateExceptionReport (PEXCEPTION_POINTERS pExceptionInfo)
 
void PrintSystemInfo ()
 
BOOL _GetWindowsVersion (TCHAR *szVersion, DWORD cntMax)
 
void WriteStackDetails (PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle)
 
bool FormatSymbolValue (PSYMBOL_INFO, EnumerateSymbolsCallbackContext *)
 
void DumpTypeIndex (DWORD64, DWORD, DWORD_PTR, bool &, char const *, char const *, bool, bool)
 
template<typename T >
void FormatOutputValueNumeric (char *buffer, size_t bufferSize, char const *format, LPCVOID address)
 
void FormatOutputValue (char *pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize, size_t countOverride=0)
 
BasicType GetBasicType (DWORD typeIndex, DWORD64 modBase) const
 
template<typename T >
requires (std::is_scalar_v<T>)
Optional< T > DereferenceUnsafePointer (LPCVOID address)
 
int Log (const TCHAR *format,...)
 
bool StoreSymbol (DWORD type, DWORD_PTR offset)
 
void ClearSymbols ()
 
SymbolDetail & PushSymbolDetail ()
 
void PopSymbolDetail ()
 
void PrintSymbolDetail ()
 

Static Private Member Functions

static BOOL _GetWindowsVersionFromWMI (TCHAR *szVersion, DWORD cntMax) noexcept
 
static BOOL _GetProcessorName (TCHAR *sProcessorName, DWORD maxcount)
 
static LPCTSTR GetExceptionString (DWORD dwCode)
 
static BOOL GetLogicalAddress (PVOID addr, PTSTR szModule, DWORD len, DWORD &section, DWORD_PTR &offset)
 
static BOOL GetSymbolFromAddress (HANDLE hProcess, DWORD64 Address, ULONG InlineContext, PDWORD64 Displacement, PSYMBOL_INFO Symbol)
 
static BOOL GetSymbolLineFromAddress (HANDLE hProcess, DWORD64 qwAddr, ULONG InlineContext, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64)
 
static BOOL CALLBACK EnumerateSymbolsCallback (PSYMBOL_INFO, ULONG, PVOID)
 
static Optional< DWORD_PTR > GetIntegerRegisterValue (PCONTEXT context, ULONG registerId)
 

Private Attributes

TCHAR * m_tempPathBuffer
 
LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter
 
_invalid_parameter_handler m_previousCrtHandler
 
FILE * m_reportFile
 
HANDLE m_dumpFile
 
HANDLE m_process
 
SymbolPairs m_symbols
 
std::stack< SymbolDetail > m_symbolDetails
 
bool m_alreadyCrashed
 
SRWLOCK m_alreadyCrashedLock
 
pRtlGetVersion RtlGetVersion
 

Static Private Attributes

static constexpr SIZE_T m_tempPathBufferChars = 0x8000
 

Detailed Description

Definition at line 379 of file WheatyExceptionReport.h.

Member Typedef Documentation

◆ pRtlGetVersion

typedef NTSTATUS(NTAPI * WheatyExceptionReport::pRtlGetVersion) (PRTL_OSVERSIONINFOW lpVersionInformation)
private

Definition at line 459 of file WheatyExceptionReport.h.

Constructor & Destructor Documentation

◆ WheatyExceptionReport() [1/3]

WheatyExceptionReport::WheatyExceptionReport ( )

Definition at line 71 of file WheatyExceptionReport.cpp.

◆ WheatyExceptionReport() [2/3]

WheatyExceptionReport::WheatyExceptionReport ( WheatyExceptionReport const &  )
delete

◆ WheatyExceptionReport() [3/3]

WheatyExceptionReport::WheatyExceptionReport ( WheatyExceptionReport &&  )
delete

◆ ~WheatyExceptionReport()

WheatyExceptionReport::~WheatyExceptionReport ( )

Member Function Documentation

◆ _GetProcessorName()

BOOL WheatyExceptionReport::_GetProcessorName ( TCHAR *  sProcessorName,
DWORD  maxcount 
)
staticprivate

Definition at line 238 of file WheatyExceptionReport.cpp.

Referenced by PrintSystemInfo().

◆ _GetWindowsVersion()

BOOL WheatyExceptionReport::_GetWindowsVersion ( TCHAR *  szVersion,
DWORD  cntMax 
)
private

Definition at line 274 of file WheatyExceptionReport.cpp.

References _GetWindowsVersionFromWMI(), RtlGetVersion, and ToTchar().

Referenced by PrintSystemInfo().

◆ _GetWindowsVersionFromWMI()

BOOL WheatyExceptionReport::_GetWindowsVersionFromWMI ( TCHAR *  szVersion,
DWORD  cntMax 
)
staticprivatenoexcept

Definition at line 458 of file WheatyExceptionReport.cpp.

References Trinity::make_unique_ptr_with_deleter(), and ToTchar().

Referenced by _GetWindowsVersion().

◆ ClearSymbols()

void WheatyExceptionReport::ClearSymbols ( )
private

Definition at line 1950 of file WheatyExceptionReport.cpp.

References m_symbolDetails, and m_symbols.

Referenced by EnumerateSymbolsCallback(), and ~WheatyExceptionReport().

◆ DereferenceUnsafePointer()

template<typename T >
requires (std::is_scalar_v<T>)
Optional< T > WheatyExceptionReport::DereferenceUnsafePointer ( LPCVOID  address)
private

Definition at line 1922 of file WheatyExceptionReport.cpp.

◆ DumpTypeIndex()

◆ EnumerateSymbolsCallback()

BOOL CALLBACK WheatyExceptionReport::EnumerateSymbolsCallback ( PSYMBOL_INFO  pSymInfo,
ULONG  ,
PVOID  UserContext 
)
staticprivate

◆ FormatOutputValue()

void WheatyExceptionReport::FormatOutputValue ( char *  pszCurrBuffer,
BasicType  basicType,
DWORD64  length,
PVOID  pAddress,
size_t  bufferSize,
size_t  countOverride = 0 
)
private

Definition at line 1778 of file WheatyExceptionReport.cpp.

References btChar, btFloat, btStdString, bufferSize, and m_process.

Referenced by DumpTypeIndex(), and FormatSymbolValue().

◆ FormatOutputValueNumeric()

template<typename T >
void WheatyExceptionReport::FormatOutputValueNumeric ( char *  buffer,
size_t  bufferSize,
char const *  format,
LPCVOID  address 
)
private

Definition at line 1770 of file WheatyExceptionReport.cpp.

References bufferSize.

◆ FormatSymbolValue()

◆ GenerateExceptionReport()

◆ GetBasicType()

BasicType WheatyExceptionReport::GetBasicType ( DWORD  typeIndex,
DWORD64  modBase 
) const
private

Definition at line 1897 of file WheatyExceptionReport.cpp.

References btNoType, and m_process.

Referenced by DumpTypeIndex(), and FormatSymbolValue().

◆ GetExceptionString()

LPCTSTR WheatyExceptionReport::GetExceptionString ( DWORD  dwCode)
staticprivate

Definition at line 889 of file WheatyExceptionReport.cpp.

References EXCEPTION.

Referenced by GenerateExceptionReport().

◆ GetIntegerRegisterValue()

Optional< DWORD_PTR > WheatyExceptionReport::GetIntegerRegisterValue ( PCONTEXT  context,
ULONG  registerId 
)
staticprivate

Definition at line 1159 of file WheatyExceptionReport.cpp.

References CPU_REG, CV_AMD64_AH, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_BH, CV_AMD64_BL, CV_AMD64_BP, CV_AMD64_BPL, CV_AMD64_BX, CV_AMD64_CH, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_DH, CV_AMD64_DI, CV_AMD64_DIL, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EAX, CV_AMD64_EBP, CV_AMD64_EBX, CV_AMD64_ECX, CV_AMD64_EDI, CV_AMD64_EDX, CV_AMD64_ESI, CV_AMD64_ESP, CV_AMD64_R10, CV_AMD64_R10B, CV_AMD64_R10D, CV_AMD64_R10W, CV_AMD64_R11, CV_AMD64_R11B, CV_AMD64_R11D, CV_AMD64_R11W, CV_AMD64_R12, CV_AMD64_R12B, CV_AMD64_R12D, CV_AMD64_R12W, CV_AMD64_R13, CV_AMD64_R13B, CV_AMD64_R13D, CV_AMD64_R13W, CV_AMD64_R14, CV_AMD64_R14B, CV_AMD64_R14D, CV_AMD64_R14W, CV_AMD64_R15, CV_AMD64_R15B, CV_AMD64_R15D, CV_AMD64_R15W, CV_AMD64_R8, CV_AMD64_R8B, CV_AMD64_R8D, CV_AMD64_R8W, CV_AMD64_R9, CV_AMD64_R9B, CV_AMD64_R9D, CV_AMD64_R9W, CV_AMD64_RAX, CV_AMD64_RBP, CV_AMD64_RBX, CV_AMD64_RCX, CV_AMD64_RDI, CV_AMD64_RDX, CV_AMD64_RIP, CV_AMD64_RSI, CV_AMD64_RSP, CV_AMD64_SI, CV_AMD64_SIL, CV_AMD64_SP, CV_AMD64_SPL, CV_ARM64_FP, CV_ARM64_IP0, CV_ARM64_IP1, CV_ARM64_LR, CV_ARM64_SP, CV_ARM64_W0, CV_ARM64_W1, CV_ARM64_W10, CV_ARM64_W11, CV_ARM64_W12, CV_ARM64_W13, CV_ARM64_W14, CV_ARM64_W15, CV_ARM64_W16, CV_ARM64_W17, CV_ARM64_W18, CV_ARM64_W19, CV_ARM64_W2, CV_ARM64_W20, CV_ARM64_W21, CV_ARM64_W22, CV_ARM64_W23, CV_ARM64_W24, CV_ARM64_W25, CV_ARM64_W26, CV_ARM64_W27, CV_ARM64_W28, CV_ARM64_W29, CV_ARM64_W3, CV_ARM64_W30, CV_ARM64_W4, CV_ARM64_W5, CV_ARM64_W6, CV_ARM64_W7, CV_ARM64_W8, CV_ARM64_W9, CV_ARM64_WZR, CV_ARM64_X0, CV_ARM64_X1, CV_ARM64_X10, CV_ARM64_X11, CV_ARM64_X12, CV_ARM64_X13, CV_ARM64_X14, CV_ARM64_X15, CV_ARM64_X18, CV_ARM64_X19, CV_ARM64_X2, CV_ARM64_X20, CV_ARM64_X21, CV_ARM64_X22, CV_ARM64_X23, CV_ARM64_X24, CV_ARM64_X25, CV_ARM64_X26, CV_ARM64_X27, CV_ARM64_X28, CV_ARM64_X3, CV_ARM64_X4, CV_ARM64_X5, CV_ARM64_X6, CV_ARM64_X7, CV_ARM64_X8, CV_ARM64_X9, CV_ARM64_ZR, CV_REG_AH, CV_REG_AL, CV_REG_AX, CV_REG_BH, CV_REG_BL, CV_REG_BP, CV_REG_BX, CV_REG_CH, CV_REG_CL, CV_REG_CX, CV_REG_DH, CV_REG_DI, CV_REG_DL, CV_REG_DX, CV_REG_EAX, CV_REG_EBP, CV_REG_EBX, CV_REG_ECX, CV_REG_EDI, CV_REG_EDX, CV_REG_EIP, CV_REG_ESI, CV_REG_ESP, CV_REG_SI, CV_REG_SP, REG_E, REG_H, REG_L, REG_R, and REG_X.

Referenced by FormatSymbolValue().

◆ GetLogicalAddress()

BOOL WheatyExceptionReport::GetLogicalAddress ( PVOID  addr,
PTSTR  szModule,
DWORD  len,
DWORD &  section,
DWORD_PTR &  offset 
)
staticprivate

Definition at line 939 of file WheatyExceptionReport.cpp.

Referenced by GenerateExceptionReport(), and WriteStackDetails().

◆ GetSymbolFromAddress()

BOOL WheatyExceptionReport::GetSymbolFromAddress ( HANDLE  hProcess,
DWORD64  Address,
ULONG  InlineContext,
PDWORD64  Displacement,
PSYMBOL_INFO  Symbol 
)
staticprivate

Definition at line 1001 of file WheatyExceptionReport.cpp.

Referenced by WriteStackDetails().

◆ GetSymbolLineFromAddress()

BOOL WheatyExceptionReport::GetSymbolLineFromAddress ( HANDLE  hProcess,
DWORD64  qwAddr,
ULONG  InlineContext,
PDWORD  pdwDisplacement,
PIMAGEHLP_LINE64  Line64 
)
staticprivate

Definition at line 1009 of file WheatyExceptionReport.cpp.

Referenced by WriteStackDetails().

◆ Log()

int WheatyExceptionReport::Log ( const TCHAR *  format,
  ... 
)
private

Definition at line 1936 of file WheatyExceptionReport.cpp.

References m_reportFile.

◆ operator=() [1/2]

WheatyExceptionReport & WheatyExceptionReport::operator= ( WheatyExceptionReport &&  )
delete

◆ operator=() [2/2]

WheatyExceptionReport & WheatyExceptionReport::operator= ( WheatyExceptionReport const &  )
delete

◆ PopSymbolDetail()

void WheatyExceptionReport::PopSymbolDetail ( )
private

Definition at line 1964 of file WheatyExceptionReport.cpp.

References m_symbolDetails, and PrintSymbolDetail().

Referenced by DumpTypeIndex(), and FormatSymbolValue().

◆ PrintSymbolDetail()

◆ PrintSystemInfo()

void WheatyExceptionReport::PrintSystemInfo ( )
private

Definition at line 607 of file WheatyExceptionReport.cpp.

References _GetProcessorName(), and _GetWindowsVersion().

Referenced by GenerateExceptionReport().

◆ printTracesForAllThreads()

void WheatyExceptionReport::printTracesForAllThreads ( bool  bWriteVariables)

Definition at line 631 of file WheatyExceptionReport.cpp.

References m_process, and WriteStackDetails().

Referenced by GenerateExceptionReport().

◆ PushSymbolDetail()

SymbolDetail & WheatyExceptionReport::PushSymbolDetail ( )
private

Definition at line 1957 of file WheatyExceptionReport.cpp.

References m_symbolDetails, and PrintSymbolDetail().

Referenced by DumpTypeIndex(), and FormatSymbolValue().

◆ StoreSymbol()

bool WheatyExceptionReport::StoreSymbol ( DWORD  type,
DWORD_PTR  offset 
)
private

Definition at line 1945 of file WheatyExceptionReport.cpp.

References m_symbols.

Referenced by DumpTypeIndex().

◆ UnhandledExceptionFilterImpl()

LONG WheatyExceptionReport::UnhandledExceptionFilterImpl ( PEXCEPTION_POINTERS  pExceptionInfo)
noexcept

◆ WheatyCrtHandler()

void __cdecl WheatyExceptionReport::WheatyCrtHandler ( wchar_t const *  expression,
wchar_t const *  function,
wchar_t const *  file,
unsigned int  line,
uintptr_t  pReserved 
)
static

Definition at line 233 of file WheatyExceptionReport.cpp.

◆ WheatyUnhandledExceptionFilter()

LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter ( PEXCEPTION_POINTERS  pExceptionInfo)
static

Definition at line 112 of file WheatyExceptionReport.cpp.

◆ WriteStackDetails()

Member Data Documentation

◆ m_alreadyCrashed

bool WheatyExceptionReport::m_alreadyCrashed
private

Definition at line 457 of file WheatyExceptionReport.h.

◆ m_alreadyCrashedLock

SRWLOCK WheatyExceptionReport::m_alreadyCrashedLock
private

Definition at line 458 of file WheatyExceptionReport.h.

◆ m_dumpFile

HANDLE WheatyExceptionReport::m_dumpFile
private

Definition at line 453 of file WheatyExceptionReport.h.

◆ m_previousCrtHandler

_invalid_parameter_handler WheatyExceptionReport::m_previousCrtHandler
private

Definition at line 451 of file WheatyExceptionReport.h.

Referenced by ~WheatyExceptionReport().

◆ m_previousFilter

LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter
private

Definition at line 450 of file WheatyExceptionReport.h.

Referenced by ~WheatyExceptionReport().

◆ m_process

HANDLE WheatyExceptionReport::m_process
private

◆ m_reportFile

FILE* WheatyExceptionReport::m_reportFile
private

Definition at line 452 of file WheatyExceptionReport.h.

Referenced by Log(), and PrintSymbolDetail().

◆ m_symbolDetails

std::stack<SymbolDetail> WheatyExceptionReport::m_symbolDetails
private

◆ m_symbols

SymbolPairs WheatyExceptionReport::m_symbols
private

Definition at line 455 of file WheatyExceptionReport.h.

Referenced by ClearSymbols(), and StoreSymbol().

◆ m_tempPathBuffer

TCHAR* WheatyExceptionReport::m_tempPathBuffer
private

◆ m_tempPathBufferChars

constexpr SIZE_T WheatyExceptionReport::m_tempPathBufferChars = 0x8000
staticconstexprprivate

Definition at line 449 of file WheatyExceptionReport.h.

Referenced by GenerateExceptionReport(), and WriteStackDetails().

◆ RtlGetVersion

pRtlGetVersion WheatyExceptionReport::RtlGetVersion
private

Definition at line 460 of file WheatyExceptionReport.h.

Referenced by _GetWindowsVersion().


The documentation for this class was generated from the following files: