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

Unified Diff: snapshot/win/system_snapshot_win.cc

Issue 1126273003: win: Retrieve module version/type information (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@thread-context-fixes
Patch Set: rebase Created 5 years, 7 months 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 | « snapshot/win/module_snapshot_win.cc ('k') | util/util.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/system_snapshot_win.cc
diff --git a/snapshot/win/system_snapshot_win.cc b/snapshot/win/system_snapshot_win.cc
index 5e24211a2ddb27cb70249dd2df0d0dca715051ed..a7523f48449d90192333071db002fb6d52d00899 100644
--- a/snapshot/win/system_snapshot_win.cc
+++ b/snapshot/win/system_snapshot_win.cc
@@ -23,10 +23,10 @@
#include <utility>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "util/win/module_version.h"
namespace crashpad {
@@ -95,45 +95,25 @@ void SystemSnapshotWin::Initialize(ProcessReaderWin* process_reader) {
PLOG(WARNING) << "GetVersionEx";
} else {
const wchar_t kSystemDll[] = L"kernel32.dll";
- DWORD size = GetFileVersionInfoSize(kSystemDll, nullptr);
- if (!size) {
- PLOG(WARNING) << "GetFileVersionInfoSize";
- } else {
- scoped_ptr<uint8_t[]> data(new uint8_t[size]);
- if (!GetFileVersionInfo(kSystemDll, 0, size, data.get())) {
- PLOG(WARNING) << "GetFileVersionInfo";
- } else {
- VS_FIXEDFILEINFO* fixed_file_info;
- UINT size;
- if (!VerQueryValue(data.get(),
- L"\\",
- reinterpret_cast<void**>(&fixed_file_info),
- &size)) {
- PLOG(WARNING) << "VerQueryValue";
- } else {
- uint32_t valid_flags =
- fixed_file_info->dwFileFlags & fixed_file_info->dwFileFlagsMask;
- std::string flags_string = GetStringForFileFlags(valid_flags);
- os_version_major_ =
- (fixed_file_info->dwFileVersionMS & 0xffff0000) >> 16;
- os_version_minor_ = fixed_file_info->dwFileVersionMS & 0xffff;
- os_version_bugfix_ =
- (fixed_file_info->dwFileVersionLS & 0xffff0000) >> 16;
- os_version_build_ = base::StringPrintf(
- "%d", fixed_file_info->dwFileVersionLS & 0xffff);
- os_server_ = version_info.wProductType != VER_NT_WORKSTATION;
- std::string os_name = GetStringForFileOS(fixed_file_info->dwFileOS);
- os_version_full_ = base::StringPrintf(
- "%s %d.%d.%d.%s%s",
- os_name.c_str(),
- os_version_major_,
- os_version_minor_,
- os_version_bugfix_,
- os_version_build_.c_str(),
- flags_string.empty() ? "" : (std::string(" (") + flags_string +
- ")").c_str());
- }
- }
+ VS_FIXEDFILEINFO ffi;
+ if (GetModuleVersionAndType(base::FilePath(kSystemDll), &ffi)) {
+ std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags);
+ os_server_ = version_info.wProductType != VER_NT_WORKSTATION;
+ std::string os_name = GetStringForFileOS(ffi.dwFileOS);
+ os_version_major_ = ffi.dwFileVersionMS >> 16;
+ os_version_minor_ = ffi.dwFileVersionMS & 0xffff;
+ os_version_bugfix_ = ffi.dwFileVersionLS >> 16;
+ os_version_build_ =
+ base::StringPrintf("%d", ffi.dwFileVersionLS & 0xffff);
+ os_version_full_ = base::StringPrintf(
+ "%s %d.%d.%d.%s%s",
+ os_name.c_str(),
+ os_version_major_,
+ os_version_minor_,
+ os_version_bugfix_,
+ os_version_build_.c_str(),
+ flags_string.empty() ? "" : (std::string(" (") + flags_string + ")")
+ .c_str());
}
}
« no previous file with comments | « snapshot/win/module_snapshot_win.cc ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698