2022-12-26 20:11:37 +01:00
|
|
|
#ifndef CRASHHANDLER_H
|
|
|
|
#define CRASHHANDLER_H
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CCrashHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCrashHandler();
|
|
|
|
~CCrashHandler();
|
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
void Lock() const { m_Mutex.lock(); };
|
|
|
|
void Unlock() const { m_Mutex.unlock(); };
|
2022-12-26 20:11:37 +01:00
|
|
|
|
|
|
|
void FormatCrash();
|
|
|
|
void FormatCallstack();
|
|
|
|
void FormatRegisters();
|
2022-12-26 22:00:38 +01:00
|
|
|
void FormatSystemInfo();
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
const char* ExceptionToString() const;
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
void SetExceptionPointers(EXCEPTION_POINTERS* pExceptionPointers) { m_pExceptionPointers = pExceptionPointers; };
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
void WriteFile();
|
2022-12-26 20:11:37 +01:00
|
|
|
void GetCallStack();
|
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
private:
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
void FormatExceptionAddress(LPCSTR pExceptionAddress = nullptr);
|
|
|
|
void FormatExceptionCode();
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
void FormatAPU(const char* pszRegister, DWORD64 nContent);
|
|
|
|
void FormatFPU(const char* pszRegister, M128A* pxContent);
|
2022-12-26 20:11:37 +01:00
|
|
|
|
2022-12-26 20:33:09 +01:00
|
|
|
bool IsPageAccessible() const;
|
2022-12-26 20:11:37 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NUM_FRAMES_TO_CAPTURE = 60
|
|
|
|
};
|
|
|
|
|
|
|
|
void* m_hExceptionHandler;
|
|
|
|
PVOID m_ppStackTrace[NUM_FRAMES_TO_CAPTURE];
|
|
|
|
EXCEPTION_POINTERS* m_pExceptionPointers;
|
|
|
|
WORD m_nCapturedFrames;
|
|
|
|
string m_svBuffer;
|
|
|
|
mutable std::mutex m_Mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CRASHHANDLER_H
|