OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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_UTIL_MACH_MACH_MESSAGE_H_ | 15 #ifndef CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ |
16 #define CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ | 16 #define CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ |
17 | 17 |
18 #include <mach/mach.h> | 18 #include <mach/mach.h> |
19 #include <stdint.h> | 19 #include <stdint.h> |
| 20 #include <sys/types.h> |
20 | 21 |
21 namespace crashpad { | 22 namespace crashpad { |
22 | 23 |
23 //! \brief Special constants used as `mach_msg_timeout_t` values. | 24 //! \brief Special constants used as `mach_msg_timeout_t` values. |
24 enum : mach_msg_timeout_t { | 25 enum : mach_msg_timeout_t { |
25 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will | 26 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will |
26 //! return #kMachMessageDeadlineNonblocking. | 27 //! return #kMachMessageDeadlineNonblocking. |
27 kMachMessageTimeoutNonblocking = 0, | 28 kMachMessageTimeoutNonblocking = 0, |
28 | 29 |
29 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will | 30 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 //! for sending do not contain trailers. | 142 //! for sending do not contain trailers. |
142 //! | 143 //! |
143 //! \param[in] header A pointer to a received Mach message. | 144 //! \param[in] header A pointer to a received Mach message. |
144 //! | 145 //! |
145 //! \return A pointer to the trailer following the received Mach message’s body. | 146 //! \return A pointer to the trailer following the received Mach message’s body. |
146 //! The contents of the trailer depend on the options provided to | 147 //! The contents of the trailer depend on the options provided to |
147 //! `mach_msg()` or a similar function when the message was received. | 148 //! `mach_msg()` or a similar function when the message was received. |
148 const mach_msg_trailer_t* MachMessageTrailerFromHeader( | 149 const mach_msg_trailer_t* MachMessageTrailerFromHeader( |
149 const mach_msg_header_t* header); | 150 const mach_msg_header_t* header); |
150 | 151 |
| 152 //! \brief Returns the process ID of a Mach message’s sender from its audit |
| 153 //! trailer. |
| 154 //! |
| 155 //! For the audit trailer to be present, the message must have been received |
| 156 //! with `MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | |
| 157 //! MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT)` specified as options. |
| 158 //! |
| 159 //! If the kernel is the message’s sender, a process ID of `0` will be returned. |
| 160 //! |
| 161 //! \param[in] trailer The trailer received with a Mach message. |
| 162 //! |
| 163 //! \return The process ID of the message’s sender, or `-1` on failure with a |
| 164 //! message logged. It is considered a failure for \a trailer to not contain |
| 165 //! audit information. |
| 166 pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer); |
| 167 |
151 } // namespace crashpad | 168 } // namespace crashpad |
152 | 169 |
153 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ | 170 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ |
OLD | NEW |