Hi ,
I am trying to write dext code for my existing Kext , i see "IOMemoryDescriptor::withAddress" being used , I dont find any alternatives in "DriverKit", Is there any others ways to achieve this,
Any input is appriciated ,
Thanks,
revan
DriverKit
RSS for tagDevelop device drivers that run in user space using DriverKit.
Posts under DriverKit tag
77 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello,
I am porting a PCI driver written with IOKit to the new PCIDriverKit framework.
I am able to perform DMA with a contiguous buffer allocated inside the dext (with IOBufferMemoryDescriptor::Create).
But I would also like to perform DMA to and from a buffer allocated by an application.
What I exactly want to do is:
Allocate an aligned buffer in the app (with e.g. posix_memalign)
Send the pointer to this buffer to the dext
In the dext, retrieve the list of pages descriptors to be able to perform DMA without copy into (or from) this buffer.
In IOKit, we can use methods such IOMemoryDescriptor::withAddressRange and IODMACommand::gen64IOVMSegments to map and retrieve the scatter gather list but I cannot find any information on how to do this in a dext with the PCIDriverKit framework.
Can anybody help me on how to do that?
Xcode version : 14.0 Beta 3
macOS version : 13 Beta 3(22A5295i)
Hi,
I'm signing the DriverKit in Developer ID Application type profile with Developer ID Application (With Kext) type certificate on Xcode.
But status shows error with"Xcode 14 and later requires a DriverKit development profile enabled for IOS and macOS.Visit the developer website to create or download a DriverKit profile"
I have downloaded all profiles and Certificates to my Mac and installed all of them, then checked the website.
I'm wondering what's different between "Development type" & "Developer ID Application type" profile ? and the reason why
"2022-07-22 14:41:54.162815+0800 0x22ee2 Error 0x0 138 0 kernelmanagerd: Error occurred while handling request "DextLaunch(arguments: Optional(["Driver Extension Server Name": com.asix.dext.usbdevice, "Check In Token": 371, "Driver Extension Server Tag": 4294975444, "CFBundleIdentifier": com.asix.dext.usbdevice, "DriverKit Reslide Shared Cache": 0, "kOSBundleDextUniqueIdentifier": <222f1e51 f5e890f7 b467c2a0 da761dbd 9b14dc5f 1bf56ff6 4eeab6b2 fed9683c>]))": Error Domain=NSPOSIXErrorDomain Code=8 "Exec format error"
error code show on when I starting the app.
I'll appreciate that someone can give me some idea or suggestions.
Thanks a lot.
We are developing driver for our USB device. Our approach is to run and test driver on macOS first and then verify on iPadOS 16. In the driver we add custom property -"kUSBSerialNumberString" into default properties:
OSDictionary * Driver::devicePropertiesWithSerialNumber() {
kern_return_t ret;
OSDictionary *properties = NULL;
OSDictionary *dictionary = NULL;
OSObjectPtr value;
const IOUSBDeviceDescriptor *deviceDescriptor;
deviceDescriptor = ivars->device->CopyDeviceDescriptor();
ret = CopyProperties(&properties);
value = copyStringAtIndex(deviceDescriptor->iSerialNumber, kIOUSBLanguageIDEnglishUS);
Log("Serial number: %{public}s", ((OSString *)value)->getCStringNoCopy());
dictionary = OSDictionary::withDictionary(properties, 0);
OSSafeReleaseNULL(properties);
if (value) {
OSDictionarySetValue(dictionary, "kUSBSerialNumberString", value);
OSSafeReleaseNULL(value);
}
return dictionary;
}
next in kern_return_t IMPL(Driver, Start) we call SetProperties:
ret = SetProperties(devicePropertiesWithSerialNumber());
if(ret != kIOReturnSuccess) {
Log("Start() - Failed to set properties: 0x%08x.", ret);
goto Exit;
}
We can read our property on macOS using:
func getDeviceProperty(device: io_object_t, key: String) -> AnyObject? {
IORegistryEntryCreateCFProperty(
device, key as CFString, kCFAllocatorDefault, .zero
)?.takeRetainedValue()
}
if let serialNumber = getDeviceProperty(device: driver, key: "kUSBSerialNumberString") {
print("serialNumber: \(serialNumber)")
}
However getDevicePropertyon iPadOS returns nil. We are wondering is any limitation for IORegistry entries(properties) on iPadOS16? Is any way to add custom property to IORegistry?
BTW, we added debug method to print all the available properties for IORegistry:
private func debugRegistry(device: io_object_t) {
var dictionary: Unmanaged<CFMutableDictionary>?
IORegistryEntryCreateCFProperties(device, &dictionary, kCFAllocatorDefault, .zero)
if let dictionary = dictionary {
let values = dictionary.takeUnretainedValue()
print(values)
}
}
It returns just 1 property for iPadOS:
{
IOClass = IOUserService;
}
and much more for macOS including our custom one:
{
CFBundleIdentifier = "****";
CFBundleIdentifierKernel = "com.apple.kpi.iokit";
IOClass = IOUserService;
IOMatchCategory = "***";
IOMatchedPersonality = {
CFBundleIdentifier = "****";
CFBundleIdentifierKernel = "com.apple.kpi.iokit";
IOClass = IOUserService;
IOMatchCategory = "****";
IOPersonalityPublisher = "****";
IOProviderClass = IOUSBHostInterface;
IOResourceMatch = IOKit;
IOUserClass = Driver;
IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac;
IOUserServerName = "*****";
UserClientProperties = {
IOClass = IOUserUserClient;
IOUserClass = DriverUserClient;
};
bConfigurationValue = 1;
bInterfaceNumber = 1;
bcdDevice = 512;
idProduct = XXXXX;
idVendor = XXXXX;
};
IOPersonalityPublisher = "*****";
IOPowerManagement = {
CapabilityFlags = 2;
CurrentPowerState = 2;
MaxPowerState = 2;
};
IOProbeScore = 100000;
IOProviderClass = IOUSBHostInterface;
IOResourceMatch = IOKit;
IOUserClass = Driver;
IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac;
IOUserServerName = "*****";
UserClientProperties = {
IOClass = IOUserUserClient;
IOUserClass = DriverUserClient;
};
bConfigurationValue = 1;
bInterfaceNumber = 1;
bcdDevice = 512;
idProduct = XXXXX;
idVendor = XXXXXX;
kUSBSerialNumberString = XXXXXXXXXXX;
}
I'm trying to built a USBDriverKit driver on the Mac. The driver loads properly but when my device is inserted the driver is ignored and instead the com.apple.AppleUserHIDDrivers driver is loaded. I do not understand what is causing this. The device both have USB and HID cababilities but I want it to work with USBDriverKit so that the driver can be used on the Ipad as well.
How can I get the driver to match properly?
Entitlements:
<?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>com.apple.developer.driverkit</key>
<true/>
<key>com.apple.developer.driverkit.transport.usb</key>
<array>
<dict>
<key>idVendor</key>
<integer>1240</integer>
</dict>
</array>
<key>com.apple.developer.driverkit.userclient-access</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
Info.plist:
...
<dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>IOKitPersonalities</key>
<dict>
<key>ClickerDriver</key>
<dict>
<key>IOKitDebug</key>
<string>65535</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>IOClass</key>
<string>IOUserService</string>
<key>IOProviderClass</key>
<string>IOUSBHostInterface</string>
<key>IOUserClass</key>
<string>ClickerDriver</string>
<key>IOUserServerName</key>
<string>example.Clicker.driver</string>
<key>bInterfaceClass</key>
<string>3</string>
<key>bInterfaceSubClass</key>
<string>0</string>
<key>bConfigurationValue</key>
<string>1</string>
<key>bInterfaceNumber</key>
<string>0</string>
<key>idProduct</key>
<integer>63</integer>
<key>idVendor</key>
<integer>1240</integer>
<key>UserClientProperties</key>
<dict>
<key>IOClass</key>
<string>IOUserUserClient</string>
<key>IOUserClass</key>
<string>ClickerDriverUserClient</string>
</dict>
</dict>
</dict>
<key>OSBundleUsageDescription</key>
<string>The app interprets monitors key presses. </string>
</dict>
</plist>
Output of ioreg -b -n "Simple HID Device Demo" -r -l is attacheded.
ioreg.log
My application installs a system extension.
When I try to remove the app from the Applications folder (cmd + backspace) I get an error message:
"The operation can’t be completed right now because another operation is in progress, such as moving or copying an item or emptying the Bin."
According to systemextensionsctl the extension state is "terminating for uninstall but still running".
I can see an error in the console logs:
kernelmanagerd Failed to terminate dext com.my.driver-dk, error: Kernel request failed: (os/kern) invalid address (1)
sysextd a category delegate declined to terminate extension with identifier: com.my.driver-dk
sysextd failed to terminate extension with identifier: com.my.driver-dk: Optional(Error Domain=kernelmanagerd.KMError Code=38 "(null)")
Issue occurs with macOS 13 - works fine with macOS 12 and macOS 11
What is the problem here?
Have there been any changes in macOS in that regard?
The "deployment target" for a DEXT is a number like 19.0 or 21.4. Xcode seems to pick the latest version on the machine you are creating the target on as a default - so if I make a new Driver target on Xcode 14 and Ventura, the Deployment Target for the driver will be 21.4. If I'm targeting macOS 12 (for example), what version of DriverKit should I choose, and where is this documented?
As i read Driverkit can be used to write the device driver.
But, I want to filter a device.
can Driverkit be used for filtering a particular device?
I'm working on a DriverKit driver. I have it running on macOS, including a very simple client app written in SwiftUI. Everything is working fine there. I've added iPadOS as a destination for the app as demonstrated in the WWDC video on DriverKit for iPadOS. The app builds and runs on my iPad, as expected (after a little work to conditionalize out my use of SystemExtensions.framework for installation on macOS). However, after installing and running the app on an iPad, the driver does not show up in Settings->General, nor in the app-specific settings pane triggered by the inclusion of a settings bundle in the app.
I've confirmed that the dext is indeed being included in the app bundle when built for iPadOS (in MyApp.app/SystemExtensions/com.me.MyApp.MyDriver.dext). I also can see in the build log that there's a validation step for the dext, and that seems to be succeeding.
I don't know why the app isn't being discovered -- or in any case surfaced to the user -- when the app is installed on the iPad. Has anyone faced this problem and solved it? Are there ways to troubleshoot installation/discovery of an embedded DriverKit extensions on iOS? Unlike on macOS, I don't really see any relevant console messages.
Hey!
I'am trying to write my own driver for usb serial device. I'am trying to subclass from IOUserUSBSerial
#include <DriverKit/IOService.iig>
#include <USBSerialDriverKit/IOUserUSBSerial.iig>
class NewDriver: public IOUserUSBSerial
{
public:
virtual kern_return_t
Start(IOService * provider) override;
};
but get a lot of errors such as
"IOUserUSBSerial::handleRxPacket(unsigned char*&, unsigned int&)", referenced from:
vtable for NewDriver in NewDriver.iig.o
"IOUserUSBSerial::handleInterruptPacket(unsigned char const*, unsigned int)", referenced from:
vtable for NewDriver in NewDriver.iig.o
"IOUserUSBSerial::free()", referenced from:
vtable for NewDriver in NewDriver.iig.o
"IOUserUSBSerial::init()", referenced from:
vtable for NewDriver in NewDriver.iig.o
"IOUserUSBSerial::initWith(IOBufferMemoryDescriptor*)", referenced from:
vtable for NewDriver in NewDriver.iig.o
"IOUserUSBSerial::_Dispatch(IOUserUSBSerial*, IORPC)", referenced from:
NewDriver::Start_Impl(IOService*) in NewDriver-e6d71af2158103084ce0c1eba7c6088d.o
NewDriver::_Dispatch(NewDriver*, IORPC) in NewDriver.iig.o
"vtable for IOUserSerial", referenced from:
IOUserSerial::IOUserSerial() in NewDriver.iig.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for IOUserUSBSerial", referenced from:
IOUserUSBSerial::IOUserUSBSerial() in NewDriver.iig.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"non-virtual thunk to IOUserUSBSerial::free()", referenced from:
vtable for NewDriver in NewDriver.iig.o
"non-virtual thunk to IOUserUSBSerial::init()", referenced from:
vtable for NewDriver in NewDriver.iig.o
"non-virtual thunk to IOUserUSBSerial::initWith(IOBufferMemoryDescriptor*)", referenced from:
vtable for NewDriver in NewDriver.iig.o
"non-virtual thunk to IOUserUSBSerial::handleRxPacket(unsigned char*&, unsigned int&)", referenced from:
vtable for NewDriver in NewDriver.iig.o
"non-virtual thunk to IOUserUSBSerial::handleInterruptPacket(unsigned char const*, unsigned int)", referenced from:
vtable for NewDriver in NewDriver.iig.o
ld: symbol(s) not found for architecture x86_64
If I making any implementations of this methods errors staying on. What Im doing wrong? Is there anywhere examples for USBSerialDriverKit? Didn't find anything on github
Hi all,
I got the entiltlements for the DriverKit PCI (primary match). so I added it to my driver app ID.
so, I can show the ~~transport.pci entitlement item on my provision profile.
However, macOS system still block the my driver, and log show the " Unsatisfied entitlements: com.apple.developer.driverkit.transport.pci"
I am trying to sign a DriverKit extension for distribution using a Developer ID provisioning profile, but when I try to import the profile to sign the dext I get the error "Platform: MacOS doesn't match platform DriverKit".
We requested the entitlement from Apple a few months ago and according to Apple Support it was approved (though we did not get any email directly from the DriverKit approval process). The App ID we are using appears to have the DriverKit capabilities that we need under "Additional Capabillities".
Our process right now is this:
Go to Certificates, Identifiers, and Profiles
Create a new Provisioning Profile and select Developer ID Distribution
Select the correct App ID
After creating and downloading the profile, import it into Xcode
Receive the error "Platform: MacOS does not match DriverKit"
According to https://developer.apple.com/documentation/driverkit/requesting_entitlements_for_driverkit_development#3557213, there should perhaps be a prompt adding DriverKit to the provisioning profile and not just the identifier, but we do not see this.
Has anybody else run into a similar issue and resolved it? I see a similar thread at https://developer.apple.com/forums/thread/710713, but that one is eight months old and doesn't appear to have a solution.
Hi All,
Is there a limit on the data size of input and output in IOConnectCallStructMethod?
I am working with CommunicatingBetweenADriverKitExtensionAndAClientApp.
It seems there a buffer size limit in OversizedDataStruct in the sample code.
typedef struct {
uint64_t foo;
uint64_t bar;
uint64_t largeArray[511];
} OversizedDataStruct;
If I tested by changing 511 to 0x1E00000(30MB), I got below error.
Thread 1: EXC_BAD_ACCESS (code=2, address=0x16f20fff8)
I need to get large image data(over 30 MBytes) from driver(dext) to user client application.
How can I transfer more than 30MB of data from driver to App with IOConnectCallStructMethod?
Or is there any other way without using IOConnectCallStructMethod?
Please help.
Hello,
I am trying to run a sample project from Apple's Developer Documentation that creates and interfaces with a DriverKit Dext. The project can be found here: Creating an Audio Device Driver.
I have followed all the steps in the README.md file: downloading the code, enabling automatic signing, building the app, moving it to the Applications folder, and launching it. I then open the app, press "Install Dext", enable it through System Preferences, and receive the message "SoundboardDriver has been activated and is ready to use."
However, the audio device does not appear in the MIDI app, there is no mention of it in the IORegistry, and I get the message “Driver extension is not running” when I try to press "Open User Client".
Is there another step I need to follow to get the app running? Perhaps it's an entitlement issue?
I don't see any error/fault message in the console app relating to the app or driver.
I am running MacOS 13.4.1 (22F82) and Xcode 14.3.1 (14E300c). I have tried with and without SIP enabled, but the issue persists.
Any help or guidance would be greatly appreciated.
Best,
Henry
Why can't Mac os 13.4 or xcode 14.3 build driverkit sign to run locally from xcode?
Why can the driverkit be successfully loaded, but the init and start functions are not executed?(sometimes it works sometimes it doesn't)
I have applied for DriverKit for PCI transport entitlements.
Selected Additional Capabilities DriverKit PCI (PrimaryMatch) for the app ID,
then made a profile and download. Check the profile, which also includes com. apple. developer. driverkit. transport. pci.
But when install this driverkit, log show the error:Unsatisfied entitlements: com.apple.developer.driverkit.transport.pci
After downloading the sample code from the provided link to Download, I performed the steps per the documentation:
You can set up the project to build with or without entitlements. To build without entitlements, do the following:
Temporarily turn off SIP, as described in the article Disabling and Enabling System Integrity Protection. After you’ve done this, confirm that SIP is disabled with the Terminal command csrutil status, and enter dext development mode with systemextensionsctl developer on, as described in the article Debugging and testing system extensions.
scott@Mac-mini-M1:CommunicatingBetweenADriverKitExtensionAndAClientApp $ csrutil status
System Integrity Protection status: disabled.
scott@Mac-mini-M1:CommunicatingBetweenADriverKitExtensionAndAClientApp $ systemextensionsctl developer
Developer mode is on
Select the DriverKitUserClientSample project and use the “Signing & Capabilities” tab to set the DriverKitSampleApp and CppUserClient targets to automatically managed code signing.
While still in the “Signing & Capabilities” tab, set the NullDriver target to manual code signing.
In the “Build Settings” tab, change the “Code Signing Identity” value to “Sign to Run Locally” for all three targets.
When I then go to build the NullDriver, I get the following failure:
error: Ad Hoc code signing is not allowed with SDK 'DriverKit 22.4' (in target 'NullDriver' from project 'DriverKitUserClientSample')
Something must be wrong in the combined effects of steps 3 and 4 in the settings for NullDriver given the resulting error. What is the correct procedure for DriverKit 22.4?
After DriverKit being released last year, I wonder if the background mode External accessory communication in Background Modes applies also for drivers made with DriverKit.
Is this mode only for products in the MFi group? If so, is there any plans to include DriverKit in this group in order to get data from an external device in the background, which is not in the MFi group?
I am new to macOS programming. I am trying to run an example from Apple that installs a "NullDriver" and then accesses it from a client CPP app (example available on line, driver kit, "com.example.apple-samplecode.dext-to-user-client)
I seem to be able to install the the DEXT correctly; I can see the system extension and the IOUserService. When I run the CPP client access program auto signed by Xcode, the app crashes with "CODESIGNING 1 Taskgated Invalid Signature". If I sign the app with "Sign to Run Locally", the app runs but is unable to connect to the IOUserService.
This is being run on Sonoma Beta 5 with a newly paid membership.
I am willing to attach whatever files are required but I wonder whether others have had the same code signing problem. My apology if I did not read a post with the answer I hope to find.
Gene