Skip to content

Commit 6cc5e74

Browse files
richardleachjandubois
authored andcommitted
Test producttype and build fields to add some support for telling Win10 and modern Windows Server versions apart.
1 parent 03d02fc commit 6cc5e74

File tree

2 files changed

+89
-28
lines changed

2 files changed

+89
-28
lines changed

Win32.pm

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ sub VER_SUITE_STORAGE_SERVER () { 0x00002000 } # Windows Storage Serve
174174
sub VER_SUITE_TERMINAL () { 0x00000010 } # Terminal Services is installed. This value is always set.
175175
# If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode.
176176
sub VER_SUITE_WH_SERVER () { 0x00008000 } # Windows Home Server is installed.
177+
sub VER_SUITE_MULTIUSERTS () { 0x00020000 } # AppServer mode is enabled.
177178

178179

179180
sub SM_TABLETPC () { 86 }
@@ -359,7 +360,8 @@ sub GetOSDisplayName {
359360
$desc =~ s/^\s*//;
360361
s/(200.)/$name Server $1/;
361362
}
362-
s/^Windows (20(03|08|12))/Windows Server $1/;
363+
s/^Windows (20(03|08|12|16|19))/Windows Server $1/;
364+
s/^Windows SAC/Windows Server/;
363365
}
364366
}
365367
$name .= " $desc" if length $desc;
@@ -544,10 +546,44 @@ sub _GetOSName {
544546
$desc = "R2";
545547
}
546548
}
547-
}
549+
}
548550
elsif ($major == 10) {
551+
if ($producttype == VER_NT_WORKSTATION) {
549552
$os = '10';
553+
if ($build == 10240) {
554+
$desc = ", version 1507 (RTM)";
555+
} elsif ($build == 14393) {
556+
$desc = ", version 1607";
557+
} elsif ($build == 15063) {
558+
$desc = ", version 1703";
559+
} elsif ($build == 16299) {
560+
$desc = ", version 1709";
561+
} elsif ($build == 17134) {
562+
$desc = ", version 1803";
563+
} elsif ($build == 17763) {
564+
$desc = ", version 1809";
565+
} else {
566+
$desc = ", version <unknown>";
567+
}
568+
} else {
569+
if ($build == 14393) {
570+
$os = "2016";
571+
$build = ", version 1607";
572+
} elsif ($build == 17763) {
573+
$os = "2019";
574+
$build = ", version 1809";
575+
} else {
576+
$os = "SAC";
577+
if ($build == 16299) {
578+
$desc = ", version 1709";
579+
} elsif ($build == 17134) {
580+
$desc = ", version 1803";
581+
} else {
582+
$desc = ", version <unknown>";
583+
}
584+
}
550585
}
586+
}
551587

552588
if ($major >= 6) {
553589
if ($productinfo == PRODUCT_ULTIMATE) {
@@ -998,6 +1034,10 @@ GetOSVersion() in list context.
9981034
The description will also include tags for other special editions,
9991035
like "R2", "Media Center", "Tablet PC", or "Starter Edition".
10001036
1037+
In the Windows 10 / Server Semi-Annual Channel era, the description may
1038+
contain the relevant ReleaseId value, but this is only inferred from
1039+
the build number, not determined absolutely.
1040+
10011041
Currently the possible values for the OS name are
10021042
10031043
WinWin32s
@@ -1013,6 +1053,12 @@ Currently the possible values for the OS name are
10131053
WinVista
10141054
Win2008
10151055
Win7
1056+
Win8
1057+
Win8.1
1058+
Win10
1059+
Win2016
1060+
Win2019
1061+
WinSAC
10161062
10171063
This routine is just a simple interface into GetOSVersion(). More
10181064
specific or demanding situations should use that instead. Another
@@ -1038,30 +1084,36 @@ For the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for
10381084
Windows NT/2000/XP/2003/Vista/2008/7. In scalar context it returns just
10391085
the ID.
10401086
1041-
Currently known values for ID MAJOR and MINOR are as follows:
1042-
1043-
OS ID MAJOR MINOR
1044-
Win32s 0 - -
1045-
Windows 95 1 4 0
1046-
Windows 98 1 4 10
1047-
Windows Me 1 4 90
1048-
1049-
Windows NT 3.51 2 3 51
1050-
Windows NT 4 2 4 0
1051-
1052-
Windows 2000 2 5 0
1053-
Windows XP 2 5 1
1054-
Windows Server 2003 2 5 2
1055-
Windows Server 2003 R2 2 5 2
1056-
Windows Home Server 2 5 2
1057-
1058-
Windows Vista 2 6 0
1059-
Windows Server 2008 2 6 0
1060-
Windows 7 2 6 1
1061-
Windows Server 2008 R2 2 6 1
1062-
Windows 8 2 6 2
1063-
Windows Server 2012 2 6 2
1064-
1087+
Currently known values for ID MAJOR MINOR and BUILD are as follows:
1088+
1089+
OS ID MAJOR MINOR BUILD
1090+
Win32s 0 - - -
1091+
Windows 95 1 4 0 -
1092+
Windows 98 1 4 10 -
1093+
Windows Me 1 4 90 -
1094+
1095+
Windows NT 3.51 2 3 51 -
1096+
Windows NT 4 2 4 0 -
1097+
1098+
Windows 2000 2 5 0 -
1099+
Windows XP 2 5 1 -
1100+
Windows Server 2003 2 5 2 -
1101+
Windows Server 2003 R2 2 5 2 -
1102+
Windows Home Server 2 5 2 -
1103+
1104+
Windows Vista 2 6 0 -
1105+
Windows Server 2008 2 6 0 -
1106+
Windows 7 2 6 1 -
1107+
Windows Server 2008 R2 2 6 1 -
1108+
Windows 8 2 6 2 -
1109+
Windows Server 2012 2 6 2 -
1110+
Windows 8.1 2 6 2 -
1111+
Windows Server 2012 R2 2 6 2 -
1112+
1113+
Windows 10 2 10 0 -
1114+
Windows Server 2016 2 10 0 14393
1115+
Windows Server 2019 2 10 0 17677
1116+
10651117
On Windows NT 4 SP6 and later this function returns the following
10661118
additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.
10671119
@@ -1081,8 +1133,14 @@ The version numbers for Windows 8 and Windows Server 2012 are
10811133
identical; the PRODUCTTYPE field must be used to differentiate between
10821134
them.
10831135
1136+
For modern Windows releases, the major and minor version numbers are
1137+
identical. The PRODUCTTYPE field must be used to differentiate between
1138+
Windows 10 and Server releases. The BUILD field is used to
1139+
differentiate Windows Server versions: currently 2016, 2019, and
1140+
Semi-Annual Channel releases.
1141+
10841142
SPMAJOR and SPMINOR are the version numbers of the latest
1085-
installed service pack.
1143+
installed service pack. (In the Windows 10 era, these are unused.)
10861144
10871145
SUITEMASK is a bitfield identifying the product suites available on
10881146
the system. Known bits are:
@@ -1103,6 +1161,7 @@ the system. Known bits are:
11031161
VER_SUITE_STORAGE_SERVER 0x00002000
11041162
VER_SUITE_COMPUTE_SERVER 0x00004000
11051163
VER_SUITE_WH_SERVER 0x00008000
1164+
VER_SUITE_MULTIUSERTS 0x00020000
11061165
11071166
The VER_SUITE_xxx names are listed here to cross reference the Microsoft
11081167
documentation. The Win32 module does not provide symbolic names for these

t/GetOSName.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ my @dual_tests = (
107107
["8.1", "8.1", 2, 6, 3 ],
108108
["2012 [R2]", "2012", 2, 6, 3, 0x00, 2, 89 ],
109109

110-
["10", "10", 2, 10, 0 ],
110+
["10", "10", 2, 10, 0, 0x00, 2, 89 ],
111+
["2016", "2016", 2, 10, 0, 0x00, 2, 89 ],
112+
["2019", "2019", 2, 10, 0, 0x00, 2, 89 ],
111113

112114
);
113115

0 commit comments

Comments
 (0)