From 333630b7de15c4090392fcbbc1bc58da4d5fb138 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 1 Dec 2023 19:53:13 +0100 Subject: Core/Misc: Added windows version checks during startup to avoid confusion about crashes when running on unsupported OS --- src/common/Utilities/Util.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/common/Utilities/Util.cpp') diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index d852ed655a0..5fb34c59948 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -31,11 +31,27 @@ #include #include -#if TRINITY_COMPILER == TRINITY_COMPILER_GNU - #include - #include - #include +void Trinity::VerifyOsVersion() +{ +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS + 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 +} std::vector Trinity::Tokenize(std::string_view str, char sep, bool keepEmpty) { -- cgit v1.2.3