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/win/address_types.h" | 27 #include "util/win/address_types.h" |
27 | 28 |
28 namespace crashpad { | 29 namespace crashpad { |
29 | 30 |
30 //! \brief Gathers information about a process given its `HANDLE`. This consists | 31 //! \brief Gathers information about a process given its `HANDLE`. This consists |
31 //! primarily of information stored in the Process Environment Block. | 32 //! primarily of information stored in the Process Environment Block. |
32 class ProcessInfo { | 33 class ProcessInfo { |
33 public: | 34 public: |
34 //! \brief Contains information about a module loaded into a process. | 35 //! \brief Contains information about a module loaded into a process. |
35 struct Module { | 36 struct Module { |
36 Module(); | 37 Module(); |
37 ~Module(); | 38 ~Module(); |
38 | 39 |
39 //! \brief The pathname used to load the module from disk. | 40 //! \brief The pathname used to load the module from disk. |
40 std::wstring name; | 41 std::wstring name; |
41 | 42 |
42 //! \brief The base address of the loaded DLL. | 43 //! \brief The base address of the loaded DLL. |
43 WinVMAddress dll_base; | 44 WinVMAddress dll_base; |
44 | 45 |
45 //! \brief The size of the module. | 46 //! \brief The size of the module. |
46 WinVMSize size; | 47 WinVMSize size; |
47 | 48 |
48 //! \brief The module's timestamp. | 49 //! \brief The module's timestamp. |
49 time_t timestamp; | 50 time_t timestamp; |
50 }; | 51 }; |
51 | 52 |
52 // \brief Contains information about a range of pages in the virtual address | 53 // \brief Contains information about a range of pages in the virtual address |
53 // space of a process. | 54 // space of a process. |
54 struct MemoryInfo { | 55 struct MemoryInfo { |
56 MemoryInfo(); | |
55 explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi); | 57 explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi); |
56 ~MemoryInfo(); | 58 ~MemoryInfo(); |
57 | 59 |
58 //! \brief The base address of the region of pages. | 60 //! \brief The base address of the region of pages. |
59 WinVMAddress base_address; | 61 WinVMAddress base_address; |
60 | 62 |
61 //! \brief The size of the region beginning at base_address in bytes. | 63 //! \brief The size of the region beginning at base_address in bytes. |
62 WinVMSize region_size; | 64 WinVMSize region_size; |
63 | 65 |
64 //! \brief The base address of a range of pages that was allocated by | 66 //! \brief The base address of a range of pages that was allocated by |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 WinVMSize peb_size_; | 152 WinVMSize peb_size_; |
151 std::vector<Module> modules_; | 153 std::vector<Module> modules_; |
152 std::vector<MemoryInfo> memory_info_; | 154 std::vector<MemoryInfo> memory_info_; |
153 bool is_64_bit_; | 155 bool is_64_bit_; |
154 bool is_wow64_; | 156 bool is_wow64_; |
155 InitializationStateDcheck initialized_; | 157 InitializationStateDcheck initialized_; |
156 | 158 |
157 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 159 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
158 }; | 160 }; |
159 | 161 |
162 //! \brief Given a process memory map, gets a set of regions that correspond to | |
Mark Mentovai
2015/09/29 21:35:50
“set” is slightly confusing when this returns a ve
scottmg
2015/09/30 17:40:26
Done.
| |
163 //! the readable regions (that are not `MEM_FREE`). | |
164 //! | |
165 //! \param[in] address The base address of the range being identified | |
166 //! \param[in] size The size of the range being identified. | |
167 //! \param[in] memory_info Memory map of a process, normally retrieved from | |
168 //! ProcessInfo::MemoryInformation(). | |
Mark Mentovai
2015/09/29 21:35:50
Since you mention MemoryInformation() and otherwis
scottmg
2015/09/30 17:40:26
After renaming the function, I tried to rephrase t
| |
169 //! | |
170 //! \return A list of ranges corresponding to the portion of the range | |
Mark Mentovai
2015/09/29 21:35:50
If the first mapping starts lower than address, wi
scottmg
2015/09/30 17:40:26
I think this is addressed by the rename/descriptio
| |
171 //! identified by \a address and \a size that are readable based on the | |
172 //! memory map. | |
173 std::vector<CheckedRange<WinVMAddress, WinVMSize>> | |
Mark Mentovai
2015/09/29 21:35:50
I’m definitely cool with CheckedRange in the imple
scottmg
2015/09/30 17:40:26
The main reason is that I don't like pair.first/.s
Mark Mentovai
2015/10/01 17:38:58
scottmg wrote:
| |
174 GetAccessibleRangesInMemoryMap( | |
Mark Mentovai
2015/09/29 21:35:50
Accessible → Readable? Based on the documentation
scottmg
2015/09/30 17:40:26
Renamed.
| |
175 WinVMAddress address, | |
176 WinVMSize size, | |
177 const std::vector<ProcessInfo::MemoryInfo>& memory_info); | |
Mark Mentovai
2015/09/29 21:35:50
It’s quirky for this to be a loose function that t
scottmg
2015/09/30 17:40:26
Yes, it was primarily for testing. Added a member
| |
178 | |
160 } // namespace crashpad | 179 } // namespace crashpad |
161 | 180 |
162 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 181 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
OLD | NEW |