Core/Misc: Added windows version checks during startup to avoid confusion about crashes when running on unsupported OS
This commit is contained in:
1 parent
d5cb122e3a
commit
d02827d228
12 files changed
+63
-6
No files matched your search
@@ -1,4 +1,8 @@
|
|||||||
add_definitions(-D_WIN32_WINNT=0x0601)
|
add_definitions(-D_WIN32_WINNT=0x0A00) # Windows 10
|
||||||
|
add_definitions(-DNTDDI_VERSION=0x0A000007) # 19H1 (1903)
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-DNOMINMAX)
|
||||||
|
add_definitions(-DTRINITY_REQUIRED_WINDOWS_BUILD=18362)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
|
||||||
|
|||||||
@@ -129,6 +129,20 @@ void Abort(char const* file, int line, char const* function)
|
|||||||
Crash(formattedMessage.c_str());
|
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)
|
void AbortHandler(int sigval)
|
||||||
{
|
{
|
||||||
// nothing useful to log here, no way to pass args
|
// nothing useful to log here, no way to pass args
|
||||||
|
|||||||
@@ -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 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) 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);
|
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 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 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() 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
|
#ifdef PERFORMANCE_PROFILING
|
||||||
#define ASSERT(cond, ...) ((void)0)
|
#define ASSERT(cond, ...) ((void)0)
|
||||||
@@ -62,6 +64,7 @@ namespace Trinity
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ABORT WPAbort
|
#define ABORT WPAbort
|
||||||
|
#define ABORT_MSG WPAbort_MSG
|
||||||
|
|
||||||
template <typename T> inline T* ASSERT_NOTNULL(T* pointer)
|
template <typename T> inline T* ASSERT_NOTNULL(T* pointer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
|
|||||||
RTL_OSVERSIONINFOEXW osvi = { };
|
RTL_OSVERSIONINFOEXW osvi = { };
|
||||||
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
|
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
|
||||||
NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
|
NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
|
||||||
if (bVersionEx < 0)
|
if (FAILED(bVersionEx))
|
||||||
{
|
{
|
||||||
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
|
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
|
||||||
if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi))
|
if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi))
|
||||||
|
|||||||
@@ -28,11 +28,27 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
void Trinity::VerifyOsVersion()
|
||||||
#include <sys/socket.h>
|
{
|
||||||
#include <netinet/in.h>
|
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||||
#include <arpa/inet.h>
|
auto isWindowsBuildGreaterOrEqual = [](DWORD build)
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, build, 0, {0}, 0, 0, 0, 0 };
|
||||||
|
ULONGLONG conditionMask = 0;
|
||||||
|
VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
|
||||||
|
|
||||||
|
return VerifyVersionInfo(&osvi, VER_BUILDNUMBER, conditionMask);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isWindowsBuildGreaterOrEqual(TRINITY_REQUIRED_WINDOWS_BUILD))
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, 0 };
|
||||||
|
GetVersionEx((LPOSVERSIONINFO)&osvi);
|
||||||
|
ABORT_MSG("TrinityCore requires Windows 10 19H1 (1903) or Windows Server 2019 (1903) - require build number 10.0.%d but found %d.%d.%d",
|
||||||
|
TRINITY_REQUIRED_WINDOWS_BUILD, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve /*= 0*/, bool keepEmptyStrings /*= true*/)
|
Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve /*= 0*/, bool keepEmptyStrings /*= true*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,11 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Trinity
|
||||||
|
{
|
||||||
|
TC_COMMON_API void VerifyOsVersion();
|
||||||
|
}
|
||||||
|
|
||||||
class TC_COMMON_API Tokenizer
|
class TC_COMMON_API Tokenizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
signal(SIGABRT, &Trinity::AbortHandler);
|
signal(SIGABRT, &Trinity::AbortHandler);
|
||||||
|
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
auto configFile = fs::absolute(_TRINITY_BNET_CONFIG);
|
auto configFile = fs::absolute(_TRINITY_BNET_CONFIG);
|
||||||
std::string configService;
|
std::string configService;
|
||||||
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
|
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ extern int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
signal(SIGABRT, &Trinity::AbortHandler);
|
signal(SIGABRT, &Trinity::AbortHandler);
|
||||||
|
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
auto configFile = fs::absolute(_TRINITY_CORE_CONFIG);
|
auto configFile = fs::absolute(_TRINITY_CORE_CONFIG);
|
||||||
std::string configService;
|
std::string configService;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
|
#include "Util.h"
|
||||||
#include "MapDefines.h"
|
#include "MapDefines.h"
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
@@ -1373,6 +1374,8 @@ void LoadCommonMPQFiles(uint32 build)
|
|||||||
|
|
||||||
int main(int argc, char * arg[])
|
int main(int argc, char * arg[])
|
||||||
{
|
{
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
Trinity::Banner::Show("Map & DBC Extractor", [](char const* text) { printf("%s\n", text); }, nullptr);
|
Trinity::Banner::Show("Map & DBC Extractor", [](char const* text) { printf("%s\n", text); }, nullptr);
|
||||||
|
|
||||||
PrintProgress = isatty(fileno(stdout));
|
PrintProgress = isatty(fileno(stdout));
|
||||||
|
|||||||
@@ -344,6 +344,8 @@ std::unordered_map<uint32, std::vector<uint32>> LoadMap(std::string const& local
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr);
|
Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr);
|
||||||
|
|
||||||
unsigned int threads = std::thread::hardware_concurrency();
|
unsigned int threads = std::thread::hardware_concurrency();
|
||||||
|
|||||||
@@ -20,9 +20,12 @@
|
|||||||
|
|
||||||
#include "TileAssembler.h"
|
#include "TileAssembler.h"
|
||||||
#include "Banner.h"
|
#include "Banner.h"
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr);
|
Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr);
|
||||||
|
|
||||||
std::string src = "Buildings";
|
std::string src = "Buildings";
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "mpqfile.h"
|
#include "mpqfile.h"
|
||||||
#include "wmo.h"
|
#include "wmo.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
|
#include "Util.h"
|
||||||
#include "vmapexport.h"
|
#include "vmapexport.h"
|
||||||
#include "VMapDefinitions.h"
|
#include "VMapDefinitions.h"
|
||||||
#include "Banner.h"
|
#include "Banner.h"
|
||||||
@@ -476,6 +477,8 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
|||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
Trinity::VerifyOsVersion();
|
||||||
|
|
||||||
Trinity::Banner::Show("VMAP data extractor", [](char const* text) { printf("%s\n", text); }, nullptr);
|
Trinity::Banner::Show("VMAP data extractor", [](char const* text) { printf("%s\n", text); }, nullptr);
|
||||||
|
|
||||||
input_path = boost::filesystem::current_path();
|
input_path = boost::filesystem::current_path();
|
||||||
|
|||||||
Reference in new issue
Block a user