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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
17 | 17 |
18 #include <sys/types.h> | 18 #include <sys/types.h> |
19 #include <windows.h> | 19 #include <windows.h> |
20 | 20 |
21 #include <string> | 21 #include <string> |
22 #include <vector> | 22 #include <vector> |
23 | 23 |
24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
25 #include "util/misc/initialization_state_dcheck.h" | 25 #include "util/misc/initialization_state_dcheck.h" |
26 #include "util/numeric/checked_range.h" | 26 #include "util/numeric/checked_range.h" |
| 27 #include "util/stdlib/aligned_allocator.h" |
27 #include "util/win/address_types.h" | 28 #include "util/win/address_types.h" |
28 | 29 |
29 namespace crashpad { | 30 namespace crashpad { |
30 | 31 |
31 //! \brief Gathers information about a process given its `HANDLE`. This consists | 32 //! \brief Gathers information about a process given its `HANDLE`. This consists |
32 //! primarily of information stored in the Process Environment Block. | 33 //! primarily of information stored in the Process Environment Block. |
33 class ProcessInfo { | 34 class ProcessInfo { |
34 public: | 35 public: |
| 36 using MemoryBasicInformation64Vector = |
| 37 AlignedVector<MEMORY_BASIC_INFORMATION64>; |
| 38 |
35 //! \brief Contains information about a module loaded into a process. | 39 //! \brief Contains information about a module loaded into a process. |
36 struct Module { | 40 struct Module { |
37 Module(); | 41 Module(); |
38 ~Module(); | 42 ~Module(); |
39 | 43 |
40 //! \brief The pathname used to load the module from disk. | 44 //! \brief The pathname used to load the module from disk. |
41 std::wstring name; | 45 std::wstring name; |
42 | 46 |
43 //! \brief The base address of the loaded DLL. | 47 //! \brief The base address of the loaded DLL. |
44 WinVMAddress dll_base; | 48 WinVMAddress dll_base; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; | 121 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; |
118 | 122 |
119 //! \brief Retrieves the modules loaded into the target process. | 123 //! \brief Retrieves the modules loaded into the target process. |
120 //! | 124 //! |
121 //! The modules are enumerated in initialization order as detailed in the | 125 //! The modules are enumerated in initialization order as detailed in the |
122 //! Process Environment Block. The main executable will always be the | 126 //! Process Environment Block. The main executable will always be the |
123 //! first element. | 127 //! first element. |
124 bool Modules(std::vector<Module>* modules) const; | 128 bool Modules(std::vector<Module>* modules) const; |
125 | 129 |
126 //! \brief Retrieves information about all pages mapped into the process. | 130 //! \brief Retrieves information about all pages mapped into the process. |
127 const std::vector<MEMORY_BASIC_INFORMATION64>& MemoryInfo() const; | 131 const MemoryBasicInformation64Vector& MemoryInfo() const; |
128 | 132 |
129 //! \brief Given a range to be read from the target process, returns a vector | 133 //! \brief Given a range to be read from the target process, returns a vector |
130 //! of ranges, representing the readable portions of the original range. | 134 //! of ranges, representing the readable portions of the original range. |
131 //! | 135 //! |
132 //! \param[in] range The range being identified. | 136 //! \param[in] range The range being identified. |
133 //! | 137 //! |
134 //! \return A vector of ranges corresponding to the portion of \a range that | 138 //! \return A vector of ranges corresponding to the portion of \a range that |
135 //! is readable based on the memory map. | 139 //! is readable based on the memory map. |
136 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( | 140 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( |
137 const CheckedRange<WinVMAddress, WinVMSize>& range) const; | 141 const CheckedRange<WinVMAddress, WinVMSize>& range) const; |
(...skipping 29 matching lines...) Expand all Loading... |
167 | 171 |
168 std::vector<Handle> BuildHandleVector(HANDLE process) const; | 172 std::vector<Handle> BuildHandleVector(HANDLE process) const; |
169 | 173 |
170 pid_t process_id_; | 174 pid_t process_id_; |
171 pid_t inherited_from_process_id_; | 175 pid_t inherited_from_process_id_; |
172 HANDLE process_; | 176 HANDLE process_; |
173 std::wstring command_line_; | 177 std::wstring command_line_; |
174 WinVMAddress peb_address_; | 178 WinVMAddress peb_address_; |
175 WinVMSize peb_size_; | 179 WinVMSize peb_size_; |
176 std::vector<Module> modules_; | 180 std::vector<Module> modules_; |
177 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; | 181 MemoryBasicInformation64Vector memory_info_; |
178 | 182 |
179 // Handles() is logically const, but updates this member on first retrieval. | 183 // Handles() is logically const, but updates this member on first retrieval. |
180 // See https://crashpad.chromium.org/bug/9. | 184 // See https://crashpad.chromium.org/bug/9. |
181 mutable std::vector<Handle> handles_; | 185 mutable std::vector<Handle> handles_; |
182 | 186 |
183 bool is_64_bit_; | 187 bool is_64_bit_; |
184 bool is_wow64_; | 188 bool is_wow64_; |
185 InitializationStateDcheck initialized_; | 189 InitializationStateDcheck initialized_; |
186 | 190 |
187 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 191 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
188 }; | 192 }; |
189 | 193 |
190 //! \brief Given a memory map of a process, and a range to be read from the | 194 //! \brief Given a memory map of a process, and a range to be read from the |
191 //! target process, returns a vector of ranges, representing the readable | 195 //! target process, returns a vector of ranges, representing the readable |
192 //! portions of the original range. | 196 //! portions of the original range. |
193 //! | 197 //! |
194 //! This is a free function for testing, but prefer | 198 //! This is a free function for testing, but prefer |
195 //! ProcessInfo::GetReadableRanges(). | 199 //! ProcessInfo::GetReadableRanges(). |
196 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( | 200 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( |
197 const CheckedRange<WinVMAddress, WinVMSize>& range, | 201 const CheckedRange<WinVMAddress, WinVMSize>& range, |
198 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); | 202 const ProcessInfo::MemoryBasicInformation64Vector& memory_info); |
199 | 203 |
200 } // namespace crashpad | 204 } // namespace crashpad |
201 | 205 |
202 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 206 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
OLD | NEW |