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

Unified Diff: snapshot/win/module_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.h ('k') | snapshot/win/system_snapshot_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/module_snapshot_win.cc
diff --git a/snapshot/win/module_snapshot_win.cc b/snapshot/win/module_snapshot_win.cc
index c3f915f8b4b70185ee62048be52069a73574d250..77a8e037524762f5325e9615d8107f6499fbdff6 100644
--- a/snapshot/win/module_snapshot_win.cc
+++ b/snapshot/win/module_snapshot_win.cc
@@ -18,6 +18,7 @@
#include "snapshot/win/pe_image_reader.h"
#include "util/misc/tri_state.h"
#include "util/misc/uuid.h"
+#include "util/win/module_version.h"
namespace crashpad {
namespace internal {
@@ -39,13 +40,13 @@ bool ModuleSnapshotWin::Initialize(
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
process_reader_ = process_reader;
- name_ = base::UTF16ToUTF8(process_reader_module.name);
+ name_ = process_reader_module.name;
timestamp_ = process_reader_module.timestamp;
pe_image_reader_.reset(new PEImageReader());
if (!pe_image_reader_->Initialize(process_reader_,
process_reader_module.dll_base,
process_reader_module.size,
- name_)) {
+ base::UTF16ToUTF8(name_))) {
return false;
}
@@ -74,7 +75,7 @@ void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) {
std::string ModuleSnapshotWin::Name() const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
- return name_;
+ return base::UTF16ToUTF8(name_);
}
uint64_t ModuleSnapshotWin::Address() const {
@@ -97,7 +98,18 @@ void ModuleSnapshotWin::FileVersion(uint16_t* version_0,
uint16_t* version_2,
uint16_t* version_3) const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
- CHECK(false) << "TODO(scottmg)";
+ VS_FIXEDFILEINFO ffi;
+ if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) {
+ *version_0 = ffi.dwFileVersionMS >> 16;
+ *version_1 = ffi.dwFileVersionMS & 0xffff;
+ *version_2 = ffi.dwFileVersionLS >> 16;
+ *version_3 = ffi.dwFileVersionLS & 0xffff;
+ } else {
+ *version_0 = 0;
+ *version_1 = 0;
+ *version_2 = 0;
+ *version_3 = 0;
+ }
}
void ModuleSnapshotWin::SourceVersion(uint16_t* version_0,
@@ -105,13 +117,32 @@ void ModuleSnapshotWin::SourceVersion(uint16_t* version_0,
uint16_t* version_2,
uint16_t* version_3) const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
- CHECK(false) << "TODO(scottmg)";
+ VS_FIXEDFILEINFO ffi;
+ if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) {
+ *version_0 = ffi.dwProductVersionMS >> 16;
+ *version_1 = ffi.dwProductVersionMS & 0xffff;
+ *version_2 = ffi.dwProductVersionLS >> 16;
+ *version_3 = ffi.dwProductVersionLS & 0xffff;
+ } else {
+ *version_0 = 0;
+ *version_1 = 0;
+ *version_2 = 0;
+ *version_3 = 0;
+ }
}
ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
- CHECK(false) << "TODO(scottmg)";
- return ModuleSnapshot::ModuleType();
+ VS_FIXEDFILEINFO ffi;
+ if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) {
+ if (ffi.dwFileType == VFT_APP)
+ return ModuleSnapshot::kModuleTypeExecutable;
+ if (ffi.dwFileType == VFT_DLL)
+ return ModuleSnapshot::kModuleTypeSharedLibrary;
+ if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD)
+ return ModuleSnapshot::kModuleTypeLoadableModule;
+ }
+ return ModuleSnapshot::kModuleTypeUnknown;
}
void ModuleSnapshotWin::UUID(crashpad::UUID* uuid) const {
« no previous file with comments | « snapshot/win/module_snapshot_win.h ('k') | snapshot/win/system_snapshot_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698