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

Unified Diff: snapshot/win/system_snapshot_win.cc

Issue 1475023004: Get module versions and types from in-memory images (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback (2) Created 5 years 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/process_subrange_reader.cc ('k') | util/numeric/checked_address_range.h » ('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 88827a5d865d54bb652f7da650b8411ebedcc8f0..a62bf5ace153e9af62f0e9b860ae55e73c2b12d2 100644
--- a/snapshot/win/system_snapshot_win.cc
+++ b/snapshot/win/system_snapshot_win.cc
@@ -86,35 +86,37 @@ void SystemSnapshotWin::Initialize(ProcessReaderWin* process_reader) {
process_reader_ = process_reader;
- // We use both GetVersionEx and VerQueryValue. GetVersionEx is not trustworthy
- // after Windows 8 (depending on the application manifest) so its data is used
- // only to fill the os_server_ field, and the rest comes from the version
+ // We use both GetVersionEx() and GetModuleVersionAndType() (which uses
+ // VerQueryValue() internally). GetVersionEx() is not trustworthy after
+ // Windows 8 (depending on the application manifest) so its data is used only
+ // to fill the os_server_ field, and the rest comes from the version
// information stamped on kernel32.dll.
OSVERSIONINFOEX version_info = {sizeof(version_info)};
if (!GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info))) {
PLOG(WARNING) << "GetVersionEx";
} else {
- const wchar_t kSystemDll[] = L"kernel32.dll";
- 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());
- }
+ os_server_ = version_info.wProductType != VER_NT_WORKSTATION;
+ }
+
+ const wchar_t kSystemDll[] = L"kernel32.dll";
+ VS_FIXEDFILEINFO ffi;
+ if (GetModuleVersionAndType(base::FilePath(kSystemDll), &ffi)) {
+ std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags);
+ 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());
}
INITIALIZATION_STATE_SET_VALID(initialized_);
« no previous file with comments | « snapshot/win/process_subrange_reader.cc ('k') | util/numeric/checked_address_range.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698