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_PE_IMAGE_READER_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_WIN_PE_IMAGE_READER_H_ |
16 #define CRASHPAD_SNAPSHOT_WIN_PE_IMAGE_READER_H_ | 16 #define CRASHPAD_SNAPSHOT_WIN_PE_IMAGE_READER_H_ |
17 | 17 |
18 #include <windows.h> | 18 #include <windows.h> |
19 | 19 |
20 #include <string> | 20 #include <string> |
21 | 21 |
22 #include "base/basictypes.h" | 22 #include "base/basictypes.h" |
23 #include "util/misc/initialization_state_dcheck.h" | 23 #include "util/misc/initialization_state_dcheck.h" |
| 24 #include "util/misc/uuid.h" |
24 #include "util/win/address_types.h" | 25 #include "util/win/address_types.h" |
25 #include "util/win/checked_win_address_range.h" | 26 #include "util/win/checked_win_address_range.h" |
26 | 27 |
27 namespace crashpad { | 28 namespace crashpad { |
28 | 29 |
29 class ProcessReaderWin; | 30 class ProcessReaderWin; |
30 | 31 |
31 namespace process_types { | 32 namespace process_types { |
32 | 33 |
33 // TODO(scottmg): Genericize and/or? move process_types out of mac/. | 34 // TODO(scottmg): Genericize and/or? move process_types out of mac/. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 //! This is the value passed as \a size to Initialize(). | 87 //! This is the value passed as \a size to Initialize(). |
87 WinVMSize Size() const { return module_range_.Size(); } | 88 WinVMSize Size() const { return module_range_.Size(); } |
88 | 89 |
89 //! \brief Obtains the module's CrashpadInfo structure. | 90 //! \brief Obtains the module's CrashpadInfo structure. |
90 //! | 91 //! |
91 //! \return `true` on success, `false` on failure. If the module does not have | 92 //! \return `true` on success, `false` on failure. If the module does not have |
92 //! a `CPADinfo` section, this will return `false` without logging any | 93 //! a `CPADinfo` section, this will return `false` without logging any |
93 //! messages. Other failures will result in messages being logged. | 94 //! messages. Other failures will result in messages being logged. |
94 bool GetCrashpadInfo(process_types::CrashpadInfo* crashpad_info) const; | 95 bool GetCrashpadInfo(process_types::CrashpadInfo* crashpad_info) const; |
95 | 96 |
| 97 //! \brief Obtains information from the module's debug directory, if any. |
| 98 //! |
| 99 //! \param[out] uuid The unique identifier of the executable/PDB. |
| 100 //! \param[out] age The age field for the pdb (the number of times it's been |
| 101 //! relinked). |
| 102 //! \param[out] pdbname Name of the pdb file. |
| 103 //! \return `true` on success, or `false` if the module has no debug directory |
| 104 //! entry. |
| 105 bool DebugDirectoryInformation(UUID* uuid, DWORD* age, std::string* pdbname); |
| 106 |
96 private: | 107 private: |
| 108 //! \brief Reads the `IMAGE_NT_HEADERS` from the beginning of the image. |
| 109 bool ReadNtHeaders(WinVMAddress* nt_header_address, |
| 110 IMAGE_NT_HEADERS* nt_headers) const; |
| 111 |
97 //! \brief Finds a given section by name in the image. | 112 //! \brief Finds a given section by name in the image. |
98 bool GetSectionByName(const std::string& name, | 113 bool GetSectionByName(const std::string& name, |
99 IMAGE_SECTION_HEADER* section) const; | 114 IMAGE_SECTION_HEADER* section) const; |
100 | 115 |
101 //! \brief Reads memory from target process, first checking whether the range | 116 //! \brief Reads memory from target process, first checking whether the range |
102 //! requested falls inside module_range_. | 117 //! requested falls inside module_range_. |
103 //! | 118 //! |
104 //! \return `true` on success, with \a into filled out, otherwise `false` and | 119 //! \return `true` on success, with \a into filled out, otherwise `false` and |
105 //! a message will be logged. | 120 //! a message will be logged. |
106 bool CheckedReadMemory(WinVMAddress address, | 121 bool CheckedReadMemory(WinVMAddress address, |
107 WinVMSize size, | 122 WinVMSize size, |
108 void* into) const; | 123 void* into) const; |
109 | 124 |
110 ProcessReaderWin* process_reader_; // weak | 125 ProcessReaderWin* process_reader_; // weak |
111 CheckedWinAddressRange module_range_; | 126 CheckedWinAddressRange module_range_; |
112 std::string module_name_; | 127 std::string module_name_; |
113 InitializationStateDcheck initialized_; | 128 InitializationStateDcheck initialized_; |
114 | 129 |
115 DISALLOW_COPY_AND_ASSIGN(PEImageReader); | 130 DISALLOW_COPY_AND_ASSIGN(PEImageReader); |
116 }; | 131 }; |
117 | 132 |
118 } // namespace crashpad | 133 } // namespace crashpad |
119 | 134 |
120 #endif // CRASHPAD_SNAPSHOT_WIN_PE_IMAGE_READER_H_ | 135 #endif // CRASHPAD_SNAPSHOT_WIN_PE_IMAGE_READER_H_ |
OLD | NEW |