Question

I was wondering if there was a way for third party developers to interact with launch agents and daemons over XPC or Mach. My understanding is that the third party would have to know the dictionary format for XPC or have access to the .defs file for Mach. Are either of these available for the launch services which come preinstalled? If not then is there any other way of interacting with the services through code?

Was it helpful?

Solution

Your understanding is correct. For Mach, the .defs file is used as input for the Mach Interface Generator (MIG), which creates the C code used to serialize arguments in the mach message, call mach_msg, wait for the reply, and deserialize the reply. XPC also uses mach messages behind the scenes, btw (though Apple really doesn't tell you that).

Apple doesn't show anything for the launch services which are preinstalled. They do provide the source for launchd itself (though the latest version doesn't compile, due to libxpc.dylib which isn't provided, no surprise).

What you could do is hook mach_msg (or the overlying xpc_* message functions - that could be a tad difficult, since most are asynchronous, and the actual message is by a GCD thread).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top