Skip to content

Commit

Permalink
GetOSSupported() changed to only use majorVersion, minorVersion, buil…
Browse files Browse the repository at this point in the history
…dVersion and servicePack values when checking for compatible OS (productType is not used). This means both 'workstation/desktop' and 'server' OS versions are checked, and compatible server versions should not produce a warning message.
  • Loading branch information
owlsroost committed Mar 3, 2019
1 parent d977af6 commit 1b67f45
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions Common-MP-TVE3/OsInfo/OSInfo.cs
Expand Up @@ -668,44 +668,39 @@ public static string GetOSx64orx32String()
/// </summary>
public static OsSupport GetOSSupported()
{
if (VerifyDesktopOSMinRequirement(5, 1, 2600, (byte) NTProductType.NT_WORKSTATION, 3))
if (VerifyOSMinRequirement(5, 1, 2600, 3))
{
// XP SP3
return OsSupport.NotSupported;
}
if (VerifyDesktopOSMinRequirement(6, 0, 6000, (byte) NTProductType.NT_WORKSTATION, 2))
if (VerifyOSMinRequirement(5, 2, 3790, 0))
{
// Vista SP2
return OsSupport.FullySupported;
}
if (VerifyDesktopOSMinRequirement(6, 1, 7600, (byte) NTProductType.NT_WORKSTATION, 0))
{
// Win7 RTM
return OsSupport.FullySupported;
// Server 2003/Windows Home Server
return OsSupport.NotSupported;
}
if (VerifyDesktopOSMinRequirement(6, 2, 9200, (byte) NTProductType.NT_WORKSTATION, 0))
if (VerifyOSMinRequirement(6, 0, 6001, 0))
{
// Windows 8 RTM
// Vista SP2/Windows Server 2008
return OsSupport.FullySupported;
}
if (VerifyDesktopOSMinRequirement(6, 3, 9431, (byte) NTProductType.NT_WORKSTATION, 0))
if (VerifyOSMinRequirement(6, 1, 7600, 0))
{
// Windows 8.1 Preview
// Windows 7/Windows Server 2008 R2/Windows Home Server 2011
return OsSupport.FullySupported;
}
if (VerifyDesktopOSMinRequirement(6, 3, 9600, (byte) NTProductType.NT_WORKSTATION, 0))
if (VerifyOSMinRequirement(6, 2, 9200, 0))
{
// Windows 8.1 RTM
// Windows 8/Windows Server 2012
return OsSupport.FullySupported;
}
if (VerifyDesktopOSMinRequirement(10, 0, 10240, (byte) NTProductType.NT_WORKSTATION, 0))
if (VerifyOSMinRequirement(6, 3, 9200, 0))
{
// Windows 10 RTM
// Windows 8.1/Windows Server 2012 R2
return OsSupport.FullySupported;
}
if (IsServer())
if (VerifyOSMinRequirement(10, 0, 10240, 0))
{
// any server OS
// Windows 10/Windows Server 2016/Windows Server 2019
return OsSupport.FullySupported;
}
return OsSupport.Blocked;
Expand Down Expand Up @@ -964,11 +959,9 @@ private static bool VerifyVersionGreaterEqual(int majorVersion, int minorVersion
/// <param name="majorVersion">Major OS version</param>
/// <param name="minorVersion">Minor OS version</param>
/// <param name="buildVersion">OS Build Version</param>
/// <param name="productType">OS Product Type</param>
/// <param name="servicePack">Minimum Major Service PackVersion</param>
/// <returns>True if Major / Minor OS versions match and service pack / build version are >= parameters</returns>
private static bool VerifyDesktopOSMinRequirement(int majorVersion, int minorVersion, int buildVersion,
byte productType, short servicePack)
private static bool VerifyOSMinRequirement(int majorVersion, int minorVersion, int buildVersion, short servicePack)
{
ulong condition = 0;
var osVersionInfo = new OSVERSIONINFOEX
Expand All @@ -977,17 +970,15 @@ private static bool VerifyVersionGreaterEqual(int majorVersion, int minorVersion
dwMajorVersion = majorVersion,
dwMinorVersion = minorVersion,
dwBuildNumber = buildVersion,
wProductType = (NTProductType) productType,
wServicePackMajor = servicePack
};
condition = VerSetConditionMask(condition, VersionTypeFlags.VER_MAJORVERSION, ConditionType.VER_EQUAL);
condition = VerSetConditionMask(condition, VersionTypeFlags.VER_MINORVERSION, ConditionType.VER_EQUAL);
condition = VerSetConditionMask(condition, VersionTypeFlags.VER_PRODUCT_TYPE, ConditionType.VER_EQUAL);
condition = VerSetConditionMask(condition, VersionTypeFlags.VER_SERVICEPACKMAJOR, ConditionType.VER_GREATER_EQUAL);
condition = VerSetConditionMask(condition, VersionTypeFlags.VER_BUILDVERSION, ConditionType.VER_GREATER_EQUAL);
return VerifyVersionInfo(ref osVersionInfo,
VersionTypeFlags.VER_MAJORVERSION | VersionTypeFlags.VER_MINORVERSION |
VersionTypeFlags.VER_PRODUCT_TYPE | VersionTypeFlags.VER_SERVICEPACKMAJOR |
VersionTypeFlags.VER_SERVICEPACKMAJOR |
VersionTypeFlags.VER_BUILDVERSION, condition);
}

Expand Down

0 comments on commit 1b67f45

Please sign in to comment.