Chromium Code Reviews| 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..f4f8725915032da51d7e23fc9b61dc0e68c246f4 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 & 0xffff0000) >> 16; |
| + *version_1 = ffi.dwFileVersionMS & 0xffff; |
| + *version_2 = (ffi.dwFileVersionLS & 0xffff0000) >> 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,18 +117,38 @@ 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 & 0xffff0000) >> 16; |
| + *version_1 = ffi.dwProductVersionMS & 0xffff; |
| + *version_2 = (ffi.dwProductVersionLS & 0xffff0000) >> 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 { |
| INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| - CHECK(false) << "TODO(scottmg)"; |
| + // TODO(scottmg): Not sure if there's anything equivalent on Windows. |
|
Robert Sesek
2015/05/12 22:44:57
This would be the UUID for the PDB.
scottmg
2015/05/12 23:28:38
Ah, so it is, I should have looked at the writer.
|
| + *uuid = crashpad::UUID(); |
| } |
| std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { |