Endpoint security es_copy_message deprecated

The es_copy_message function is deprecated and there are no alternatives provided.

https://developer.apple.com/documentation/endpointsecurity/3228861-es_copy_message


Currently, we copy incoming messages so that we can respond to messages later on a different dispatch queue/thread.

Is there a change in ownership of incoming messages or is there something that I am missing here?


Answered by mdolan in 637955022
From the header file

/**
  • Retains an esmessaget, returning a non-const pointer to the given esmessaget for compatibility with
 * existing code.
  • * @warning It is invalid to attempt to write to the returned esmessaget, despite being non-const, and
 * doing so will result in a crash.
  • * @deprecated Use esretainmessage to retain a message.
 *
  • @param msg The message to be retained
 * @return non-const pointer to the retained esmessaget.
  • * @brief The caller must release the memory with es_free_message
    • /

    OSEXPORT
APIDEPRECATED("Use esretainmessage to retain a message.", macos(10.15, 11.0))
APIUNAVAILABLE(ios, tvos, watchos)
es
messaget * Nullable
escopymessage(const esmessaget * _Nonnull msg);
Accepted Answer
From the header file

/**
  • Retains an esmessaget, returning a non-const pointer to the given esmessaget for compatibility with
 * existing code.
  • * @warning It is invalid to attempt to write to the returned esmessaget, despite being non-const, and
 * doing so will result in a crash.
  • * @deprecated Use esretainmessage to retain a message.
 *
  • @param msg The message to be retained
 * @return non-const pointer to the retained esmessaget.
  • * @brief The caller must release the memory with es_free_message
    • /

    OSEXPORT
APIDEPRECATED("Use esretainmessage to retain a message.", macos(10.15, 11.0))
APIUNAVAILABLE(ios, tvos, watchos)
es
messaget * Nullable
escopymessage(const esmessaget * _Nonnull msg);
The formatting got all messed up, best to just look at the header file in Xcode 12.2 beta 2 where I got this
Thanks mdolan! Looks like online documentation doesn't have all the details, I will get the beta and refer to the headers.
Endpoint security es_copy_message deprecated
 
 
Q