2014-07-11 02:10:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-10-18 18:14:31 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_WindowsVersion_h
|
|
|
|
#define mozilla_WindowsVersion_h
|
|
|
|
|
2017-10-09 08:36:23 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
2014-02-27 22:58:47 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include <stdint.h>
|
2013-10-18 18:14:31 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2014-07-11 02:10:17 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
2017-06-06 17:14:58 +00:00
|
|
|
inline bool IsWindows10BuildOrLater(uint32_t aBuild) {
|
2017-10-09 08:36:23 +00:00
|
|
|
static Atomic<uint32_t> minBuild(0);
|
|
|
|
static Atomic<uint32_t> maxBuild(UINT32_MAX);
|
2017-06-06 17:14:58 +00:00
|
|
|
|
|
|
|
if (minBuild >= aBuild) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aBuild >= maxBuild) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:40:48 +00:00
|
|
|
OSVERSIONINFOEXW info;
|
|
|
|
ZeroMemory(&info, sizeof(OSVERSIONINFOEXW));
|
|
|
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
2017-06-06 17:14:58 +00:00
|
|
|
info.dwMajorVersion = 10;
|
|
|
|
info.dwBuildNumber = aBuild;
|
|
|
|
|
|
|
|
DWORDLONG conditionMask = 0;
|
|
|
|
VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
|
|
|
VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
|
|
|
|
VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
|
|
|
|
VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
|
|
|
VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
|
|
|
|
|
2021-01-04 14:40:48 +00:00
|
|
|
if (VerifyVersionInfoW(&info,
|
|
|
|
VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER |
|
|
|
|
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
conditionMask)) {
|
2017-06-06 17:14:58 +00:00
|
|
|
minBuild = aBuild;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxBuild = aBuild;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-07 23:24:51 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin10AnniversaryUpdateOrLater() {
|
|
|
|
return IsWindows10BuildOrLater(14393);
|
|
|
|
}
|
|
|
|
|
2017-06-06 17:14:58 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin10CreatorsUpdateOrLater() {
|
|
|
|
return IsWindows10BuildOrLater(15063);
|
|
|
|
}
|
|
|
|
|
2018-04-05 17:53:56 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin10FallCreatorsUpdateOrLater() {
|
|
|
|
return IsWindows10BuildOrLater(16299);
|
|
|
|
}
|
|
|
|
|
2019-02-05 22:10:11 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin10Sep2018UpdateOrLater() {
|
|
|
|
return IsWindows10BuildOrLater(17763);
|
|
|
|
}
|
|
|
|
|
2021-10-28 21:08:12 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin11OrLater() {
|
|
|
|
return IsWindows10BuildOrLater(22000);
|
|
|
|
}
|
|
|
|
|
2023-10-03 15:24:47 +00:00
|
|
|
MOZ_ALWAYS_INLINE bool IsWin1122H2OrLater() {
|
2022-10-28 14:17:54 +00:00
|
|
|
return IsWindows10BuildOrLater(22621);
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:10:17 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-10-18 18:14:31 +00:00
|
|
|
#endif /* mozilla_WindowsVersion_h */
|