iokit

kIOReturnNotPermitted from IOServiceOpen connecting to SystemExtension IOService

孤街浪徒 提交于 2020-05-15 09:29:06
问题 I am trying to create a client connection to a SystemExtension IOService. I can see that my IOUserClient subclass is created ( init() and Start(IOService*) is called), but the return code from IOServiceOpen returns kIOReturnNotPermitted . I am making the call to IOServiceOpen from the same app that creates the activation request. Entitlements for app that makes the activation request / call to IOServiceOpen : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1

How to find the parent USB device of a serial port under macOS?

心不动则不痛 提交于 2020-01-05 02:13:44
问题 Here is how I was trying to enumerate all serial ports found on a Mac, and traverse up the device node tree to find the parent USB device for USB-serial adapters: #import <Foundation/Foundation.h> #import <IOKit/IOKitLib.h> #import <IOKit/serial/IOSerialKeys.h> #import <IOKit/usb/IOUSBLib.h> int main(int argc, const char * argv[]) { @autoreleasepool { CFMutableDictionaryRef keywordDict = IOServiceMatching(kIOSerialBSDServiceValue); io_object_t port = 0; io_iterator_t iterator = 0; kern_return

How to find the parent USB device of a serial port under macOS?

假装没事ソ 提交于 2020-01-05 02:12:09
问题 Here is how I was trying to enumerate all serial ports found on a Mac, and traverse up the device node tree to find the parent USB device for USB-serial adapters: #import <Foundation/Foundation.h> #import <IOKit/IOKitLib.h> #import <IOKit/serial/IOSerialKeys.h> #import <IOKit/usb/IOUSBLib.h> int main(int argc, const char * argv[]) { @autoreleasepool { CFMutableDictionaryRef keywordDict = IOServiceMatching(kIOSerialBSDServiceValue); io_object_t port = 0; io_iterator_t iterator = 0; kern_return

IOHIDEventSystemCreate on iOS6 failed

我怕爱的太早我们不能终老 提交于 2019-12-30 07:18:04
问题 IOHIDEventSystemCreate always return NULL on iOS6 (work fine on iOS5). Anyone know why? Example on iPhoneDevWiki #include <IOKit/hid/IOHIDEventSystem.h> #include <stdio.h> void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) { // handle the events here. printf("Received event of type %2d from service %p.\n", IOHIDEventGetType(event), service); } int main () { // Create and open an event system. IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL);

IOHIDEventSystemCreate on iOS6 failed

☆樱花仙子☆ 提交于 2019-12-30 07:17:09
问题 IOHIDEventSystemCreate always return NULL on iOS6 (work fine on iOS5). Anyone know why? Example on iPhoneDevWiki #include <IOKit/hid/IOHIDEventSystem.h> #include <stdio.h> void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) { // handle the events here. printf("Received event of type %2d from service %p.\n", IOHIDEventGetType(event), service); } int main () { // Create and open an event system. IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL);

IOService leaking for NO reason

送分小仙女□ 提交于 2019-12-24 07:38:10
问题 Okay, I am completely stumped and frustrated. I was working on an I/O Kit RAM Disk implementation and discovered that it wasn't unloading when my friend loaded it with kextload and then tried to unload it with kextunload . The reason for this was that none of the OSObject s which the kext allocated were being freed. However, on both my computer (running Mac OS 10.8.5) and a VM (running Mac OS 10.7) everything worked as expected. Eventually, I narrowed the problem down so much that I created a

How do I programmatically determine which Mac drive is the boot drive?

拟墨画扇 提交于 2019-12-24 06:45:02
问题 Great information on interrogating mounted drives via IOKit in this question. But is there a way to determine which of the devices returned by IOIteratorNext() is the boot drive? Or better yet, might there be a way to get just the boot drive in the iterator returned by IOServiceGetMatchingServices() ? 回答1: Booting is done from media, not a device per se. Devices have media, media have volumes. I don't believe that volumes are represented in IOKit. This is probably easiest using Disk

Disable ambient-light sensor screen dimming programmatically on OS X

不羁岁月 提交于 2019-12-22 04:02:03
问题 I've been digging around in the kernel code repo for days, but I just can't find this anywhere. I want to disable/enable/detect the state of the ambient-light sensor based screen dimming that many of the higher end Mac laptops have. This is the dimming that is activated by the "Automatically Adjust Brightness" checkbox in the Display control panel. Note that I'm NOT talking about the halfdim setting that causes the screen to dramatically dim right before it sleeps. I'm talking about the

Creating a ChargeInhibit Assertion (OS X 10.6.8)

一世执手 提交于 2019-12-21 22:04:05
问题 Platform (OS X 10.6.8) - [Macbook Pro - this is important as I want to deal with the battery handling - not applicable for a desktop] Forgive me if I've made a basic mistake that I don't see, as I haven't written any C/C++ in five years or more, and I'm not fully following the way apple APIs want you to deal with them, so this is what my question regards. Basically, I want to be able to inhibit charging from the AC adaptor at my command, so that I can choose whether to charge my laptop or not

IOKit device adding/removal notifications - only fire once?

混江龙づ霸主 提交于 2019-12-21 14:36:20
问题 I have been trying to get notified when a specific USB device is added or removed. I have read 'Accessing Hardware From Applications' document and have a bare-bones demo application, mainly based on the code provided in that document. It works the first time a device is added or removed, but after that my callbacks never get called. I cannot work out why? Can anyone spot where I am going wrong? (xcode project if you would like to test) http://monkeyfood.com/testIOKitNOtificaiton.zip Thanks. /