Commit e93de3a3 authored by Alan Screen's avatar Alan Screen Committed by Commit Bot

Export Windows file version as base::Version

The Windows VS_FIXEDFILEINFO structure includes fields to represent the
version number of a file.  Allow these to be provided as a standard
base::Version object.

Update base::FileVersionInfoWin to make use of this API update.

Drop exposure of internal VS_FIXEDFILEINFO structure, and propagate
cleanup to gpu/config to use cleaned up API.

Bug: 1008222
Change-Id: I94beaf8f8d2d3d90ebb19c3c44acacf7027903f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828219
Commit-Queue: Alan Screen <awscreen@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702015}
parent 3ef54bb4
...@@ -183,6 +183,14 @@ base::string16 FileVersionInfoWin::GetStringValue(const base::char16* name) { ...@@ -183,6 +183,14 @@ base::string16 FileVersionInfoWin::GetStringValue(const base::char16* name) {
return base::string16(); return base::string16();
} }
base::Version FileVersionInfoWin::GetFileVersion() const {
return base::Version(
std::vector<uint32_t>{HIWORD(fixed_file_info_->dwFileVersionMS),
LOWORD(fixed_file_info_->dwFileVersionMS),
HIWORD(fixed_file_info_->dwFileVersionLS),
LOWORD(fixed_file_info_->dwFileVersionLS)});
}
FileVersionInfoWin::FileVersionInfoWin(std::vector<uint8_t>&& data, FileVersionInfoWin::FileVersionInfoWin(std::vector<uint8_t>&& data,
WORD language, WORD language,
WORD code_page) WORD code_page)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/base_export.h" #include "base/base_export.h"
#include "base/file_version_info.h" #include "base/file_version_info.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/version.h"
struct tagVS_FIXEDFILEINFO; struct tagVS_FIXEDFILEINFO;
typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO;
...@@ -44,8 +45,8 @@ class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo { ...@@ -44,8 +45,8 @@ class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo {
// does not exist). // does not exist).
base::string16 GetStringValue(const base::char16* name); base::string16 GetStringValue(const base::char16* name);
// Get the fixed file info if it exists. Otherwise NULL // Get file version number in dotted version format.
const VS_FIXEDFILEINFO* fixed_file_info() const { return fixed_file_info_; } base::Version GetFileVersion() const;
// Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin. // Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin.
static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin( static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin(
......
...@@ -152,4 +152,7 @@ TYPED_TEST(FileVersionInfoTest, CustomProperties) { ...@@ -152,4 +152,7 @@ TYPED_TEST(FileVersionInfoTest, CustomProperties) {
version_info_win->GetValue(STRING16_LITERAL("Unknown property"), &str)); version_info_win->GetValue(STRING16_LITERAL("Unknown property"), &str));
EXPECT_EQ(base::string16(), version_info_win->GetStringValue( EXPECT_EQ(base::string16(), version_info_win->GetStringValue(
STRING16_LITERAL("Unknown property"))); STRING16_LITERAL("Unknown property")));
EXPECT_EQ(base::Version(std::vector<uint32_t>{1, 0, 0, 1}),
version_info_win->GetFileVersion());
} }
...@@ -214,15 +214,7 @@ base::Version OSInfo::Kernel32BaseVersion() const { ...@@ -214,15 +214,7 @@ base::Version OSInfo::Kernel32BaseVersion() const {
FilePath(FILE_PATH_LITERAL("kernelbase.dll"))); FilePath(FILE_PATH_LITERAL("kernelbase.dll")));
} }
CHECK(file_version_info); CHECK(file_version_info);
const int major = return file_version_info->GetFileVersion();
HIWORD(file_version_info->fixed_file_info()->dwFileVersionMS);
const int minor =
LOWORD(file_version_info->fixed_file_info()->dwFileVersionMS);
const int build =
HIWORD(file_version_info->fixed_file_info()->dwFileVersionLS);
const int patch =
LOWORD(file_version_info->fixed_file_info()->dwFileVersionLS);
return base::Version(std::vector<uint32_t>{major, minor, build, patch});
}()); }());
return *version; return *version;
} }
......
...@@ -229,21 +229,13 @@ bool BadAMDVulkanDriverVersion() { ...@@ -229,21 +229,13 @@ bool BadAMDVulkanDriverVersion() {
return false; return false;
} }
const VS_FIXEDFILEINFO* fixed_file_info =
file_version_info->fixed_file_info();
const int major = HIWORD(fixed_file_info->dwFileVersionMS);
const int minor = LOWORD(fixed_file_info->dwFileVersionMS);
const int minor_1 = HIWORD(fixed_file_info->dwFileVersionLS);
// From the Canary crash logs, the broken amdvlk64.dll versions // From the Canary crash logs, the broken amdvlk64.dll versions
// are 1.0.39.0, 1.0.51.0 and 1.0.54.0. In the manual test, version // are 1.0.39.0, 1.0.51.0 and 1.0.54.0. In the manual test, version
// 9.2.10.1 dated 12/6/2017 works and version 1.0.54.0 dated 11/2/1017 // 9.2.10.1 dated 12/6/2017 works and version 1.0.54.0 dated 11/2/1017
// crashes. All version numbers small than 1.0.54.0 will be marked as // crashes. All version numbers small than 1.0.54.0 will be marked as
// broken. // broken.
if (major == 1 && minor == 0 && minor_1 <= 54) { const base::Version kBadAMDVulkanDriverVersion("1.0.54.0");
return true; return file_version_info->GetFileVersion() <= kBadAMDVulkanDriverVersion;
}
return false;
} }
bool BadVulkanDllVersion() { bool BadVulkanDllVersion() {
...@@ -253,13 +245,6 @@ bool BadVulkanDllVersion() { ...@@ -253,13 +245,6 @@ bool BadVulkanDllVersion() {
if (!file_version_info) if (!file_version_info)
return false; return false;
const VS_FIXEDFILEINFO* fixed_file_info =
file_version_info->fixed_file_info();
const int major = HIWORD(fixed_file_info->dwFileVersionMS);
const int minor = LOWORD(fixed_file_info->dwFileVersionMS);
const int build_1 = HIWORD(fixed_file_info->dwFileVersionLS);
const int build_2 = LOWORD(fixed_file_info->dwFileVersionLS);
// From the logs, most vulkan-1.dll crashs are from the following versions. // From the logs, most vulkan-1.dll crashs are from the following versions.
// As of 7/23/2018. // As of 7/23/2018.
// 0.0.0.0 - # of crashes: 6556 // 0.0.0.0 - # of crashes: 6556
...@@ -271,13 +256,12 @@ bool BadVulkanDllVersion() { ...@@ -271,13 +256,12 @@ bool BadVulkanDllVersion() {
// The GPU could be from any vendor, but only some certain models would crash. // The GPU could be from any vendor, but only some certain models would crash.
// For those that don't crash, they usually return failures upon GPU vulkan // For those that don't crash, they usually return failures upon GPU vulkan
// support querying even though the GPU drivers can support it. // support querying even though the GPU drivers can support it.
if ((major == 0 && minor == 0 && build_1 == 0 && build_2 == 0) || base::Version fv = file_version_info->GetFileVersion();
(major == 1 && minor == 0 && build_1 == 26 && build_2 == 0) || const char* const kBadVulkanDllVersion[] = {
(major == 1 && minor == 0 && build_1 == 33 && build_2 == 0) || "0.0.0.0", "1.0.26.0", "1.0.33.0", "1.0.42.0", "1.0.42.1", "1.0.51.0"};
(major == 1 && minor == 0 && build_1 == 42 && build_2 == 0) || for (const char* bad_version : kBadVulkanDllVersion) {
(major == 1 && minor == 0 && build_1 == 42 && build_2 == 1) || if (fv == base::Version(bad_version))
(major == 1 && minor == 0 && build_1 == 51 && build_2 == 0)) { return true;
return true;
} }
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment