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, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 //! \brief The base address of the loaded DLL. | 43 //! \brief The base address of the loaded DLL. |
| 44 WinVMAddress dll_base; | 44 WinVMAddress dll_base; |
| 45 | 45 |
| 46 //! \brief The size of the module. | 46 //! \brief The size of the module. |
| 47 WinVMSize size; | 47 WinVMSize size; |
| 48 | 48 |
| 49 //! \brief The module's timestamp. | 49 //! \brief The module's timestamp. |
| 50 time_t timestamp; | 50 time_t timestamp; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 struct Handle { | |
| 54 Handle(); | |
| 55 ~Handle(); | |
| 56 | |
| 57 //! \brief A string representation of the handle's type. | |
| 58 std::wstring type_name; | |
| 59 | |
| 60 //! \brief The handle's value. | |
| 61 //! | |
| 62 //! See https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203 on | |
| 63 //! 32 bit being the correct size for HANDLEs for proceses, even on Windows | |
|
Mark Mentovai
2015/10/16 04:03:04
32 bits, plural. Also, `HANDLE`s. Not just handles
scottmg
2015/10/16 20:36:01
Done. Somehow I always feel illiterate after these
Mark Mentovai
2015/10/16 22:04:05
You can blame it on your text editor like I do. :)
| |
| 64 //! x64. | |
| 65 uint32_t handle; | |
| 66 | |
| 67 //! \brief The attributes for the handle, e.g. `OBJ_INHERIT`, | |
| 68 //! `OBJ_CASE_INSENSITIVE`, etc. | |
| 69 uint32_t attributes; | |
| 70 | |
| 71 //! \brief The `ACCESS_MASK` for the handle in this process. | |
| 72 //! | |
| 73 //! See | |
| 74 //! http://blogs.msdn.com/b/openspecification/archive/2010/04/01/about-the-a ccess-mask-structure.aspx | |
| 75 //! for more information. | |
| 76 uint32_t granted_access; | |
| 77 | |
| 78 //! \brief The number of kernel references to the object that this handle | |
| 79 //! refers to. | |
| 80 uint32_t pointer_count; | |
| 81 | |
| 82 //! \brief The number of open handles to the object that this handle refers | |
| 83 //! to. | |
| 84 uint32_t handle_count; | |
| 85 }; | |
| 86 | |
| 53 ProcessInfo(); | 87 ProcessInfo(); |
| 54 ~ProcessInfo(); | 88 ~ProcessInfo(); |
| 55 | 89 |
| 56 //! \brief Initializes this object with information about the given | 90 //! \brief Initializes this object with information about the given |
| 57 //! \a process. | 91 //! \a process. |
| 58 //! | 92 //! |
| 59 //! This method must be called successfully prior to calling any other | 93 //! This method must be called successfully prior to calling any other |
| 60 //! method in this class. This method may only be called once. | 94 //! method in this class. This method may only be called once. |
| 61 //! | 95 //! |
| 62 //! \return `true` on success, `false` on failure with a message logged. | 96 //! \return `true` on success, `false` on failure with a message logged. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 //! \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 |
| 100 //! of ranges, representing the readable portions of the original range. | 134 //! of ranges, representing the readable portions of the original range. |
| 101 //! | 135 //! |
| 102 //! \param[in] range The range being identified. | 136 //! \param[in] range The range being identified. |
| 103 //! | 137 //! |
| 104 //! \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 |
| 105 //! is readable based on the memory map. | 139 //! is readable based on the memory map. |
| 106 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( | 140 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( |
| 107 const CheckedRange<WinVMAddress, WinVMSize>& range) const; | 141 const CheckedRange<WinVMAddress, WinVMSize>& range) const; |
| 108 | 142 |
| 143 //! \brief Retrieves information about open handles in the target process. | |
| 144 const std::vector<Handle>& Handles(); | |
| 145 | |
| 109 private: | 146 private: |
| 110 template <class Traits> | 147 template <class Traits> |
| 111 friend bool GetProcessBasicInformation(HANDLE process, | 148 friend bool GetProcessBasicInformation(HANDLE process, |
| 112 bool is_wow64, | 149 bool is_wow64, |
| 113 ProcessInfo* process_info, | 150 ProcessInfo* process_info, |
| 114 WinVMAddress* peb_address, | 151 WinVMAddress* peb_address, |
| 115 WinVMSize* peb_size); | 152 WinVMSize* peb_size); |
| 116 template <class Traits> | 153 template <class Traits> |
| 117 friend bool ReadProcessData(HANDLE process, | 154 friend bool ReadProcessData(HANDLE process, |
| 118 WinVMAddress peb_address_vmaddr, | 155 WinVMAddress peb_address_vmaddr, |
| 119 ProcessInfo* process_info); | 156 ProcessInfo* process_info); |
| 120 | 157 |
| 121 friend bool ReadMemoryInfo(HANDLE process, | 158 friend bool ReadMemoryInfo(HANDLE process, |
| 122 bool is_64_bit, | 159 bool is_64_bit, |
| 123 ProcessInfo* process_info); | 160 ProcessInfo* process_info); |
| 124 | 161 |
| 162 std::vector<Handle> BuildHandleVector(HANDLE process) const; | |
| 163 | |
| 125 pid_t process_id_; | 164 pid_t process_id_; |
| 126 pid_t inherited_from_process_id_; | 165 pid_t inherited_from_process_id_; |
| 166 HANDLE process_; | |
| 127 std::wstring command_line_; | 167 std::wstring command_line_; |
| 128 WinVMAddress peb_address_; | 168 WinVMAddress peb_address_; |
| 129 WinVMSize peb_size_; | 169 WinVMSize peb_size_; |
| 130 std::vector<Module> modules_; | 170 std::vector<Module> modules_; |
| 131 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; | 171 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; |
| 172 std::vector<Handle> handles_; | |
| 132 bool is_64_bit_; | 173 bool is_64_bit_; |
| 133 bool is_wow64_; | 174 bool is_wow64_; |
| 134 InitializationStateDcheck initialized_; | 175 InitializationStateDcheck initialized_; |
| 135 | 176 |
| 136 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 177 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
| 137 }; | 178 }; |
| 138 | 179 |
| 139 //! \brief Given a memory map of a process, and a range to be read from the | 180 //! \brief Given a memory map of a process, and a range to be read from the |
| 140 //! target process, returns a vector of ranges, representing the readable | 181 //! target process, returns a vector of ranges, representing the readable |
| 141 //! portions of the original range. | 182 //! portions of the original range. |
| 142 //! | 183 //! |
| 143 //! This is a free function for testing, but prefer | 184 //! This is a free function for testing, but prefer |
| 144 //! ProcessInfo::GetReadableRanges(). | 185 //! ProcessInfo::GetReadableRanges(). |
| 145 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( | 186 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( |
| 146 const CheckedRange<WinVMAddress, WinVMSize>& range, | 187 const CheckedRange<WinVMAddress, WinVMSize>& range, |
| 147 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); | 188 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); |
| 148 | 189 |
| 149 } // namespace crashpad | 190 } // namespace crashpad |
| 150 | 191 |
| 151 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 192 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |
| OLD | NEW |