Posts

Post marked as solved
1 Replies
884 Views
I am trying to interact with a dext from an application. I am able to find the service using `IOServiceOpen` and I get a call to `NewUserClient` of my dext (I can see the `type` parameter passed being output in the log). After this I am a bit lost. Reading here about NewUserClient I can see that one should use Create to create a new Service object.The Discussion part here says "The keys in the propertiesKey dictionary describe the new service." Should this dictionary be placed in the plist file for the system extension as a top level entry, or should the dictionary be placed with the key in IOKitPersonalities? Can I leave the "IOServiceDEXTEntitlements" key with an ampty value to not imposte any restrictions about entitlements on the application that is connecting to the system extension?My plist looks like this (with the "MyUserClientProperties" key / dict in two places).<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1</string> <key>MyUserClientProperties</key> <dict> <key>IOClass</key> <string>MyUserClient</string> <key>IOUserClass</key> <string>MyUserUSBInterfaceDriver</string> <key>IOServiceDEXTEntitlements</key> <string></string> </dict> <key>IOKitPersonalities</key> <dict> <key>example_device</key> <dict> <key>MyUserClientProperties</key> <dict> <key>IOClass</key> <string>MyUserClient</string> <key>IOUserClass</key> <string>MyUserUSBInterfaceDriver</string> <key>IOServiceDEXTEntitlements</key> <string></string> </dict> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>IOClass</key> <string>IOUserService</string> <key>IOProviderClass</key> <string>IOUSBHostInterface</string> <key>IOUserClass</key> <string>MyUserUSBInterfaceDriver</string> <key>IOUserServerName</key> <string>sc.example.MyUserUSBInterfaceDriver</string> <key>bConfigurationValue</key> <integer>0x1</integer> <key>bInterfaceNumber</key> <integer>0x0</integer> <key>idVendor</key> <integer>0x123</integer> <key>idProduct</key> <integer>0x08</integer> </dict> </dict> <key>OSBundleUsageDescription</key> <string>Example user space USB driver</string> </dict> </plist>Do I need to pass SUPERDISPATCH as the last argument to "Create"?From "OSX and iOS kernel programming" chapter 5 page 81:The ingenuity of the I/O Kit design is that user client objects are themselves a driver object: the IOUserClient class inherits from IOService and, as with any other IOService instance, each user client has a provider class that, for a user client, is the instance of the driver that the application is controlling.While the above might only be correct for kext (?) I would assume that things work in the same way for a dext,From Create documenation: "Use the kIOUserClassKey key to specify the name of the custom IOService subclass that you want the system to instantiate."Why is another IOService class needed to be instantiated? What is the purpose of this class? Is it the provider for my class that inherits from IOUserClient? If so how can I make the instance of my driver (the one that implements NewUserClient) the provider?From Create documenation: "Use the kIOClassKey to specify the name of the custom IOUserClient subclass to return to clients of your service."Is the type of the class that will be created and assigned to the third argument of "Create"? If so, is that the one I should assign to the IOUserClient pointer passed to "NewUserClient"?kern_return_t IMPL(MyUserUSBInterfaceDriver, NewUserClient) { os_log(OS_LOG_DEFAULT, "%{public}d:", type); IOPropertyName propertiesKey = "MyUserClientProperties"; IOService* client; auto ret = Create(this, propertiesKey, &client, SUPERDISPATCH); // Need to do more things here... return ret; }No matter what I try I always get an assert, but I cannot see what is causing it.3 com.apple.DriverKit 0x0000000102f2b24b __assert_rtn + 102 4 com.apple.DriverKit 0x0000000102f2c20a IOService::Create_Impl(IOService*, char const*, IOService**) (.cold.2) + 35 5 com.apple.DriverKit 0x0000000102f1766b IOService::Create_Impl(IOService*, char const*, IOService**) + 91 6 com.apple.DriverKit 0x0000000102f2668f IOService::Create_Invoke(IORPC, OSMetaClassBase*, int (*)(OSMetaClassBase*, IOService*, char const*, IOService**)) + 135 7 com.apple.DriverKit 0x0000000102f276d7 IOService::Create(IOService*, char const*, IOService**, int (*)(OSMetaClassBase*, IORPC)) + 267 8 sc.example.MyUserUSBInterfaceDriver 0x0000000102ee0c89 MyUserUSBInterfaceDriver::NewUserClient_Impl(unsigned int, IOUserClient**) + 313 (MyUserUSBInterfaceDriver.cpp:155)
Posted
by tuple_cat.
Last updated
.