Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added detection of new windows versions #42

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
68 changes: 63 additions & 5 deletions Win32.pm
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ sub GetOSDisplayName {
$desc =~ s/^\s*//;
s/(200.)/$name Server $1/;
}
s/^Windows (20(03|08|12|16|19))/Windows Server $1/;
s/^Windows (20(03|08|12|16|19|22))/Windows Server $1/;
s/^Windows SAC/Windows Server/;
}
}
Expand Down Expand Up @@ -559,8 +559,10 @@ sub _GetOSName {
}
elsif ($major == 10) {
if ($producttype == VER_NT_WORKSTATION) {
$os = $build < 22000 ? '10' : '11';

# Build numbers from https://en.wikipedia.org/wiki/Windows_10_version_history
$os = '10';
# windows 10
if (9841 <= $build && $build <= 10240) {
$desc = " Version 1507";
$desc .= " (Preview Build $build)" if $build < 10240;
Expand Down Expand Up @@ -594,11 +596,46 @@ sub _GetOSName {
$desc = " Version 1903 (May 2019 Update)";
$desc .= " (Preview Build $build)" if $build < 18362;
}
elsif ($build == 18363) {
$desc = " Version 1909 (November 2019 Update)";
}
elsif ($build == 19041) {
$desc = " Version 2004 (May 2020 Update)";
}
elsif ($build == 19042) {
$desc = " Version 20H2 (October 2020 Update)";
}
elsif ($build == 19043) {
$desc = " Version 21H1 (May 2021 Update)";
}
elsif ($build == 19044) {
$desc = " Version 21H2 (November 2021 Update)";
}
elsif ($build == 19045) {
$desc = " Version 22H2 (2022 Update)";
}
# Build numbers from https://en.wikipedia.org/wiki/Windows_11_version_history
# windows 11
elsif ($build == 22000) {
$desc = " Version 21H2 (2021 Update)";
}
elsif ($build == 22621) {
$desc = " Version 22H2 (2022 Update)";
}
elsif ($build == 22631) {
$desc = " Version 23H2 (2023 Update)";
}
elsif ($build == 26100) {
$desc = " Version 24H2 (2024 Update)";
}
else {
$desc = " Build $build";
}
}
else {
# Build numbers from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
# https://learn.microsoft.com/en-us/windows-server/get-started/servicing-channels-comparison#annual-channel-ac
# Long-Term Servicing Channel (LTSC)
if ($build == 14393) {
$os = "2016";
$desc = "Version 1607";
Expand All @@ -607,7 +644,12 @@ sub _GetOSName {
$os = "2019";
$desc = "Version 1809";
}
elsif ($build == 20348) {
$os = "2022";
$desc = "Version 21H2";
}
else {
# (Semi) Annual Channel (AC)
$os = "Server";
if ($build == 16299) {
$desc = "Version 1709";
Expand All @@ -618,6 +660,18 @@ sub _GetOSName {
elsif ($build == 18362) {
$desc = "Version 1903";
}
elsif ($build == 18363) {
$desc = "Version 1909";
}
elsif ($build == 19041) {
$desc = "Version 2004";
}
elsif ($build == 19042) {
$desc = "Version 20H2";
}
elsif ($build == 25398) {
$desc = "Version 23H2";
}
else {
$desc = "Build $build";
}
Expand Down Expand Up @@ -1128,6 +1182,8 @@ Currently the possible values for the OS name are
Win10
Win2016
Win2019
Win2022
Win11
WinSAC

This routine is just a simple interface into GetOSVersion(). More
Expand Down Expand Up @@ -1179,11 +1235,13 @@ Currently known values for ID MAJOR MINOR and BUILD are as follows:
Windows Server 2012 2 6 2 -
Windows 8.1 2 6 2 -
Windows Server 2012 R2 2 6 2 -

Windows 10 2 10 0 -
Windows Server 2016 2 10 0 14393
Windows Server 2019 2 10 0 17677

Windows Server 2019 2 10 0 17763
Windows Server 2022 2 10 0 20348
Windows 11 2 10 0 -

On Windows NT 4 SP6 and later this function returns the following
additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.

Expand Down
20 changes: 18 additions & 2 deletions t/GetOSName.t
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,31 @@ my @win10_tests = (
["10 [Version 1903 (May 2019 Update) (Preview Build 18204)]", "10", 2, 10, 0, 0x00, 0, 0, 18204],
["10 [Version 1903 (May 2019 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 18362],

["10 [Version 1909 (November 2019 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 18363],
["10 [Version 2004 (May 2020 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 19041],
["10 [Version 20H2 (October 2020 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 19042],
["10 [Version 21H1 (May 2021 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 19043],
["10 [Version 21H2 (November 2021 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 19044],
["10 [Version 22H2 (2022 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 19045],

["11 [Version 21H2 (2021 Update)]", "11", 2, 10, 0, 0x00, 0, 0, 22000],
["11 [Version 22H2 (2022 Update)]", "11", 2, 10, 0, 0x00, 0, 0, 22621],
["11 [Version 23H2 (2023 Update)]", "11", 2, 10, 0, 0x00, 0, 0, 22631],
["11 [Version 24H2 (2024 Update)]", "11", 2, 10, 0, 0x00, 0, 0, 26100],

["2016 [Version 1607]", "2016", 2, 10, 0, 0x07, 2, 0, 14393],
["2019 [Version 1809]", "2019", 2, 10, 0, 0x07, 2, 0, 17763],
["2022 [Version 21H2]", "2022", 2, 10, 0, 0x07, 2, 0, 20348],

["Server [Version 1709]", "Server", 2, 10, 0, 0x07, 2, 0, 16299],
["Server [Version 1803]", "Server", 2, 10, 0, 0x07, 2, 0, 17134],
# The 1809 version from the semi-annual channel will identify as "Windows Server 2019 Version 1809"
#["Server [Version 1809]", "Server", 2, 10, 0, 0x07, 2, 0, 17763],
["Server [Version 1903]", "Server", 2, 10, 0, 0x07, 2, 0, 18362],
["Server [Version 1909]", "Server", 2, 10, 0, 0x07, 2, 0, 18363],
["Server [Version 2004]", "Server", 2, 10, 0, 0x07, 2, 0, 19041],
["Server [Version 20H2]", "Server", 2, 10, 0, 0x07, 2, 0, 19042],
["Server [Version 23H2]", "Server", 2, 10, 0, 0x07, 2, 0, 25398],
["Server [Build 12345]", "Server", 2, 10, 0, 0x07, 2, 0, 12345],

);
Expand All @@ -169,7 +186,7 @@ sub check {
# and 2003/2008 start with "Windows Server"
unless ($pretty eq "Win32s") {
my $prefix = "Windows";
$prefix .= " Server" if $pretty =~ /^20(03|08|12|16|19)/;
$prefix .= " Server" if $pretty =~ /^20(03|08|12|16|19|22)/;
$pretty = "$prefix $pretty";
}

Expand Down Expand Up @@ -209,4 +226,3 @@ sub check {
check($_, Win32::PROCESSOR_ARCHITECTURE_INTEL) for @intel_tests, @dual_tests, @win10_tests;
check($_, Win32::PROCESSOR_ARCHITECTURE_AMD64) for @amd64_tests, @dual_tests;
check($_, Win32::PROCESSOR_ARCHITECTURE_IA64) for @ia64_tests;