66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
|
/***
|
||
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: Panic.cpp
|
||
|
Date: 2021-6-12
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#include <RuntimeInternal.hpp>
|
||
|
#include "Debug.hpp"
|
||
|
#include "Panic.hpp"
|
||
|
|
||
|
#include <Console/ConsoleLogger/ConsoleLogger.hpp>
|
||
|
|
||
|
namespace Aurora::Debug
|
||
|
{
|
||
|
AUKN_SYM void Panic()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
CheckErrors();
|
||
|
}
|
||
|
catch (...)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
try
|
||
|
{
|
||
|
Console::ConsoleLogger::Flush();
|
||
|
}
|
||
|
catch (...)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
static bool panicSingleshot = false;
|
||
|
if (std::exchange(panicSingleshot, true))
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
Telemetry::Mayday();
|
||
|
}
|
||
|
catch (...)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//
|
||
|
static bool handlingFatal = false;
|
||
|
if (std::exchange(handlingFatal, true))
|
||
|
{
|
||
|
std::terminate();
|
||
|
}
|
||
|
|
||
|
#if defined(AURORA_PLATFORM_WIN32)
|
||
|
// there is a syscall you can use to terminate in instances like this
|
||
|
// anticheats and drm love it
|
||
|
// i just dont remember what it is
|
||
|
// amendment: i believe its some software interrupt that raises an unhandleable exception
|
||
|
TerminateProcess(GetCurrentProcess(), 0xDEAD);
|
||
|
#else
|
||
|
std::exit(0xDEAD);
|
||
|
#endif
|
||
|
}
|
||
|
}
|