Index: util/mach/mach_message.h |
diff --git a/util/mach/mach_message.h b/util/mach/mach_message.h |
index 05695404f3c6313dfa9a8272671ff85b4c205a06..5de081852e3a0f3b935a0b07fc4d87f1b8885238 100644 |
--- a/util/mach/mach_message.h |
+++ b/util/mach/mach_message.h |
@@ -17,6 +17,7 @@ |
#include <mach/mach.h> |
#include <stdint.h> |
+#include <sys/types.h> |
namespace crashpad { |
@@ -148,6 +149,22 @@ void SetMIGReplyError(mach_msg_header_t* out_header, kern_return_t error); |
const mach_msg_trailer_t* MachMessageTrailerFromHeader( |
const mach_msg_header_t* header); |
+//! \brief Returns the process ID of a Mach message’s sender from its audit |
+//! trailer. |
+//! |
+//! For the audit trailer to be present, the message must have been received |
+//! with `MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | |
+//! MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT)` specified as options. |
+//! |
+//! If the kernel is the message’s sender, a process ID of `0` will be returned. |
+//! |
+//! \param[in] trailer The trailer received with a Mach message. |
+//! |
+//! \return The process ID of the message’s sender, or `-1` on failure with a |
+//! message logged. It is considered a failure for \a trailer to not contain |
+//! audit information. |
+pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer); |
+ |
} // namespace crashpad |
#endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ |