Post

Replies

Boosts

Views

Activity

How should NewUserClient be implemented?
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)
1
0
1.1k
May ’20
Deadlock in AudioWorkIntervalCreate
Sometimes when I call AudioWorkIntervalCreate the call hangs with the following stacktrace. The call is made on the main thread. mach_msg2_trap 0x00007ff801f0b3ce mach_msg2_internal 0x00007ff801f19d80 mach_msg_overwrite 0x00007ff801f12510 mach_msg 0x00007ff801f0b6bd HALC_Object_AddPropertyListener 0x00007ff8049ea43e HALC_ProxyObject::HALC_ProxyObject(unsigned int, unsigned int, unsigned int, unsigned int) 0x00007ff8047f97f2 HALC_ProxyObjectMap::_CreateObject(unsigned int, unsigned int, unsigned int, unsigned int) 0x00007ff80490f69c HALC_ProxyObjectMap::CopyObjectByObjectID(unsigned int) 0x00007ff80490ecd6 HALC_ShellPlugIn::_ReconcileDeviceList(bool, bool, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>>&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>>&) 0x00007ff8045d68cf HALB_CommandGate::ExecuteCommand(void () block_pointer) const 0x00007ff80492ed14 HALC_ShellObject::ExecuteCommand(void () block_pointer) const 0x00007ff80470f554 HALC_ShellPlugIn::ReconcileDeviceList(bool, bool) 0x00007ff8045d6414 HALC_ShellPlugIn::ConnectToServer() 0x00007ff8045d74a4 HAL_HardwarePlugIn_InitializeWithObjectID(AudioHardwarePlugInInterface**, unsigned int) 0x00007ff8045da256 HALPlugInManagement::CreateHALPlugIn(HALCFPlugIn const*) 0x00007ff80442f828 HALSystem::InitializeDevices() 0x00007ff80442ebc3 HALSystem::CheckOutInstance() 0x00007ff80442b696 AudioObjectAddPropertyListener_mac_imp 0x00007ff80469b431 auoop::WorkgroupManager_macOS::WorkgroupManager_macOS() 0x00007ff8040fc3d5 auoop::gWorkgroupManager() 0x00007ff8040fc245 AudioWorkIntervalCreate 0x00007ff804034a33
2
0
503
May ’24