USBDriverKit

RSS for tag

Develop drivers for USB-based devices using USBDriverKit.

Posts under USBDriverKit tag

45 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

launching a modal dialog in application crashing in macOS Sonoma 14.2.1
2024-01-09 17:00:09.747 java[6069:574042] Suppressing invocation of -[NSApplication runModalForWindow:]. -[NSApplication runModalForWindow:] cannot run inside a transaction begin/commit pair, or inside a transaction commit. Consider switching to an asynchronous equivalent. ( 0 AppKit 0x00007ff80f886ffb -[NSApplication runModalForWindow:] + 365 1 AppKit 0x00007ff8103c9ffe -[NSSavePanel runModal] + 414 2 AppKit 0x00007ff8103d3dae -[NSSavePanel(Deprecated) runModalForDirectory:file:types:] + 227 3 libawt_lwawt.dylib 0x0000000122ece116 -[CFileDialog safeSaveOrLoad] + 363 4 Foundation 0x00007ff80cfa1bd5 __NSThreadPerformPerform + 178 5 CoreFoundation 0x00007ff80c0877d6 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 6 CoreFoundation 0x00007ff80c087779 __CFRunLoopDoSource0 + 157 7 CoreFoundation 0x00007ff80c087548 __CFRunLoopDoSources0 + 215 8 CoreFoundation 0x00007ff80c0861b8 __CFRunLoopRun + 919 9 CoreFoundation 0x00007ff80c085859 CFRunLoopRunSpecific + 557 10 Foundation 0x00007ff80cf81481 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216 11 libawt_lwawt.dylib 0x0000000122eeb1c2 Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl + 324 12 ??? 0x00000001105eae47 0x0 + 4569607751 13 ??? 0x00000001105daffd 0x0 + 4569542653 14 ??? 0x00000001105daffd 0x0 + 4569542653 ) this is the error am getting in logs, where the modal dialog box is been blocked by some external application or for some other reasons
1
0
563
Jan ’24
USB DriverKit returning large asynchronous data
this is a repost with more appropriate tags. The original is here: https://developer.apple.com/forums/thread/744268 Can anyone advise, or give example of, communicating large (>128 byte) incoming buffers from a dext to a user-space app? My specific situation is interrupt reads from a USB device. These return reports which are too large to fit into the asyncData field of an AsyncCompletion call. Apple's CommunicatingBetweenADriverKitExtensionAndAClientApp sample shows examples of returning a "large" struct, but the example is synchronous. The asynchronous example returns data by copying into a IOUserClientAsyncArgumentsArray, which isn't very big. I can allocate a single buffer larger than 4K in user space, and communicate that buffer to my driver as an IOMemoryDescriptor when I set up my async callback. The driver retains the descriptor, maps it into its memory space and can thus write into it when the hardware returns interrupt data. The driver then calls AsyncCompletion, which will cause my user-side callback to be called, so the user side software knows that there's new data available in the previously allocated buffer. That's fine, it works, but there are data race problems - since USB interrupt reads complete whenever the hardware has provided data, incoming completions happen at unpredictable times, so the shared buffer contents could change while the user side code is examining them. Is there an example somewhere of how to deal with this? Can I allocate memory on the driver side on demand, create an IOMemoryDescriptor for it and return that descriptor packed inside the asyncData? If so, how does the driver know when it can relinquish that memory? I have a feeling there's something here I just don't understand...
0
0
506
Jan ’24
What are command line tools?
I was trying to hide some external drives from desktop, I know I can do it from finder preferences, but it will hide all my external drives from desktop. I want drive A, B, C to be visible on desktop but don't want drive D to be visible. Some website suggest this solution: sudo SetFile -a V /Volumes/"Drive Name" but it says I need command line tools, since I was in terminal, and prompt come from MacOS itself, I stared installation. But what are this tools actually is it sahe to install it? And why this tool taking 2.35GB of storage just to hide one icon from desktop?
1
0
481
Dec ’23
Control HID USB Device from iPad?
I have a custom HID USB device that I can control on Mac with IOKit via the default HID MacOS driver. I am using IOHIDManager to detect it and send reports to it. I would like to extend this capability to iPad but the full IOKit framework is not supported on iOS/iPadOS. I saw that USBDriverKit is now supported on iPads with an M1 chip or newer. But, both MacOS and Windows can operate the device with their generic HID driver. As such, having to create a whole custom driver to interact with an HID device on iOS is really overkill. Would registering it in the MFi Program and operating it with the External Accessory framework be the correct route to take here? Or is there another framework for controlling HID devices on iPad over USB that I am not aware of?
2
0
814
Dec ’23
Unable to link to or even find USBDriverKit for iPadOS
According to Apple's documentation USBDriverKit for iPadOS has been available since DriverKit 19 and the M1 iPad were released. However, using Xcode 15.0.1, I am unable to link to or even find USBDriverKit from within Xcode. Is the documentation incorrect? If not what do I need to do in order to access and leverage USBDriverKit? From what I've read, USBSerialDriverKit is not available. As I have a USB based serial device that I want to use from the iPad, the next obvious step is to write my own USB device extension using USBDriverKit as a provider. If you have experience with this and can definitively say whether or not what I'm attempting is even within the realm of possibility, please chime in. Thanks. -Michael
2
0
676
Dec ’23
How to develop a driver extension for a USB mass storage device
I am currently in the process of developing a DEXT for a USB based external mass storage device using the USBDriverKit framework. IOUSBHostInterface is used as the provider to communicate with the interface's endpoints and I am successful in it. As per the IOUSBHostInterface documentation, To use a host interface object, call Open to create a new session between the interface and your driver. After successfully opening your session, you can request information from the interface and set up pipes to communicate with the interface's endpoints. Remember to close the session you opened in the Stop method of your driver. However, calling Open gains exclusive access to the USB interface and does not allow other services to access the interface. Also, to let go of the exclusive access, Close method can be called but in the Stop method which is called only once during the lifecycle of the extension (when the DEXT is unloaded). As a result of this, Apple's mass storage related KEXTs (media and partition related specifically) do not match the interface and so the filesystem of the drive in question does not get mounted whenever the DEXT has matched the interface. Is this exclusive access a limitation of USBDriverkit or is there any way to get around this issue in this case?
2
0
610
Nov ’23
DriverKit target in iPad app, missing libclang_rt.profile_driverkit.a
I'm trying to build the DriverKit template driver target in an Xcode project which contains an app targeting iPadOS 17. I've made no modifications to the DriverKit template. When building, I get this link error ld: file cannot be open()ed, errno=2 path=/Applications/Xcode 15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.profile_driverkit.a in '/Applications/Xcode 15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.profile_driverkit.a' anyone know how to fix this? My search turned up something about building llvm from sources, which seems like overkill to put a DriverKit driver into an iPad app.
3
1
924
Nov ’23
Driver kit issue with OS 17.1
In my application, I have used DriverKit USB Transport - VendorID. Now whenever I am trying to install my application using driver kit development profile, it throws me error that profile is not valid. Now, If I try to install the app using Adhoc profile, then I am able to install it. Can you update us, is there any changes are there in 17.1 OS with development profile.
2
0
387
Nov ’23
DriverKit | Memory limitations of AsyncCallback
We implemented communication between Swift App and DriverKit driver using IOConnectCallAsyncStructMethod. void USBDriverClass::registerAsyncCallback(){   // Async required variables   notificationPort = NULL;   machNotificationPort = NULL;   runLoopSource = NULL;       // Async initialization   globalRunLoop = CFRunLoopGetMain();   CFRetain(globalRunLoop);       notificationPort = IONotificationPortCreate(kIOMainPortDefault);   if (notificationPort == NULL)   {     printf("Failed to create notification port for application.\n");   }       machNotificationPort = IONotificationPortGetMachPort(notificationPort);   if (machNotificationPort == 0)   {     printf("Failed to get mach notification port for application.\n");   }       runLoopSource = IONotificationPortGetRunLoopSource(notificationPort);   if (runLoopSource == NULL)   {     printf("Failed to get run loop for application.\n");   }       // Establish our notifications in the run loop, so we can get callbacks.   CFRunLoopAddSource(globalRunLoop, runLoopSource, kCFRunLoopDefaultMode);       // Establish our "AsyncCallback" function as the function that will be called by our Dext when it calls its "AsyncCompletion" function.   // We'll use kIOAsyncCalloutFuncIndex and kIOAsyncCalloutRefconIndex to define the parameters for our async callback   // This is your callback function. Check the definition for more details.   asyncRef[kIOAsyncCalloutFuncIndex] = (io_user_reference_t)AsyncCallback;   // Use this for context on the return. For example you might pass "this". But since this example is entirely static, we'll skip that step.   asyncRef[kIOAsyncCalloutRefconIndex] = (io_user_reference_t)NULL;       kern_return_t ret = kIOReturnSuccess;   uint8_t words = 4;       size_t inputSize = sizeof(StructA);   StructA structA;       structA.tag = 1;   structA.length = 0;   structA.values[0] = 0x106000;   structA.values[1] = words * sizeof(uint32_t);       size_t outputSize = sizeof(OutputData);   OutputData data;   printf("registerAsyncCallback called");       ret = IOConnectCallAsyncStructMethod(connection, MessageType_RegisterAsyncCallback, machNotificationPort, asyncRef, kIOAsyncCalloutCount, &structA, inputSize, &data, &outputSize);   if (ret != kIOReturnSuccess)   {     printf("IOConnectCallAsyncStructMethod failed with error: 0x%08x.\n", ret);   } } And when we get data from device we send data back from Driver to Swift app ivars->mUSBProbeDriverClient->AsyncCompletion(ivars->streamingDataCallback, kIOReturnSuccess, asyncData, 16); Driver should transfer data to swift app asynchronously when it's provided by USB device so we can not transfer struct synchronously. Async call back has limitation of 16 of uint64_t only and our application require larger data transfer. The logical way to transfer data using a memory buffer and as per Apple documentation they are providing this using IODataQueueDispatchSource. But they have not provided any example or showed how to use this. How to use fill buffer and use it in swift app using IODataQueueDispatchSource?
1
1
1.1k
Nov ’23
Can't use <memory> <vector> and some other includes with DriverKit framework
I have XCode 15.0 project with system extension target (c++), and can't include some standard headers, like or . Compilation error: __debug file not found. Base SDK and Supported platforms: DriverKit. Reinstallation of XCode didn't help, as well as manual copy of __debug file into framework include folder. No problems with other C++ targets (command line tools, etc) Please reply if you have identical projects, but without compilation errors. May be that is my system configuration problem and not common DriverKit feature ?
1
0
383
Nov ’23
How to let the system take over a device after the DriverKit process exits?
I have created a USB filter using Mac DriverKit, but the filter is unable to retrieve configuration information during startup. After the USB filter has started and registered the service, my app can send the configuration information to the filter. Therefore, I would like to know if there is a way to exit the USB filter and allow the system to take control of the USB device once the filter has exited. I have tried calling Terminate(0), but it did not work as even after the USB filter exited, the Finder still couldn't display the USB device.
0
0
415
Nov ’23
How does the driverkit serve as a bridge between hardware and the system?
I want to use DriverKit to develop a USBDriver, which serves as a bridge between USB devices and the system. All messages between USB devices and the system will be forwarded through the USBDriver. Can anyone give me some tips or suggestions? What API should I use? I couldn't find anything like this in the documentation or sample code. class MyUSBDriver: public IOUserClient { public: virtual bool init() override; virtual kern_return_t Start(IOService * provider) override; virtual kern_return_t Stop(IOService * provider) override; virtual void free() override; virtual kern_return_t GetRegistryEntryID(uint64_t * registryEntryID) override; virtual kern_return_t NewUserClient(uint32_t type, IOUserClient** userClient) override; virtual kern_return_t ExternalMethod(uint64_t selector, IOUserClientMethodArguments* arguments, const IOUserClientMethodDispatch* dispatch, OSObject* target, void* reference) override; }; I am now able to retrieve the device descriptor in the Start method IOUSBHostDevice *device = OSDynamicCast(IOUSBHostDevice, provider); if (device) { const IOUSBDeviceDescriptor *deviceDescriptor = device->CopyDeviceDescriptor(); if (deviceDescriptor) { uint16_t idVendor = deviceDescriptor->idVendor; uint16_t idProduct = deviceDescriptor->idProduct; uint8_t iSerialNumber = deviceDescriptor->iSerialNumber; IOUSBHostFreeDescriptor(deviceDescriptor); } }
0
0
418
Nov ’23
cannot install CreatingAnAudioDeviceDriver app on ipados 17! Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.yOSaDQ/extracted/SimpleAudio.app/SystemExtensions/com.xreal.nrsdk.driver.demo.Driver.d
Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.yOSaDQ/extracted/SimpleAudio.app/SystemExtensions/com.xreal.nrsdk.driver.demo.Driver.dext : 0xe8008015 (A valid provisioning profile for this executable was not found.) Verify that the Developer App certificate for your account is trusted on your device. Open Settings on the device and navigate to General -> VPN & Device Management, then select your Developer App certificate to trust it.
2
2
802
Oct ’23
Using DriverKit to simulate graphics tablet input
Hi, My goal is to enable this project https://github.com/evidlo/remarkable_mouse to provide native tablet inputs with full information to applications on MacOS, allowing me to reuse my reMarkable tablet for the computer instead of having to buy yet another device, such as a Wacom tablet or an iPad Pro for sidecar when the necessary hardware is already in my posession. I would like to understand whether it is possible to use DriverKit in order to simulate a graphics tablet input device with extra inputs such as pressure and tilt in user-space. Or is this something where IOKit or other comes into play, requiring the creation of a kernel space driver? In either case, what would be the right steps to take? How would I create a virtual device and what are the limitations? If you have the knowledge, how complex would you consider this project to be? The path should basically be some inter-process communication from remarkable_mouse, possibly file-based, triggering tablet events through the driver. At least in the first stage. I assume better performance would be achieved if the whole system was self-contained but porting the reMarkable communication is another challenge on its own. I am experienced developing in other environments but MacOS and driver development are fairly new to me. I've read through the documentation on how to handle the tablet events but creating them seems much murkier. I have searched around for this specific topic without getting much. An open-source tablet driver would be a great place to start but sadly I found none. I've also inquired with ChatGPT but only got high level tips and pseudocode. Any help is greatly appreciated, thank you!
0
0
517
Oct ’23
Is it possible to synchronously request configuration information within the Start method of DriverKit?
Is there a way to synchronously retrieve configuration information from the app or read configuration information from a file within the Start method of DriverKit? I have attempted to use OSMappedFile to read a file, but my driver crashes or I receive the error message "Sandbox: com.injection.epusbfilter.dext(20610) deny(1) file-read-data /private/tmp/driverkit_config.txt" in the console, even though I have set com.apple.security.app-sandbox to false. OSMappedFile *mappedFile; do { const char *path = "/private/tmp/cfg"; // 创建 OSMappedFile 实例 kern_return_t result = OSMappedFile::createFromPath(path, 0, 0, &mappedFile); if (result != KERN_SUCCESS) { Log("Failed to create and map the file."); ret = -1; break; } *size = mappedFile->size(); // 获取映射到内存中的数据 char *charData = reinterpret_cast<char *>(const_cast<void *>(mappedFile->data())); Log("get cfg:%s", charData); if (strlen(charData) > 0) { if (charData[0] == '1') { ret = 1; break; } } else { ret = -2; break; } } while(false); mappedFile->free();
2
0
431
Oct ’23