Skip to content

Commit 60cc43a

Browse files
committed
Update info.c
Fixes #67407: Windows 8.1/Server 2012 R2 reported as Windows 8/Server 2012
1 parent ab074b4 commit 60cc43a

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

ext/standard/info.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,37 @@ char* php_get_windows_name()
335335
major = "Windows Server 2008 R2";
336336
}
337337
} else if ( osvi.dwMinorVersion == 2 ) {
338-
if( osvi.wProductType == VER_NT_WORKSTATION ) {
339-
major = "Windows 8";
338+
/* could be Windows 8/Windows Server 2012, could be Windows 8.1/Windows Server 2012 R2 */
339+
OSVERSIONINFOEX osvi81;
340+
DWORDLONG dwlConditionMask = 0;
341+
int op = VER_GREATER_EQUAL;
342+
343+
ZeroMemory(&osvi81, sizeof(OSVERSIONINFOEX));
344+
osvi81.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
345+
osvi81.dwMajorVersion = 6;
346+
osvi81.dwMinorVersion = 3;
347+
osvi81.wServicePackMajor = 0;
348+
349+
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
350+
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op);
351+
VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR, op);
352+
353+
if (VerifyVersionInfo(&osvi81,
354+
VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
355+
dwlConditionMask)) {
356+
osvi.dwMinorVersion = 3; /* Windows 8.1/Windows Server 2012 R2 */
357+
if( osvi.wProductType == VER_NT_WORKSTATION ) {
358+
major = "Windows 8.1";
359+
} else {
360+
major = "Windows Server 2012 R2";
361+
}
340362
} else {
341-
major = "Windows Server 2012";
342-
}
363+
if( osvi.wProductType == VER_NT_WORKSTATION ) {
364+
major = "Windows 8";
365+
} else {
366+
major = "Windows Server 2012";
367+
}
368+
}
343369
} else {
344370
major = "Unknown Windows version";
345371
}

0 commit comments

Comments
 (0)