Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: base/win/windows_version.cc

Issue 2506523002: Report Windows build and patch number in the component updater checks. (Closed)
Patch Set: static constexpr Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/win/windows_version.h ('k') | components/update_client/utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/windows_version.h" 5 #include "base/win/windows_version.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 LOWORD(file_version_info->fixed_file_info()->dwFileVersionMS); 76 LOWORD(file_version_info->fixed_file_info()->dwFileVersionMS);
77 const int build = 77 const int build =
78 HIWORD(file_version_info->fixed_file_info()->dwFileVersionLS); 78 HIWORD(file_version_info->fixed_file_info()->dwFileVersionLS);
79 return MajorMinorBuildToVersion(major, minor, build); 79 return MajorMinorBuildToVersion(major, minor, build);
80 } 80 }
81 81
82 NOTREACHED(); 82 NOTREACHED();
83 return VERSION_WIN_LAST; 83 return VERSION_WIN_LAST;
84 } 84 }
85 85
86 // Returns the the "UBR" value from the registry. Introduced in Windows 10,
87 // this undocumented value appears to be similar to a patch number.
88 // Returns 0 if the value does not exist or it could not be read.
89 int GetUBR() {
90 // The values under the CurrentVersion registry hive are mirrored under
91 // the corresponding Wow6432 hive.
92 static constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] =
93 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
94
95 base::win::RegKey key;
96 if (key.Open(HKEY_LOCAL_MACHINE, kRegKeyWindowsNTCurrentVersion,
97 KEY_QUERY_VALUE) != ERROR_SUCCESS) {
98 return 0;
99 }
100
101 DWORD ubr = 0;
102 key.ReadValueDW(L"UBR", &ubr);
103
104 return static_cast<int>(ubr);
105 }
106
86 } // namespace 107 } // namespace
87 108
88 // static 109 // static
89 OSInfo* OSInfo::GetInstance() { 110 OSInfo* OSInfo::GetInstance() {
90 // Note: we don't use the Singleton class because it depends on AtExitManager, 111 // Note: we don't use the Singleton class because it depends on AtExitManager,
91 // and it's convenient for other modules to use this classs without it. This 112 // and it's convenient for other modules to use this classs without it. This
92 // pattern is copied from gurl.cc. 113 // pattern is copied from gurl.cc.
93 static OSInfo* info; 114 static OSInfo* info;
94 if (!info) { 115 if (!info) {
95 OSInfo* new_info = new OSInfo(); 116 OSInfo* new_info = new OSInfo();
96 if (InterlockedCompareExchangePointer( 117 if (InterlockedCompareExchangePointer(
97 reinterpret_cast<PVOID*>(&info), new_info, NULL)) { 118 reinterpret_cast<PVOID*>(&info), new_info, NULL)) {
98 delete new_info; 119 delete new_info;
99 } 120 }
100 } 121 }
101 return info; 122 return info;
102 } 123 }
103 124
104 OSInfo::OSInfo() 125 OSInfo::OSInfo()
105 : version_(VERSION_PRE_XP), 126 : version_(VERSION_PRE_XP),
106 kernel32_version_(VERSION_PRE_XP), 127 kernel32_version_(VERSION_PRE_XP),
107 got_kernel32_version_(false), 128 got_kernel32_version_(false),
108 architecture_(OTHER_ARCHITECTURE), 129 architecture_(OTHER_ARCHITECTURE),
109 wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) { 130 wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) {
110 OSVERSIONINFOEX version_info = { sizeof version_info }; 131 OSVERSIONINFOEX version_info = { sizeof version_info };
111 ::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); 132 ::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
112 version_number_.major = version_info.dwMajorVersion; 133 version_number_.major = version_info.dwMajorVersion;
113 version_number_.minor = version_info.dwMinorVersion; 134 version_number_.minor = version_info.dwMinorVersion;
114 version_number_.build = version_info.dwBuildNumber; 135 version_number_.build = version_info.dwBuildNumber;
136 version_number_.patch = GetUBR();
115 version_ = MajorMinorBuildToVersion( 137 version_ = MajorMinorBuildToVersion(
116 version_number_.major, version_number_.minor, version_number_.build); 138 version_number_.major, version_number_.minor, version_number_.build);
117 service_pack_.major = version_info.wServicePackMajor; 139 service_pack_.major = version_info.wServicePackMajor;
118 service_pack_.minor = version_info.wServicePackMinor; 140 service_pack_.minor = version_info.wServicePackMinor;
119 service_pack_str_ = base::WideToUTF8(version_info.szCSDVersion); 141 service_pack_str_ = base::WideToUTF8(version_info.szCSDVersion);
120 142
121 SYSTEM_INFO system_info = {}; 143 SYSTEM_INFO system_info = {};
122 ::GetNativeSystemInfo(&system_info); 144 ::GetNativeSystemInfo(&system_info);
123 switch (system_info.wProcessorArchitecture) { 145 switch (system_info.wProcessorArchitecture) {
124 case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break; 146 case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return WOW64_UNKNOWN; 244 return WOW64_UNKNOWN;
223 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; 245 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED;
224 } 246 }
225 247
226 Version GetVersion() { 248 Version GetVersion() {
227 return OSInfo::GetInstance()->version(); 249 return OSInfo::GetInstance()->version();
228 } 250 }
229 251
230 } // namespace win 252 } // namespace win
231 } // namespace base 253 } // namespace base
OLDNEW
« no previous file with comments | « base/win/windows_version.h ('k') | components/update_client/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698