Etc.uname: Report the actual Windows version

GetVersionEx reports 6.2.9200 on Windows 8.1 and later unless the manifest of the executable declares them as supported, and ruby.manifest does not. RtlGetVersion is not affected by the manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5.5 committed 2026-09-27 14:30:49 +09:00
1 parent 41349bb1e8
commit f6ff9e7d02
2 files changed
+11 -2
Notes: git 2026-09-27 05:31:20 +00:00

No files matched your search

+6 -2
View File
@@ -800,6 +800,8 @@ static VALUE
etc_uname(VALUE obj)
{
#ifdef _WIN32
typedef long (WINAPI version_func)(OSVERSIONINFOW *);
version_func *pRtlGetVersion;
OSVERSIONINFOW v;
SYSTEM_INFO s;
const char *sysname, *mach;
@@ -808,9 +810,11 @@ etc_uname(VALUE obj)
DWORD len = 0;
WCHAR *buf;
/* GetVersionEx reports 6.2 unless the manifest declares Windows 8.1 or later */
pRtlGetVersion = (version_func *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion");
v.dwOSVersionInfoSize = sizeof(v);
if (!GetVersionExW(&v))
rb_sys_fail("GetVersionEx");
if (!pRtlGetVersion || pRtlGetVersion(&v))
rb_notimplement();
result = rb_hash_new();
sysname = "Windows_NT";
+5
View File
@@ -131,6 +131,11 @@ class TestEtc < Test::Unit::TestCase
}
end
def test_uname_release_on_windows
release = IO.popen(%w[cmd.exe /c ver], "rb", &:read)[/\d+\.\d+\.\d+/]
assert_equal(release, Etc.uname[:release])
end if /mswin|mingw/ =~ RUBY_PLATFORM
def test_sysconf
begin
Etc.sysconf