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 <windows.h> | 18 #include <windows.h> |
19 | 19 |
20 #include "util/misc/initialization_state_dcheck.h" | 20 #include "util/misc/initialization_state_dcheck.h" |
| 21 #include "util/win/address_types.h" |
21 #include "util/win/process_info.h" | 22 #include "util/win/process_info.h" |
22 | 23 |
23 namespace crashpad { | 24 namespace crashpad { |
24 | 25 |
25 //! \brief Accesses information about another process, identified by a HANDLE. | 26 //! \brief Accesses information about another process, identified by a HANDLE. |
26 class ProcessReaderWin { | 27 class ProcessReaderWin { |
27 public: | 28 public: |
28 ProcessReaderWin(); | 29 ProcessReaderWin(); |
29 ~ProcessReaderWin(); | 30 ~ProcessReaderWin(); |
30 | 31 |
31 //! \brief Initializes this object. This method must be called before any | 32 //! \brief Initializes this object. This method must be called before any |
32 //! other. | 33 //! other. |
33 //! | 34 //! |
34 //! \param[in] process Process handle, must have PROCESS_QUERY_INFORMATION, | 35 //! \param[in] process Process handle, must have PROCESS_QUERY_INFORMATION, |
35 //! PROCESS_VM_READ, and PROCESS_DUP_HANDLE access. | 36 //! PROCESS_VM_READ, and PROCESS_DUP_HANDLE access. |
36 //! | 37 //! |
37 //! \return `true` on success, indicating that this object will respond | 38 //! \return `true` on success, indicating that this object will respond |
38 //! validly to further method calls. `false` on failure. On failure, no | 39 //! validly to further method calls. `false` on failure. On failure, no |
39 //! further method calls should be made. | 40 //! further method calls should be made. |
40 bool Initialize(HANDLE process); | 41 bool Initialize(HANDLE process); |
41 | 42 |
42 //! \return `true` if the target task is a 64-bit process. | 43 //! \return `true` if the target task is a 64-bit process. |
43 bool Is64Bit() const { return process_info_.Is64Bit(); } | 44 bool Is64Bit() const { return process_info_.Is64Bit(); } |
44 | 45 |
| 46 pid_t ProcessID() const { return process_info_.ProcessID(); } |
| 47 pid_t ParentProcessID() const { return process_info_.ParentProcessID(); } |
| 48 |
| 49 bool ReadMemory(win_vm_address_t at, win_vm_size_t num_bytes, void* into); |
| 50 |
| 51 //! \return The modules loaded in the process. The first element (at index |
| 52 //! `0`) corresponds to the main executable. |
| 53 const std::vector<ProcessInfo::Module>& Modules(); |
| 54 |
45 private: | 55 private: |
| 56 HANDLE process_; |
46 ProcessInfo process_info_; | 57 ProcessInfo process_info_; |
| 58 std::vector<ProcessInfo::Module> modules_; |
47 InitializationStateDcheck initialized_; | 59 InitializationStateDcheck initialized_; |
48 | 60 |
49 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); | 61 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); |
50 }; | 62 }; |
51 | 63 |
52 } // namespace crashpad | 64 } // namespace crashpad |
53 | 65 |
54 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ | 66 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ |
OLD | NEW |