| 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_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ |
| 16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ | 16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ |
| 17 | 17 |
| 18 #include <sys/time.h> | 18 #include <sys/time.h> |
| 19 #include <windows.h> | 19 #include <windows.h> |
| 20 | 20 |
| 21 #include <vector> | 21 #include <vector> |
| 22 | 22 |
| 23 #include "build/build_config.h" |
| 23 #include "util/misc/initialization_state_dcheck.h" | 24 #include "util/misc/initialization_state_dcheck.h" |
| 24 #include "util/win/address_types.h" | 25 #include "util/win/address_types.h" |
| 25 #include "util/win/process_info.h" | 26 #include "util/win/process_info.h" |
| 26 | 27 |
| 27 namespace crashpad { | 28 namespace crashpad { |
| 28 | 29 |
| 29 //! \brief State of process being read by ProcessReaderWin. | 30 //! \brief State of process being read by ProcessReaderWin. |
| 30 enum class ProcessSuspensionState : bool { | 31 enum class ProcessSuspensionState : bool { |
| 31 //! \brief The process has not been suspended. | 32 //! \brief The process has not been suspended. |
| 32 kRunning, | 33 kRunning, |
| 33 | 34 |
| 34 //! \brief The process is suspended. | 35 //! \brief The process is suspended. |
| 35 kSuspended, | 36 kSuspended, |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 //! \brief Accesses information about another process, identified by a `HANDLE`. | 39 //! \brief Accesses information about another process, identified by a `HANDLE`. |
| 39 class ProcessReaderWin { | 40 class ProcessReaderWin { |
| 40 public: | 41 public: |
| 41 //! \brief Contains information about a thread that belongs to a process. | 42 //! \brief Contains information about a thread that belongs to a process. |
| 42 struct Thread { | 43 struct Thread { |
| 43 Thread(); | 44 Thread(); |
| 44 ~Thread() {} | 45 ~Thread() {} |
| 45 | 46 |
| 46 CONTEXT context; | 47 union { |
| 48 CONTEXT native; |
| 49 #if defined(ARCH_CPU_64_BITS) |
| 50 WOW64_CONTEXT wow64; |
| 51 #endif; |
| 52 } context; |
| 47 uint64_t id; | 53 uint64_t id; |
| 48 WinVMAddress teb; | 54 WinVMAddress teb; |
| 49 WinVMAddress stack_region_address; | 55 WinVMAddress stack_region_address; |
| 50 WinVMSize stack_region_size; | 56 WinVMSize stack_region_size; |
| 51 uint32_t suspend_count; | 57 uint32_t suspend_count; |
| 52 uint32_t priority_class; | 58 uint32_t priority_class; |
| 53 uint32_t priority; | 59 uint32_t priority; |
| 54 }; | 60 }; |
| 55 | 61 |
| 56 ProcessReaderWin(); | 62 ProcessReaderWin(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 //! \return The threads that are in the process. The first element (at index | 107 //! \return The threads that are in the process. The first element (at index |
| 102 //! `0`) corresponds to the main thread. | 108 //! `0`) corresponds to the main thread. |
| 103 const std::vector<Thread>& Threads(); | 109 const std::vector<Thread>& Threads(); |
| 104 | 110 |
| 105 //! \return The modules loaded in the process. The first element (at index | 111 //! \return The modules loaded in the process. The first element (at index |
| 106 //! `0`) corresponds to the main executable. | 112 //! `0`) corresponds to the main executable. |
| 107 const std::vector<ProcessInfo::Module>& Modules(); | 113 const std::vector<ProcessInfo::Module>& Modules(); |
| 108 | 114 |
| 109 private: | 115 private: |
| 110 template <class Traits> | 116 template <class Traits> |
| 111 void ReadThreadData(); | 117 void ReadThreadData(bool is_64_reading_32); |
| 112 | 118 |
| 113 HANDLE process_; | 119 HANDLE process_; |
| 114 ProcessInfo process_info_; | 120 ProcessInfo process_info_; |
| 115 std::vector<Thread> threads_; | 121 std::vector<Thread> threads_; |
| 116 std::vector<ProcessInfo::Module> modules_; | 122 std::vector<ProcessInfo::Module> modules_; |
| 117 ProcessSuspensionState suspension_state_; | 123 ProcessSuspensionState suspension_state_; |
| 118 bool initialized_threads_; | 124 bool initialized_threads_; |
| 119 InitializationStateDcheck initialized_; | 125 InitializationStateDcheck initialized_; |
| 120 | 126 |
| 121 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); | 127 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 } // namespace crashpad | 130 } // namespace crashpad |
| 125 | 131 |
| 126 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ | 132 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ |
| OLD | NEW |