Search code examples
iosiokitipadosdriverkit

How do you find and open a DriverKit service and communicate with it on iPadOS?


I'm trying to communicate between an iPad app and a DriverKit dext, but IOServiceGetMatchingServices can't find the dext to communicate with.

I've been basing my app on this macOS example from Apple: https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app

With an Objective-C wrapper iPad app around the C++ CppUserClient. I had to make a few changes to the Entitlements and some of the CppUserClient because some of the features are not available on iPadOS (different Entitlements like com.apple.developer.driverkit.communicates-with-drivers) or deprecated stuff in Apple's example code (e.g. kIOMasterPortDefault -> kIOMainPortDefault).

This line

ret = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching(dextIdentifier), &iterator);

succeeds, but the iterator doesn't have anything in it to open; there are no matching services. I'm sure the driver has started up though because I can see the init and Start succeeding in the console logs.

Is there some completely different way iPad apps are supposed to communicate with DriverKit? Or are there just other IOKit changes that need to be made to Apple's example macOS CppUserClient to work with iPads? Is there something like ioreg on iPadOS that I can use to see what services are running and see if the dext is there to communicate with?


Solution

  • For an IOService object to become eligible for matching, RegisterService() must be called on it. Essentially, this signals to the rest of the system that the object is ready for clients to connect to it, be they other kernel or DriverKit IOService nodes, or user clients that wish to connect with IOServiceOpen().