+
+OSStatus SecCodeCreateWithXPCMessage(xpc_object_t message, SecCSFlags flags,
+ SecCodeRef * __nonnull CF_RETURNS_RETAINED target)
+{
+ BEGIN_CSAPI
+
+ checkFlags(flags);
+
+ if (xpc_get_type(message) != XPC_TYPE_DICTIONARY) {
+ return errSecCSInvalidObjectRef;
+ }
+
+ xpc_connection_t connection = xpc_dictionary_get_remote_connection(message);
+ if (connection == NULL) {
+ return errSecCSInvalidObjectRef;
+ }
+
+ audit_token_t t = {0};
+ xpc_connection_get_audit_token(connection, &t);
+
+ return SecCodeCreateWithAuditToken(&t, flags, target);
+
+ END_CSAPI
+}
+