AuroraRuntime/Source/SWInfo/VersionHelpers.cpp
2022-05-28 17:21:57 +01:00

99 lines
3.3 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: VersionHelpers.cpp
Date: 2022-1-25
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "SWInfo.hpp"
// NO HEADER (note -> .hpp wouldn't clash with windows' sdk)
namespace Aurora::SWInfo
{
static AuUInt16 kWinVerNT4 = 0x0400;
static AuUInt16 kWinVerWin2K = 0x0500;
static AuUInt16 kWinVerWinXP = 0x0501;
static AuUInt16 kWinVerWS03 = 0x0502;
static AuUInt16 kWinVerWin6 = 0x0600;
static AuUInt16 kWinVerVista = 0x0600;
static AuUInt16 kWinVerWS08 = 0x0600;
static AuUInt16 kWinVerWin7 = 0x0601;
static AuUInt16 kWinVerWin8 = 0x0602;
static AuUInt16 kWinVerWinBlue = 0x0603;
static AuUInt16 kWinVerWin10 = 0x0A00;
static AuUInt16 kKernPatchWin11 = 22000;
static bool IsWindowsVersionOrGreater(AuUInt8 major, AuUInt8 minor, AuUInt16 sp)
{
auto &info = GetPlatformInfo();
return info.ePlatform == Build::EPlatform::ePlatformWin32 &&
(info.uKernelMajor > major || (info.uKernelMajor == major && info.uKernelMinor >= minor)) &&
((info.uKernelMajor == major && info.uKernelMinor == minor) ? info.uUserlandMinor >= sp : true);
}
AUKN_SYM bool IsWindowsXPOrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWinXP), AuBitsToLower(kWinVerWinXP), 0);
}
AUKN_SYM bool IsWindowsXPSP1OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWinXP), AuBitsToLower(kWinVerWinXP), 1);
}
AUKN_SYM bool IsWindowsXPSP2OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWinXP), AuBitsToLower(kWinVerWinXP), 2);
}
AUKN_SYM bool IsWindowsXPSP3OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWinXP), AuBitsToLower(kWinVerWinXP), 3);
}
AUKN_SYM bool IsWindowsVistaOrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerVista), AuBitsToLower(kWinVerVista), 0);
}
AUKN_SYM bool IsWindowsVistaSP1OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerVista), AuBitsToLower(kWinVerVista), 1);
}
AUKN_SYM bool IsWindowsVistaSP2OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerVista), AuBitsToLower(kWinVerVista), 2);
}
AUKN_SYM bool IsWindows7OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWin7), AuBitsToLower(kWinVerWin7), 0);
}
AUKN_SYM bool IsWindows7SP1OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWin7), AuBitsToLower(kWinVerWin7), 1);
}
AUKN_SYM bool IsWindows8OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWin8), AuBitsToLower(kWinVerWin8), 0);
}
AUKN_SYM bool IsWindows8Point1OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWinBlue), AuBitsToLower(kWinVerWinBlue), 0);
}
AUKN_SYM bool IsWindows10OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWin10), AuBitsToLower(kWinVerWin10), 0);
}
AUKN_SYM bool IsWindows11OrGreater()
{
return IsWindowsVersionOrGreater(AuBitsToHigher(kWinVerWin10), AuBitsToLower(kWinVerWin10), 0) && GetPlatformInfo().uKernelPatch >= kKernPatchWin11;
}
}