Bugfix for OS detection

* Avoids CurrentBuild collision between Win8 and Win8.1
* Fix DisplayName formatting
This commit is contained in:
2Shirt 2018-05-13 16:09:07 -06:00
parent ee2bcd5aea
commit 18c535dcfd
2 changed files with 15 additions and 3 deletions

View file

@ -616,12 +616,21 @@ def check_os():
# Query registry
path = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
with winreg.OpenKey(HKLM, path) as key:
for name in ['CurrentBuild', 'ProductName']:
for name in ['CurrentBuild', 'CurrentVersion', 'ProductName']:
try:
tmp[name] = winreg.QueryValueEx(key, name)[0]
except FileNotFoundError:
tmp[name] = 'Unknown'
# Handle CurrentBuild collision
if tmp['CurrentBuild'] == '9200':
if tmp['CurrentVersion'] == '6.2':
# Windown 8, set to fake build number
tmp['CurrentBuild'] = '9199'
else:
# Windows 8.1, leave alone
pass
# Check bit depth
tmp['Arch'] = 32
if 'PROGRAMFILES(X86)' in global_vars['Env']:
@ -631,6 +640,7 @@ def check_os():
build_info = WINDOWS_BUILDS.get(
tmp['CurrentBuild'],
('Unknown', 'Build {}'.format(tmp['CurrentBuild']), None, None, 'unrecognized'))
build_info = list(build_info)
tmp['Version'] = build_info.pop(0)
tmp['Release'] = build_info.pop(0)
tmp['Codename'] = build_info.pop(0)
@ -650,7 +660,7 @@ def check_os():
# Set display name
tmp['DisplayName'] = '{} x{}'.format(tmp['Name'], tmp['Arch'])
if tmp['Notes']:
tmp['Name'] += ' ({})'.format(tmp['Notes'])
tmp['DisplayName'] += ' ({})'.format(tmp['Notes'])
global_vars['OS'] = tmp

View file

@ -10,7 +10,9 @@ WINDOWS_BUILDS = {
'7600': ( '7', 'RTM', 'Vienna', None, 'unsupported'),
'7601': ( '7', 'SP1', 'Vienna', None, 'outdated'),
'9200': ( '8', 'RTM', None, None, 'unsupported'),
#9199 is a fake build since Win 8 is 6.2.9200 but that collides with Win 8.1 (6.3.9200)
'9199': ( '8', 'RTM', None, None, 'unsupported'),
'9200': ( '8.1', None, 'Blue', None, 'outdated'),
'9600': ( '8.1', None, 'Update', None, None),