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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/windows_version.h ('k') | components/update_client/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/windows_version.cc
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc
index 3cf22d8ccdad71f77da35d1310b9b73b7ede46da..8a1c715370396c92017bf1dbab5c2586ebbfa206 100644
--- a/base/win/windows_version.cc
+++ b/base/win/windows_version.cc
@@ -83,6 +83,27 @@ Version GetVersionFromKernel32() {
return VERSION_WIN_LAST;
}
+// Returns the the "UBR" value from the registry. Introduced in Windows 10,
+// this undocumented value appears to be similar to a patch number.
+// Returns 0 if the value does not exist or it could not be read.
+int GetUBR() {
+ // The values under the CurrentVersion registry hive are mirrored under
+ // the corresponding Wow6432 hive.
+ static constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] =
+ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
+
+ base::win::RegKey key;
+ if (key.Open(HKEY_LOCAL_MACHINE, kRegKeyWindowsNTCurrentVersion,
+ KEY_QUERY_VALUE) != ERROR_SUCCESS) {
+ return 0;
+ }
+
+ DWORD ubr = 0;
+ key.ReadValueDW(L"UBR", &ubr);
+
+ return static_cast<int>(ubr);
+}
+
} // namespace
// static
@@ -112,6 +133,7 @@ OSInfo::OSInfo()
version_number_.major = version_info.dwMajorVersion;
version_number_.minor = version_info.dwMinorVersion;
version_number_.build = version_info.dwBuildNumber;
+ version_number_.patch = GetUBR();
version_ = MajorMinorBuildToVersion(
version_number_.major, version_number_.minor, version_number_.build);
service_pack_.major = version_info.wServicePackMajor;
« 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