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 <windows.h> | |
| 19 #include <dbghelp.h> | |
| 18 #include <sys/types.h> | 20 #include <sys/types.h> |
| 19 #include <windows.h> | |
| 20 | 21 |
| 21 #include <string> | 22 #include <string> |
| 22 #include <vector> | 23 #include <vector> |
| 23 | 24 |
| 24 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 25 #include "util/misc/initialization_state_dcheck.h" | 26 #include "util/misc/initialization_state_dcheck.h" |
| 26 #include "util/numeric/checked_range.h" | 27 #include "util/numeric/checked_range.h" |
| 27 #include "util/win/address_types.h" | 28 #include "util/win/address_types.h" |
| 28 | 29 |
| 29 namespace crashpad { | 30 namespace crashpad { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 43 //! \brief The base address of the loaded DLL. | 44 //! \brief The base address of the loaded DLL. |
| 44 WinVMAddress dll_base; | 45 WinVMAddress dll_base; |
| 45 | 46 |
| 46 //! \brief The size of the module. | 47 //! \brief The size of the module. |
| 47 WinVMSize size; | 48 WinVMSize size; |
| 48 | 49 |
| 49 //! \brief The module's timestamp. | 50 //! \brief The module's timestamp. |
| 50 time_t timestamp; | 51 time_t timestamp; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 // \brief Contains information about a range of pages in the virtual address | |
| 54 // space of a process. | |
| 55 struct MemoryInfo { | |
| 56 explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi); | |
| 57 ~MemoryInfo(); | |
| 58 | |
| 59 //! \brief The base address of the region of pages. | |
| 60 WinVMAddress base_address; | |
| 61 | |
| 62 //! \brief The size of the region beginning at base_address in bytes. | |
| 63 WinVMSize region_size; | |
| 64 | |
| 65 //! \brief The base address of a range of pages that was allocated by | |
| 66 //! `VirtualAlloc()`. The page pointed to base_address is within this | |
| 67 //! range of pages. | |
| 68 WinVMAddress allocation_base; | |
| 69 | |
| 70 //! \brief The state of the pages, one of `MEM_COMMIT`, `MEM_FREE`, or | |
| 71 //! `MEM_RESERVE`. | |
| 72 uint32_t state; | |
| 73 | |
| 74 //! \brief The memory protection option when this page was originally | |
| 75 //! allocated. This will be `PAGE_EXECUTE`, `PAGE_EXECUTE_READ`, etc. | |
| 76 uint32_t allocation_protect; | |
| 77 | |
| 78 //! \brief The current memoryprotection state. This will be `PAGE_EXECUTE`, | |
| 79 //! `PAGE_EXECUTE_READ`, etc. | |
| 80 uint32_t protect; | |
| 81 | |
| 82 //! \brief The type of the pages. This will be one of `MEM_IMAGE`, | |
| 83 //! `MEM_MAPPED`, or `MEM_PRIVATE`. | |
| 84 uint32_t type; | |
| 85 }; | |
| 86 | |
| 87 ProcessInfo(); | 54 ProcessInfo(); |
| 88 ~ProcessInfo(); | 55 ~ProcessInfo(); |
| 89 | 56 |
| 90 //! \brief Initializes this object with information about the given | 57 //! \brief Initializes this object with information about the given |
| 91 //! \a process. | 58 //! \a process. |
| 92 //! | 59 //! |
| 93 //! This method must be called successfully prior to calling any other | 60 //! This method must be called successfully prior to calling any other |
| 94 //! method in this class. This method may only be called once. | 61 //! method in this class. This method may only be called once. |
| 95 //! | 62 //! |
| 96 //! \return `true` on success, `false` on failure with a message logged. | 63 //! \return `true` on success, `false` on failure with a message logged. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 121 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; | 88 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; |
| 122 | 89 |
| 123 //! \brief Retrieves the modules loaded into the target process. | 90 //! \brief Retrieves the modules loaded into the target process. |
| 124 //! | 91 //! |
| 125 //! The modules are enumerated in initialization order as detailed in the | 92 //! The modules are enumerated in initialization order as detailed in the |
| 126 //! Process Environment Block. The main executable will always be the | 93 //! Process Environment Block. The main executable will always be the |
| 127 //! first element. | 94 //! first element. |
| 128 bool Modules(std::vector<Module>* modules) const; | 95 bool Modules(std::vector<Module>* modules) const; |
| 129 | 96 |
| 130 //! \brief Retrieves information about all pages mapped into the process. | 97 //! \brief Retrieves information about all pages mapped into the process. |
| 131 const std::vector<MemoryInfo>& MemoryInformation() const; | 98 const std::vector<MINIDUMP_MEMORY_INFO>& MemoryInfo() const; |
|
Mark Mentovai
2015/10/06 20:57:14
OK, this was what I was missing when reading https
scottmg
2015/10/06 22:43:26
Makes sense. I went with MEMORY_BASIC_INFORMATION6
| |
| 132 | 99 |
| 133 //! \brief Given a range to be read from the target process, returns a vector | 100 //! \brief Given a range to be read from the target process, returns a vector |
| 134 //! of ranges, representing the readable portions of the original range. | 101 //! of ranges, representing the readable portions of the original range. |
| 135 //! | 102 //! |
| 136 //! \param[in] range The range being identified. | 103 //! \param[in] range The range being identified. |
| 137 //! | 104 //! |
| 138 //! \return A vector of ranges corresponding to the portion of \a range that | 105 //! \return A vector of ranges corresponding to the portion of \a range that |
| 139 //! is readable based on the memory map. | 106 //! is readable based on the memory map. |
| 140 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( | 107 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( |
| 141 const CheckedRange<WinVMAddress, WinVMSize>& range) const; | 108 const CheckedRange<WinVMAddress, WinVMSize>& range) const; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 155 friend bool ReadMemoryInfo(HANDLE process, | 122 friend bool ReadMemoryInfo(HANDLE process, |
| 156 bool is_64_bit, | 123 bool is_64_bit, |
| 157 ProcessInfo* process_info); | 124 ProcessInfo* process_info); |
| 158 | 125 |
| 159 pid_t process_id_; | 126 pid_t process_id_; |
| 160 pid_t inherited_from_process_id_; | 127 pid_t inherited_from_process_id_; |
| 161 std::wstring command_line_; | 128 std::wstring command_line_; |
| 162 WinVMAddress peb_address_; | 129 WinVMAddress peb_address_; |
| 163 WinVMSize peb_size_; | 130 WinVMSize peb_size_; |
| 164 std::vector<Module> modules_; | 131 std::vector<Module> modules_; |
| 165 std::vector<MemoryInfo> memory_info_; | 132 std::vector<MINIDUMP_MEMORY_INFO> memory_info_; |
| 166 bool is_64_bit_; | 133 bool is_64_bit_; |
| 167 bool is_wow64_; | 134 bool is_wow64_; |
| 168 InitializationStateDcheck initialized_; | 135 InitializationStateDcheck initialized_; |
| 169 | 136 |
| 170 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 137 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
| 171 }; | 138 }; |
| 172 | 139 |
| 173 //! \brief Given a memory map of a process, and a range to be read from the | 140 //! \brief Given a memory map of a process, and a range to be read from the |
| 174 //! target process, returns a vector of ranges, representing the readable | 141 //! target process, returns a vector of ranges, representing the readable |
| 175 //! portions of the original range. | 142 //! portions of the original range. |
| 176 //! | 143 //! |
| 177 //! This is a free function for testing, but prefer | 144 //! This is a free function for testing, but prefer |
| 178 //! ProcessInfo::GetReadableRanges(). | 145 //! ProcessInfo::GetReadableRanges(). |
| 179 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( | 146 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( |
| 180 const CheckedRange<WinVMAddress, WinVMSize>& range, | 147 const CheckedRange<WinVMAddress, WinVMSize>& range, |
| 181 const std::vector<ProcessInfo::MemoryInfo>& memory_info); | 148 const std::vector<MINIDUMP_MEMORY_INFO>& memory_info); |
| 182 | 149 |
| 183 } // namespace crashpad | 150 } // namespace crashpad |
| 184 | 151 |
| 185 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 152 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
| OLD | NEW |