// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
//==================================================================================================
struct TerminationParams
{
   PCWSTR         Message              $required;
   $PCCallerInfo  CallerInfoPtr        $optional;
   DWORD          SourceThreadId       $relopt;
   bool           UseTerminationThread;
}; // TerminationParams
typedef TerminationParams*       PTerminationParams;
typedef const TerminationParams* PCTerminationParams;
//==================================================================================================
enum ReportOutputs $flags
{
   UI    = 1u << 0,
   Trace = 1u << 1,
   All   = UI | Trace
}; // ReportOutputs
//==================================================================================================
struct ShowErrorBoxParams
{
   PCWSTR Text, Caption;
}; // ShowErrorBoxParams
typedef ShowErrorBoxParams*         PShowErrorBoxParams;
typedef const ShowErrorBoxParams*   PCShowErrorBoxParams;
//==================================================================================================
static DWORD _RaiseCallerThreadId_, _TerminationThreadId_;
//==================================================================================================
static void ReportError( const TerminationParams& terminationParams,
                         bool isCompletionReport = false );
static void ReportError( ReportOutputs outputs,
                         const TerminationParams& terminationParams,
                         bool isCompletionReport = false );
static bool ShowErrorBox( PCWSTR text, PCWSTR caption );
static DWORD WINAPI ShowErrorBoxRoutine(PVOID pShowErrorBoxParams);
//--------------------------------------------------------------------------------------------------
static UINT __stdcall TerminationRoutine(PVOID pStartData);
static void Terminate() $not_returns;
//--------------------------------------------------------------------------------------------------
static void TraceExceptionMessage(PCWSTR captionPhrase,const std::exception& e);
static PCWSTR VerifyFormatAlloc($CI_REF,PCWSTR str) $fatal_error_on_failure;
//==================================================================================================
