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

Unified Diff: base/win/windows_version.cc

Issue 2506523002: Report Windows build and patch number in the component updater checks. (Closed)
Patch Set: up to #11 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..39e72721b191c39619a7b24691e8c72214afc189 100644
--- a/base/win/windows_version.cc
+++ b/base/win/windows_version.cc
@@ -83,6 +83,28 @@ 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.
+ constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] =
grt (UTC plus 2) 2016/11/15 20:59:09 "static constexpr ..." so that the string isn't pu
Sorin Jianu 2016/11/15 23:03:29 Done. This had a massive impact, which I admit I
+ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
+ constexpr wchar_t kRegValUBR[] = L"UBR";
+
+ base::win::RegKey key;
+ if (key.Open(HKEY_LOCAL_MACHINE, kRegKeyWindowsNTCurrentVersion,
+ KEY_QUERY_VALUE) != ERROR_SUCCESS) {
+ return 0;
+ }
+
+ DWORD ubr = 0;
+ key.ReadValueDW(kRegValUBR, &ubr);
grt (UTC plus 2) 2016/11/15 20:59:09 nit: i would use L"UBR" directly here since using
Sorin Jianu 2016/11/15 23:03:29 Done.
+
+ return static_cast<int>(ubr);
+}
+
} // namespace
// static
@@ -112,6 +134,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