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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 //! \brief The base address of the loaded DLL. | 42 //! \brief The base address of the loaded DLL. |
43 WinVMAddress dll_base; | 43 WinVMAddress dll_base; |
44 | 44 |
45 //! \brief The size of the module. | 45 //! \brief The size of the module. |
46 WinVMSize size; | 46 WinVMSize size; |
47 | 47 |
48 //! \brief The module's timestamp. | 48 //! \brief The module's timestamp. |
49 time_t timestamp; | 49 time_t timestamp; |
50 }; | 50 }; |
51 | 51 |
| 52 // \brief Contains information about a range of pages in the virtual address |
| 53 // space of a process. |
| 54 struct MemoryInfo { |
| 55 explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi); |
| 56 ~MemoryInfo(); |
| 57 |
| 58 //! \brief The base address of the region of pages. |
| 59 WinVMAddress base_address; |
| 60 |
| 61 //! \brief The size of the region beginning at base_address in bytes. |
| 62 WinVMSize region_size; |
| 63 |
| 64 //! \brief The base address of a range of pages that was allocated by |
| 65 //! `VirtualAlloc()`. The page pointed to base_address is within this |
| 66 //! range of pages. |
| 67 WinVMAddress allocation_base; |
| 68 |
| 69 //! \brief The state of the pages, one of `MEM_COMMIT`, `MEM_FREE`, or |
| 70 //! `MEM_RESERVE`. |
| 71 uint32_t state; |
| 72 |
| 73 //! \brief The memory protection option when this page was originally |
| 74 //! allocated. This will be `PAGE_EXECUTE`, `PAGE_EXECUTE_READ`, etc. |
| 75 uint32_t allocation_protect; |
| 76 |
| 77 //! \brief The current memoryprotection state. This will be `PAGE_EXECUTE`, |
| 78 //! `PAGE_EXECUTE_READ`, etc. |
| 79 uint32_t protect; |
| 80 |
| 81 //! \brief The type of the pages. This will be one of `MEM_IMAGE`, |
| 82 //! `MEM_MAPPED`, or `MEM_PRIVATE`. |
| 83 uint32_t type; |
| 84 }; |
| 85 |
52 ProcessInfo(); | 86 ProcessInfo(); |
53 ~ProcessInfo(); | 87 ~ProcessInfo(); |
54 | 88 |
55 //! \brief Initializes this object with information about the given | 89 //! \brief Initializes this object with information about the given |
56 //! \a process. | 90 //! \a process. |
57 //! | 91 //! |
58 //! This method must be called successfully prior to calling any other | 92 //! This method must be called successfully prior to calling any other |
59 //! method in this class. This method may only be called once. | 93 //! method in this class. This method may only be called once. |
60 //! | 94 //! |
61 //! \return `true` on success, `false` on failure with a message logged. | 95 //! \return `true` on success, `false` on failure with a message logged. |
(...skipping 23 matching lines...) Expand all Loading... |
85 //! \param[out] peb_size The size of the Process Environment Block. | 119 //! \param[out] peb_size The size of the Process Environment Block. |
86 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; | 120 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; |
87 | 121 |
88 //! \brief Retrieves the modules loaded into the target process. | 122 //! \brief Retrieves the modules loaded into the target process. |
89 //! | 123 //! |
90 //! The modules are enumerated in initialization order as detailed in the | 124 //! The modules are enumerated in initialization order as detailed in the |
91 //! Process Environment Block. The main executable will always be the | 125 //! Process Environment Block. The main executable will always be the |
92 //! first element. | 126 //! first element. |
93 bool Modules(std::vector<Module>* modules) const; | 127 bool Modules(std::vector<Module>* modules) const; |
94 | 128 |
| 129 //! \brief Retrieves information about all pages mapped into the process. |
| 130 const std::vector<MemoryInfo>& MemoryInformation() const; |
| 131 |
95 private: | 132 private: |
96 template <class Traits> | 133 template <class Traits> |
97 friend bool GetProcessBasicInformation(HANDLE process, | 134 friend bool GetProcessBasicInformation(HANDLE process, |
98 bool is_wow64, | 135 bool is_wow64, |
99 ProcessInfo* process_info, | 136 ProcessInfo* process_info, |
100 WinVMAddress* peb_address, | 137 WinVMAddress* peb_address, |
101 WinVMSize* peb_size); | 138 WinVMSize* peb_size); |
102 template <class Traits> | 139 template <class Traits> |
103 friend bool ReadProcessData(HANDLE process, | 140 friend bool ReadProcessData(HANDLE process, |
104 WinVMAddress peb_address_vmaddr, | 141 WinVMAddress peb_address_vmaddr, |
105 ProcessInfo* process_info); | 142 ProcessInfo* process_info); |
106 | 143 |
| 144 friend bool ReadMemoryInfo(HANDLE process, ProcessInfo* process_info); |
| 145 |
107 pid_t process_id_; | 146 pid_t process_id_; |
108 pid_t inherited_from_process_id_; | 147 pid_t inherited_from_process_id_; |
109 std::wstring command_line_; | 148 std::wstring command_line_; |
110 WinVMAddress peb_address_; | 149 WinVMAddress peb_address_; |
111 WinVMSize peb_size_; | 150 WinVMSize peb_size_; |
112 std::vector<Module> modules_; | 151 std::vector<Module> modules_; |
| 152 std::vector<MemoryInfo> memory_info_; |
113 bool is_64_bit_; | 153 bool is_64_bit_; |
114 bool is_wow64_; | 154 bool is_wow64_; |
115 InitializationStateDcheck initialized_; | 155 InitializationStateDcheck initialized_; |
116 | 156 |
117 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 157 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
118 }; | 158 }; |
119 | 159 |
120 } // namespace crashpad | 160 } // namespace crashpad |
121 | 161 |
122 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 162 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
OLD | NEW |