Chromium Code Reviews| 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(); | |
|
Mark Mentovai
2015/10/01 17:38:59
We killed this in
https://codereview.chromium.org/
scottmg
2015/10/01 18:10:02
Done.
| |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 //! \brief Retrieves the modules loaded into the target process. | 124 //! \brief Retrieves the modules loaded into the target process. |
| 123 //! | 125 //! |
| 124 //! The modules are enumerated in initialization order as detailed in the | 126 //! The modules are enumerated in initialization order as detailed in the |
| 125 //! Process Environment Block. The main executable will always be the | 127 //! Process Environment Block. The main executable will always be the |
| 126 //! first element. | 128 //! first element. |
| 127 bool Modules(std::vector<Module>* modules) const; | 129 bool Modules(std::vector<Module>* modules) const; |
| 128 | 130 |
| 129 //! \brief Retrieves information about all pages mapped into the process. | 131 //! \brief Retrieves information about all pages mapped into the process. |
| 130 const std::vector<MemoryInfo>& MemoryInformation() const; | 132 const std::vector<MemoryInfo>& MemoryInformation() const; |
| 131 | 133 |
| 134 //! \brief Given a range to be read from the target process, returns a vector | |
| 135 //! of ranges, representing the readable portions of the original range. | |
| 136 //! | |
| 137 //! \param[in] range The range being identified. | |
| 138 //! | |
| 139 //! \return A vector of ranges corresponding to the portion of the range | |
| 140 //! identified by \a range that are readable, based on the memory map. | |
| 141 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( | |
| 142 const CheckedRange<WinVMAddress, WinVMSize>& range) const; | |
| 143 | |
| 132 private: | 144 private: |
| 133 template <class Traits> | 145 template <class Traits> |
| 134 friend bool GetProcessBasicInformation(HANDLE process, | 146 friend bool GetProcessBasicInformation(HANDLE process, |
| 135 bool is_wow64, | 147 bool is_wow64, |
| 136 ProcessInfo* process_info, | 148 ProcessInfo* process_info, |
| 137 WinVMAddress* peb_address, | 149 WinVMAddress* peb_address, |
| 138 WinVMSize* peb_size); | 150 WinVMSize* peb_size); |
| 139 template <class Traits> | 151 template <class Traits> |
| 140 friend bool ReadProcessData(HANDLE process, | 152 friend bool ReadProcessData(HANDLE process, |
| 141 WinVMAddress peb_address_vmaddr, | 153 WinVMAddress peb_address_vmaddr, |
| 142 ProcessInfo* process_info); | 154 ProcessInfo* process_info); |
| 143 | 155 |
| 144 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info); | 156 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info); |
| 145 | 157 |
| 146 pid_t process_id_; | 158 pid_t process_id_; |
| 147 pid_t inherited_from_process_id_; | 159 pid_t inherited_from_process_id_; |
| 148 std::wstring command_line_; | 160 std::wstring command_line_; |
| 149 WinVMAddress peb_address_; | 161 WinVMAddress peb_address_; |
| 150 WinVMSize peb_size_; | 162 WinVMSize peb_size_; |
| 151 std::vector<Module> modules_; | 163 std::vector<Module> modules_; |
| 152 std::vector<MemoryInfo> memory_info_; | 164 std::vector<MemoryInfo> memory_info_; |
| 153 bool is_64_bit_; | 165 bool is_64_bit_; |
| 154 bool is_wow64_; | 166 bool is_wow64_; |
| 155 InitializationStateDcheck initialized_; | 167 InitializationStateDcheck initialized_; |
| 156 | 168 |
| 157 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 169 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
| 158 }; | 170 }; |
| 159 | 171 |
| 172 //! \brief Given a memory map of a process, and a range to be read from the | |
| 173 //! target process, returns a vector of ranges, representing the readable | |
| 174 //! portions of the original range. | |
| 175 //! | |
| 176 //! This is a free function for testing, but prefer | |
| 177 //! ProcessInfo::GetReadableRanges(). | |
| 178 //! | |
| 179 //! \sa ProcessInfo::GetReadableRanges() | |
|
Mark Mentovai
2015/10/01 17:38:59
I don’t think you need to say \sa when you just ga
scottmg
2015/10/01 18:10:02
Done.
| |
| 180 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( | |
| 181 const CheckedRange<WinVMAddress, WinVMSize>& range, | |
| 182 const std::vector<ProcessInfo::MemoryInfo>& memory_info); | |
| 183 | |
| 160 } // namespace crashpad | 184 } // namespace crashpad |
| 161 | 185 |
| 162 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 186 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
| OLD | NEW |