[newlib-cygwin] Overwite potentially faked kernel version with correct values
Corinna Vinschen
corinna@sourceware.org
Wed Mar 9 22:10:00 GMT 2016
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=48511f3d3847c35352d09cded56e25f0c1b22bc9
commit 48511f3d3847c35352d09cded56e25f0c1b22bc9
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Mar 9 23:10:17 2016 +0100
Overwite potentially faked kernel version with correct values
* ntdll.h (RtlGetNtVersionNumbers): Declare.
* wincap.cc (wincapc::init): Overwrite kernel version info
returned by RtlGetVersion with correct info returnd by
RtlGetNtVersionNumbers. Add comment.
Originally, using RtlGetVersion instead of GetVersionEx was supposed to
fix the fact that GetVersionInfo returns the wrong kernel version if the
executable has been built with an old manifest (or none at all), starting
with Windows 8.1. Either this never really worked as desired and our
testing was flawed, or this has been changed again with Windows 10, so
that RtlGetVersion does the kernel faking twist as well. Since we're
only reading the value in the first process in a process tree. the entire
process tree is running with a wrong OS version information in that case.
Fortunately, the (undocumented) RtlGetNtVersionNumbers function is not
affected by this nonsense, so we simply override the OS version info
fields with the correct values now.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/ntdll.h | 1 +
winsup/cygwin/wincap.cc | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 5cc7c46..2792112 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -1452,6 +1452,7 @@ extern "C"
PACL *, PBOOLEAN);
NTSTATUS NTAPI RtlGetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR, PSID *,
PBOOLEAN);
+ NTSTATUS NTAPI RtlGetNtVersionNumbers (LPDWORD, LPDWORD, LPDWORD);
NTSTATUS NTAPI RtlGetOwnerSecurityDescriptor (PSECURITY_DESCRIPTOR, PSID *,
PBOOLEAN);
NTSTATUS NTAPI RtlGetVersion (PRTL_OSVERSIONINFOEXW);
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index c7c9f2e..313d7f9 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -276,6 +276,11 @@ wincapc::init ()
GetSystemInfo (&system_info);
version.dwOSVersionInfoSize = sizeof (RTL_OSVERSIONINFOEXW);
RtlGetVersion (&version);
+ /* Overwrite unreliable kernel version with correct values returned by
+ RtlGetNtVersionNumbers. See git log of this change for a description. */
+ RtlGetNtVersionNumbers (&version.dwMajorVersion,
+ &version.dwMinorVersion,
+ &version.dwBuildNumber);
switch (version.dwMajorVersion)
{
More information about the Cygwin-cvs
mailing list