win: improve accuracy of ProductName between arch (#4191)
uv_os_uname() on Windows queries the registry value "HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" to fill uv_utsname_t. If calling application was compiled for x86 and run on a x86_64 host, that query is redirected to "Computer\HKEY_LOCAL_MACHINE\ SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\ProductName" instead. For whatever reason, the value of 'ProductName' in the 32-bit registry section on 64-bit Windows sometimes differs from the 64-bit equivalent value and is inaccurate (e.g. containing the data "Windows 10 Enterprise" while the 64-bit value accurately contains "Windows 10 Pro"). Adds the 'KEY_WOW64_64KEY' security descriptor when opening the appropriate registry key so that the value of ProductName is always taken from the primary registry on 64-bit systems, regardless of compiled architecture. The descriptor is safely ignored on 32-bit hosts.
This commit is contained in:
parent
93efccf4ee
commit
66160d6973
@ -1506,7 +1506,7 @@ int uv_os_uname(uv_utsname_t* buffer) {
|
|||||||
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE | KEY_WOW64_64KEY,
|
||||||
®istry_key);
|
®istry_key);
|
||||||
|
|
||||||
if (r == ERROR_SUCCESS) {
|
if (r == ERROR_SUCCESS) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user