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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class ProcessSnapshotWin final : public ProcessSnapshot { | 52 class ProcessSnapshotWin final : public ProcessSnapshot { |
53 public: | 53 public: |
54 ProcessSnapshotWin(); | 54 ProcessSnapshotWin(); |
55 ~ProcessSnapshotWin() override; | 55 ~ProcessSnapshotWin() override; |
56 | 56 |
57 //! \brief Initializes the object. | 57 //! \brief Initializes the object. |
58 //! | 58 //! |
59 //! \param[in] process The handle to create a snapshot from. | 59 //! \param[in] process The handle to create a snapshot from. |
60 //! \param[in] suspension_state Whether \a process has been suspended by the | 60 //! \param[in] suspension_state Whether \a process has been suspended by the |
61 //! caller. | 61 //! caller. |
| 62 //! \param[in] debug_critical_section_address The address in the target |
| 63 //! process's address space of a `CRITICAL_SECTION` allocated with valid |
| 64 //! `.DebugInfo`. Used as a starting point to walk the process's locks. |
| 65 //! May be `0`. |
62 //! | 66 //! |
63 //! \return `true` if the snapshot could be created, `false` otherwise with | 67 //! \return `true` if the snapshot could be created, `false` otherwise with |
64 //! an appropriate message logged. | 68 //! an appropriate message logged. |
65 //! | 69 //! |
66 //! \sa ScopedProcessSuspend | 70 //! \sa ScopedProcessSuspend |
67 bool Initialize(HANDLE process, ProcessSuspensionState suspension_state); | 71 bool Initialize(HANDLE process, |
| 72 ProcessSuspensionState suspension_state, |
| 73 WinVMAddress debug_critical_section_address); |
68 | 74 |
69 //! \brief Initializes the object's exception. | 75 //! \brief Initializes the object's exception. |
70 //! | 76 //! |
71 //! This populates the data to be returned by Exception(). | 77 //! This populates the data to be returned by Exception(). |
72 //! | 78 //! |
73 //! This method must not be called until after a successful call to | 79 //! This method must not be called until after a successful call to |
74 //! Initialize(). | 80 //! Initialize(). |
75 //! | 81 //! |
76 //! \param[in] exception_information_address The address in the client | 82 //! \param[in] exception_information_address The address in the client |
77 //! process's address space of an ExceptionInformation structure. | 83 //! process's address space of an ExceptionInformation structure. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override; | 137 std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override; |
132 std::vector<const MemorySnapshot*> ExtraMemory() const override; | 138 std::vector<const MemorySnapshot*> ExtraMemory() const override; |
133 | 139 |
134 private: | 140 private: |
135 // Initializes threads_ on behalf of Initialize(). | 141 // Initializes threads_ on behalf of Initialize(). |
136 void InitializeThreads(); | 142 void InitializeThreads(); |
137 | 143 |
138 // Initializes modules_ on behalf of Initialize(). | 144 // Initializes modules_ on behalf of Initialize(). |
139 void InitializeModules(); | 145 void InitializeModules(); |
140 | 146 |
141 // Initializes peb_memory_ on behalf of Initialize(). | 147 // Initializes various memory blocks reachable from the PEB on behalf of |
| 148 // Initialize(). |
142 template <class Traits> | 149 template <class Traits> |
143 void InitializePebData(); | 150 void InitializePebData(WinVMAddress debug_critical_section_address); |
144 | 151 |
145 void AddMemorySnapshot(WinVMAddress address, | 152 void AddMemorySnapshot(WinVMAddress address, |
146 WinVMSize size, | 153 WinVMSize size, |
147 PointerVector<internal::MemorySnapshotWin>* into); | 154 PointerVector<internal::MemorySnapshotWin>* into); |
148 | 155 |
149 template <class Traits> | 156 template <class Traits> |
150 void AddMemorySnapshotForUNICODE_STRING( | 157 void AddMemorySnapshotForUNICODE_STRING( |
151 const process_types::UNICODE_STRING<Traits>& us, | 158 const process_types::UNICODE_STRING<Traits>& us, |
152 PointerVector<internal::MemorySnapshotWin>* into); | 159 PointerVector<internal::MemorySnapshotWin>* into); |
153 | 160 |
154 template <class Traits> | 161 template <class Traits> |
155 void AddMemorySnapshotForLdrLIST_ENTRY( | 162 void AddMemorySnapshotForLdrLIST_ENTRY( |
156 const process_types::LIST_ENTRY<Traits>& le, | 163 const process_types::LIST_ENTRY<Traits>& le, |
157 size_t offset_of_member, | 164 size_t offset_of_member, |
158 PointerVector<internal::MemorySnapshotWin>* into); | 165 PointerVector<internal::MemorySnapshotWin>* into); |
159 | 166 |
160 WinVMSize DetermineSizeOfEnvironmentBlock( | 167 WinVMSize DetermineSizeOfEnvironmentBlock( |
161 WinVMAddress start_of_environment_block); | 168 WinVMAddress start_of_environment_block); |
162 | 169 |
| 170 // Starting from the address of a CRITICAL_SECTION, walks the doubly-linked |
| 171 // list stored in RTL_CRITICAL_SECTION.DebugInfo.ProcessLocksList adding both |
| 172 // the RTL_CRITICAL_SECTION and the RTL_CRITICAL_SECTION_DEBUG memory blocks |
| 173 // to the snapshot. |
| 174 template <class Traits> |
| 175 void ReadLocks(WinVMAddress start, |
| 176 PointerVector<internal::MemorySnapshotWin>* into); |
| 177 |
163 internal::SystemSnapshotWin system_; | 178 internal::SystemSnapshotWin system_; |
164 PointerVector<internal::MemorySnapshotWin> peb_memory_; | 179 PointerVector<internal::MemorySnapshotWin> extra_memory_; |
165 PointerVector<internal::ThreadSnapshotWin> threads_; | 180 PointerVector<internal::ThreadSnapshotWin> threads_; |
166 PointerVector<internal::ModuleSnapshotWin> modules_; | 181 PointerVector<internal::ModuleSnapshotWin> modules_; |
167 scoped_ptr<internal::ExceptionSnapshotWin> exception_; | 182 scoped_ptr<internal::ExceptionSnapshotWin> exception_; |
168 PointerVector<internal::MemoryMapRegionSnapshotWin> memory_map_; | 183 PointerVector<internal::MemoryMapRegionSnapshotWin> memory_map_; |
169 ProcessReaderWin process_reader_; | 184 ProcessReaderWin process_reader_; |
170 UUID report_id_; | 185 UUID report_id_; |
171 UUID client_id_; | 186 UUID client_id_; |
172 std::map<std::string, std::string> annotations_simple_map_; | 187 std::map<std::string, std::string> annotations_simple_map_; |
173 timeval snapshot_time_; | 188 timeval snapshot_time_; |
174 InitializationStateDcheck initialized_; | 189 InitializationStateDcheck initialized_; |
175 | 190 |
176 DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotWin); | 191 DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotWin); |
177 }; | 192 }; |
178 | 193 |
179 } // namespace crashpad | 194 } // namespace crashpad |
180 | 195 |
181 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_SNAPSHOT_WIN_H_ | 196 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_SNAPSHOT_WIN_H_ |
OLD | NEW |