Bug #69642 [Fbk]: Windows 10 reported as Windows 8 in phpinfo()
| From: | wenz@php.net | Date: | Wed, 27 May 2015 12:47:17 +0000 |
| Subject: | Bug #69642 [Fbk]: Windows 10 reported as Windows 8 in phpinfo() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192914@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69642&edit=1
ID: 69642
Updated by: wenz@php.net
Reported by: wenz@php.net
Summary: Windows 10 reported as Windows 8 in phpinfo()
Status: Feedback
Type: Bug
Package: PHP options/info functions
Operating System: Windows 10
PHP Version: master-Git-2015-05-15 (Git)
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Sorry for the late reply. I did try the manifest approach, but did not get any change in behavior.
Maybe there is a way to embed the manifest in the executable, but I did not succeed in doing so.
The file version approach sounds good. I am trying a similar approach in my (non-functional) patch,
but the link you posted looks very promising. Will probably try that tomorrow.
Previous Comments:
------------------------------------------------------------------------
[2015-05-27 12:30:20] ab@php.net
@wenz, ping, were you able to verify the snippets to read file versions?
Thanks.
------------------------------------------------------------------------
[2015-05-20 19:42:44] ab@php.net
I was a bit rambling around on this matter and tripped over this blog http://blogs.msdn.com/b/chuckw/archive/2013/09/10/manifest-madness.aspx
. Theoretically, we could try to create manifests. The current makefile is already prepared for
that, it there's a file with a suffix .manifest, it'll be taken automatically. Say, having
x64\Release_TS\php7ts.dll, a file x64\Release_TS\php7ts.dll.manifest would be picked up
automatically if exists. I've tried this but it was still delivering 6.2 under win8.1.
Notsure, maybe you'll have more luck :) But we should check this carefully, not that it'd
need some digital signatures or alike, that were bad.
Another resource - to the possibility of reading file versions. A worky example can be found here https://support.microsoft.com/en-us/kb/167597/
. With that, I saw outputs like 10,0,10074,0 on kernel32.dll and user32.dll under win10, and like
6,3,9600,17415 under win8.1. Though this way isn't recommended officially, maybe we could take
it as a very last fallback solution, if nothing else works. At least you could check whether you see
the same as described.
The function IsWindows10OrGreater() didn't want even to link for me, quite strange.
But anyway you're right, we'd better to fix this as early as possible. Possibly also for
PHP5.
Thanks.
------------------------------------------------------------------------
[2015-05-16 22:10:36] wenz@php.net
Since Technical Preview 2 of Windows 10, the version number is (supposedly - with Microsoft you
never know ;-) ) consistently 10.0.
As I wrote the issue with the patch is that it does not work - I somehow cannot use the functions
from version.dll (that's why I have all the if statements). So this needs to be fixed first
before we rearrange the code. I do hope it's a small thing, but except from PHP patches my C
coding ended 15 years ago, so I was hoping someone could take a look.
If the "get functionality from version.dll" stuff eventually works, it should cover
Windows 8.1, Windows Server 2012 R2, Windows 10 and also the upcoming Windows Server 2016. Windows 8
and 7 are already covered by the old API, I did not change that part of the code.
Sorry I am not of more help, but there is anything I can do, please let me know!
------------------------------------------------------------------------
[2015-05-16 19:57:01] ab@php.net
Yeah, I was checking this stuff 1-2 months ago, and the versions delivered was valid win8 only on
win10. So i thought as it's just a preview, it might get better later. So thanks for the patch.
Would this work also on downlevel (mainly win7 and win8)? Need to test that before, otherwise we
could mix the old and new method.
Could you please rewrite the patch so it does early returns instead of those nested ifs? That would
improve the code readability a lot. And, how about backporting to PHP5? Whereby i can take it over
once it's in master.
Thanks.
------------------------------------------------------------------------
[2015-05-15 20:25:09] wenz@php.net
Description:
------------
The phpinfo() output on Windows 8.1 and Windows Server 2012 R2 reports the OS as Windows 8 and
Windows Server 2012.
This is due to the deprecation of GetVersionEx (which we are using) on these platforms - http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074%28v=vs.85%29.aspx
Once we compile the Windows builds with the Visual Studio 2013 compiler and the Windows 8.1 (or
higher) SDK, _NT_TARGET_VERSION=$(_NT_TARGET_VERSION_LATEST) seems to help. Alternatively, we could
use a manifest file, see https://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx.
This would require a change to the build scripts, though. Until we actually do this, we need a
different approach.
VerifyVersionInfo
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms725491%28v=vs.85%29.aspx) looked like the
best solution when I tackled a related but for Windows 8.1 (#67407). However despite Microsoft
originally introducing that function to have an alternative to GetVersionEx, it looks like this
function is deprecated already, see the note at http://blogs.msdn.com/b/chuckw/archive/2014/10/03/windows-10-technical-preview.aspx.
The first technology preview of Windows 10 reported itself as version 6.4, since the second
technology preview Windows 10 identifies itself as 10.0, yet VerifyVersionInfo reports 6.2 here.
Thus, even the isWindows10OrGreater() function from the Windows 10 SDK (which uses VerifyVersionInf)
does not identify Windows 10 correctly if there is no manifest! Incredible ...
Microsoft provides a tiny hint at https://msdn.microsoft.com/en-us/library/windows/desktop/ms724429%28v=vs.85%29.aspx
though: "To obtain the full version number for the operating system, call the
GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll, then call VerQueryValue
to obtain the \\StringFileInfo\\<lang><codepage>\\ProductVersion subblock of the file
version information." I have tried to implement this to the best of my knowledge, but for some
reason I cannot use the GetFileVersionInfoSize() function from version.dll. I hope someone with more
C experience than I have could look at the attached diff. I hope that only a little bit is missing
... I have changed to code so that once the GetFileVersionInfo approach works, it is used for both
Windows 8.1 and Windows 10, making the VerifyVersionInfo call obsolete.
Note: at some point, we should tackle this at a greater scale. I have also thought about using WMI,
but this seems to be overkill. Maybe using a Manifest would be the most feasible option eventually.
I am aware that the final version of Windows 10 has not been released yet. However I guess that PHP
7 will be released close to the release of Windows 10, and it would not look good if our shiny new
version could not detect the new OS version number, so I would like to get that resolved rather
sooner than later.
Please let me know if I can be of any assistance with testing etc.!
Test script:
---------------
<?php
phpinfo(INFO_GENERAL);
Expected result:
----------------
Output contains "Windows 10" on a Windows 10 machine.
Actual result:
--------------
Output contains "Windows 8" (and not 10) on a Windows 10 machine.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69642&edit=1