Core/Misc: Added windows version checks during startup to avoid confusion about crashes when running on unsupported OS

This commit is contained in:
Shauren authored and Ovahlord committed 2023-12-14 01:06:34 +01:00
1 parent d5cb122e3a
commit d02827d228
12 files changed
+63 -6

No files matched your search

+14
View File
@@ -129,6 +129,20 @@ void Abort(char const* file, int line, char const* function)
Crash(formattedMessage.c_str());
}
void Abort(char const* file, int line, char const* function, char const* message, ...)
{
va_list args;
va_start(args, message);
std::string formattedMessage = StringFormat("\n%s:%i in %s ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
}
void AbortHandler(int sigval)
{
// nothing useful to log here, no way to pass args
+3
View File
@@ -30,6 +30,7 @@ namespace Trinity
DECLSPEC_NORETURN TC_COMMON_API void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN TC_COMMON_API void Abort(char const* file, int line, char const* function) ATTR_NORETURN;
DECLSPEC_NORETURN TC_COMMON_API void Abort(char const* file, int line, char const* function, char const* message, ...) ATTR_NORETURN;
TC_COMMON_API void Warning(char const* file, int line, char const* function, char const* message);
@@ -54,6 +55,7 @@ namespace Trinity
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END
#ifdef PERFORMANCE_PROFILING
#define ASSERT(cond, ...) ((void)0)
@@ -62,6 +64,7 @@ namespace Trinity
#endif
#define ABORT WPAbort
#define ABORT_MSG WPAbort_MSG
template <typename T> inline T* ASSERT_NOTNULL(T* pointer)
{
@@ -264,7 +264,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
RTL_OSVERSIONINFOEXW osvi = { };
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
if (bVersionEx < 0)
if (FAILED(bVersionEx))
{
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi))