win: Don't warn when no VERSIONINFO resource is present in a module

Modules will work without a VERSIONINFO resource. This happens in some
of Crashpad's tests.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1467993003 .
This commit is contained in:
Mark Mentovai 2015-11-23 16:17:50 -05:00
parent f5c4273d4f
commit 116e1087f0
2 changed files with 28 additions and 25 deletions

View File

@ -26,30 +26,31 @@ bool GetModuleVersionAndType(const base::FilePath& path,
VS_FIXEDFILEINFO* vs_fixedfileinfo) {
DWORD size = GetFileVersionInfoSize(path.value().c_str(), nullptr);
if (!size) {
PLOG(WARNING) << "GetFileVersionInfoSize: "
<< base::UTF16ToUTF8(path.value());
} else {
scoped_ptr<uint8_t[]> data(new uint8_t[size]);
if (!GetFileVersionInfo(path.value().c_str(), 0, size, data.get())) {
PLOG(WARNING) << "GetFileVersionInfo: "
<< base::UTF16ToUTF8(path.value());
} else {
VS_FIXEDFILEINFO* fixed_file_info;
UINT ffi_size;
if (!VerQueryValue(data.get(),
L"\\",
reinterpret_cast<void**>(&fixed_file_info),
&ffi_size)) {
PLOG(WARNING) << "VerQueryValue";
} else {
*vs_fixedfileinfo = *fixed_file_info;
vs_fixedfileinfo->dwFileFlags &= vs_fixedfileinfo->dwFileFlagsMask;
return true;
}
}
PLOG_IF(WARNING, GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND)
<< "GetFileVersionInfoSize: " << base::UTF16ToUTF8(path.value());
return false;
}
return false;
scoped_ptr<uint8_t[]> data(new uint8_t[size]);
if (!GetFileVersionInfo(path.value().c_str(), 0, size, data.get())) {
PLOG(WARNING) << "GetFileVersionInfo: "
<< base::UTF16ToUTF8(path.value());
return false;
}
VS_FIXEDFILEINFO* fixed_file_info;
UINT ffi_size;
if (!VerQueryValue(data.get(),
L"\\",
reinterpret_cast<void**>(&fixed_file_info),
&ffi_size)) {
PLOG(WARNING) << "VerQueryValue";
return false;
}
*vs_fixedfileinfo = *fixed_file_info;
vs_fixedfileinfo->dwFileFlags &= vs_fixedfileinfo->dwFileFlagsMask;
return true;
}
} // namespace crashpad

View File

@ -25,10 +25,12 @@ namespace crashpad {
//! dll, etc.)
//!
//! \param[in] path The path to the module to be inspected.
//! \param[out] vs_fixedfileinfo The VS_FIXEDFILEINFO on success. `dwFileFlags`
//! will have been masked with `dwFileFlagsMask` already.
//! \param[out] vs_fixedfileinfo The `VS_FIXEDFILEINFO` on success.
//! `dwFileFlags` will have been masked with `dwFileFlagsMask` already.
//!
//! \return `true` on success, or `false` on failure with a message logged.
//! \return `true` on success, or `false` on failure with a message logged. If
//! the module has no `VERSIONINFO` resource, `false` will be returned
//! without any messages logged.
bool GetModuleVersionAndType(const base::FilePath& path,
VS_FIXEDFILEINFO* vs_fixedfileinfo);