OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 ModuleSnapshotWin::ModuleSnapshotWin() | 27 ModuleSnapshotWin::ModuleSnapshotWin() |
28 : ModuleSnapshot(), | 28 : ModuleSnapshot(), |
29 name_(), | 29 name_(), |
30 pdb_name_(), | 30 pdb_name_(), |
31 uuid_(), | 31 uuid_(), |
32 pe_image_reader_(), | 32 pe_image_reader_(), |
33 process_reader_(nullptr), | 33 process_reader_(nullptr), |
34 timestamp_(0), | 34 timestamp_(0), |
35 age_(0), | 35 age_(0), |
36 initialized_() { | 36 initialized_(), |
| 37 vs_fixed_file_info_(), |
| 38 initialized_vs_fixed_file_info_() { |
37 } | 39 } |
38 | 40 |
39 ModuleSnapshotWin::~ModuleSnapshotWin() { | 41 ModuleSnapshotWin::~ModuleSnapshotWin() { |
40 } | 42 } |
41 | 43 |
42 bool ModuleSnapshotWin::Initialize( | 44 bool ModuleSnapshotWin::Initialize( |
43 ProcessReaderWin* process_reader, | 45 ProcessReaderWin* process_reader, |
44 const ProcessInfo::Module& process_reader_module) { | 46 const ProcessInfo::Module& process_reader_module) { |
45 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 47 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
46 | 48 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 time_t ModuleSnapshotWin::Timestamp() const { | 102 time_t ModuleSnapshotWin::Timestamp() const { |
101 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 103 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
102 return timestamp_; | 104 return timestamp_; |
103 } | 105 } |
104 | 106 |
105 void ModuleSnapshotWin::FileVersion(uint16_t* version_0, | 107 void ModuleSnapshotWin::FileVersion(uint16_t* version_0, |
106 uint16_t* version_1, | 108 uint16_t* version_1, |
107 uint16_t* version_2, | 109 uint16_t* version_2, |
108 uint16_t* version_3) const { | 110 uint16_t* version_3) const { |
109 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 111 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
110 VS_FIXEDFILEINFO ffi; | 112 const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); |
111 if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) { | 113 if (ffi) { |
112 *version_0 = ffi.dwFileVersionMS >> 16; | 114 *version_0 = ffi->dwFileVersionMS >> 16; |
113 *version_1 = ffi.dwFileVersionMS & 0xffff; | 115 *version_1 = ffi->dwFileVersionMS & 0xffff; |
114 *version_2 = ffi.dwFileVersionLS >> 16; | 116 *version_2 = ffi->dwFileVersionLS >> 16; |
115 *version_3 = ffi.dwFileVersionLS & 0xffff; | 117 *version_3 = ffi->dwFileVersionLS & 0xffff; |
116 } else { | 118 } else { |
117 *version_0 = 0; | 119 *version_0 = 0; |
118 *version_1 = 0; | 120 *version_1 = 0; |
119 *version_2 = 0; | 121 *version_2 = 0; |
120 *version_3 = 0; | 122 *version_3 = 0; |
121 } | 123 } |
122 } | 124 } |
123 | 125 |
124 void ModuleSnapshotWin::SourceVersion(uint16_t* version_0, | 126 void ModuleSnapshotWin::SourceVersion(uint16_t* version_0, |
125 uint16_t* version_1, | 127 uint16_t* version_1, |
126 uint16_t* version_2, | 128 uint16_t* version_2, |
127 uint16_t* version_3) const { | 129 uint16_t* version_3) const { |
128 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 130 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
129 VS_FIXEDFILEINFO ffi; | 131 const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); |
130 if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) { | 132 if (ffi) { |
131 *version_0 = ffi.dwProductVersionMS >> 16; | 133 *version_0 = ffi->dwProductVersionMS >> 16; |
132 *version_1 = ffi.dwProductVersionMS & 0xffff; | 134 *version_1 = ffi->dwProductVersionMS & 0xffff; |
133 *version_2 = ffi.dwProductVersionLS >> 16; | 135 *version_2 = ffi->dwProductVersionLS >> 16; |
134 *version_3 = ffi.dwProductVersionLS & 0xffff; | 136 *version_3 = ffi->dwProductVersionLS & 0xffff; |
135 } else { | 137 } else { |
136 *version_0 = 0; | 138 *version_0 = 0; |
137 *version_1 = 0; | 139 *version_1 = 0; |
138 *version_2 = 0; | 140 *version_2 = 0; |
139 *version_3 = 0; | 141 *version_3 = 0; |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
143 ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const { | 145 ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const { |
144 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 146 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
145 VS_FIXEDFILEINFO ffi; | 147 const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); |
146 if (GetModuleVersionAndType(base::FilePath(name_), &ffi)) { | 148 if (ffi) { |
147 if (ffi.dwFileType == VFT_APP) | 149 switch (ffi->dwFileType) { |
148 return ModuleSnapshot::kModuleTypeExecutable; | 150 case VFT_APP: |
149 if (ffi.dwFileType == VFT_DLL) | 151 return ModuleSnapshot::kModuleTypeExecutable; |
150 return ModuleSnapshot::kModuleTypeSharedLibrary; | 152 case VFT_DLL: |
151 if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD) | 153 return ModuleSnapshot::kModuleTypeSharedLibrary; |
152 return ModuleSnapshot::kModuleTypeLoadableModule; | 154 case VFT_DRV: |
| 155 case VFT_VXD: |
| 156 return ModuleSnapshot::kModuleTypeLoadableModule; |
| 157 } |
153 } | 158 } |
154 return ModuleSnapshot::kModuleTypeUnknown; | 159 return ModuleSnapshot::kModuleTypeUnknown; |
155 } | 160 } |
156 | 161 |
157 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { | 162 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { |
158 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 163 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
159 *uuid = uuid_; | 164 *uuid = uuid_; |
160 *age = age_; | 165 *age = age_; |
161 } | 166 } |
162 | 167 |
(...skipping 30 matching lines...) Expand all Loading... |
193 | 198 |
194 options->crashpad_handler_behavior = | 199 options->crashpad_handler_behavior = |
195 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 200 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
196 crashpad_info.crashpad_handler_behavior); | 201 crashpad_info.crashpad_handler_behavior); |
197 | 202 |
198 options->system_crash_reporter_forwarding = | 203 options->system_crash_reporter_forwarding = |
199 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 204 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
200 crashpad_info.system_crash_reporter_forwarding); | 205 crashpad_info.system_crash_reporter_forwarding); |
201 } | 206 } |
202 | 207 |
| 208 const VS_FIXEDFILEINFO* ModuleSnapshotWin::VSFixedFileInfo() const { |
| 209 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 210 |
| 211 if (initialized_vs_fixed_file_info_.is_uninitialized()) { |
| 212 initialized_vs_fixed_file_info_.set_invalid(); |
| 213 if (GetModuleVersionAndType(base::FilePath(name_), &vs_fixed_file_info_)) { |
| 214 initialized_vs_fixed_file_info_.set_valid(); |
| 215 } |
| 216 } |
| 217 |
| 218 return initialized_vs_fixed_file_info_.is_valid() ? &vs_fixed_file_info_ |
| 219 : nullptr; |
| 220 } |
| 221 |
203 } // namespace internal | 222 } // namespace internal |
204 } // namespace crashpad | 223 } // namespace crashpad |
OLD | NEW |