iokit

Memory Leak - Not Sure How/Where to CFRelease() CFSet

五迷三道 提交于 2019-12-11 16:44:44
问题 I'm yet again struggling with a memory leak, and need some help figuring this one out. I know (or am pretty sure) the CFSet(s) are the problem here. I assume I need to CFRelease() them, but am not sure how to accomplish this since I also need to return a CFSet in USBDeviceCount(). Any help would be appreciated! Thank you! Here's the code (which seemingly works great! except for the leaks): // New USB device has been added (callback function) static void Handle_DeviceMatchingCallback(void

Workaround for a certain IOServiceOpen() call requiring root privileges

自作多情 提交于 2019-12-11 15:33:17
问题 Background It is possible to perform a software-controlled disconnection of the power adapter of a Mac laptop by creating an DisableInflow power management assertion. Code from this answer to an SO question can be used to create said assertion. The following is a working example that creates this assertion until the process is killed: #include <IOKit/pwr_mgt/IOPMLib.h> #include <unistd.h> int main() { IOPMAssertionID neverSleep = 0; IOPMAssertionCreateWithName(kIOPMAssertionTypeDisableInflow,

Which KPI Library Is IODeviceMemory Declared In?

旧街凉风 提交于 2019-12-11 07:34:44
问题 Google yields no insight. I wasn't able to figure it out by searching around in the kernel source. I'm using the open source IOProxyVideoFamily to implement a virtual framebuffer. I just replaced a C-style cast to IODeviceMemory with OSDynamicCast, because I suspect that cast will fail. If so I will know how to fix it. But I can't find the KPI library that contains it. IODeviceMemory has been in the OS since 10.0, and is required for PCI card drivers. $ kextlibs -undef-symbols /System/Library

Passing CFDictionary via IOKIt command

烈酒焚心 提交于 2019-12-11 07:29:14
问题 I'm looking for a universal method to configure parameters from userspace agent to kernel since there is no Mac equivalent to windows registry where driver can directly access any key in this table using ZwQueryValueKey command. Therefore, I'd like to pass a dynamic list of variables through CFDictionary . In IOConnectCallMethod there's a way to pass input pointer, but the question is if I can pass a CFDictionary or CFDictionaryRef instead of just a simple struct. I saw that there are some

Figuring out data from IOUSBInterface pipes

我们两清 提交于 2019-12-11 04:33:36
问题 I am coding for a Mac app that sends and receives messages to a Personel Video Recorder using with the IOKit. I need to send messages to change its status and it needs to give me info about the video like resolution or if its recording. I realize that I have to find the right messages to send it, so first I thought I could receive some messages from it first. I have already found the interface for the device. How would I be able to dump the received messages? Here is a log from USB Probe:

IONotificationPortCreate function call generates compiler error

浪尽此生 提交于 2019-12-11 03:12:25
问题 I am having an issue with the IONotificationCreatePort function in IOKit: var NotificationPort = IONotificationPortCreate(MasterPort) IONotificationPortSetDispatchQueue(NotificationPort, DispatchQueue) gives the following compiler error when NotificationPort is used in the function call in the second line 'Unmanaged IONotificationPort' is not identical to 'IONotificationPort' if I use the following code based on the information in the Using Swift with Cocoa and Objective-C document, it

Can't edit IORegistryEntry

不想你离开。 提交于 2019-12-11 03:04:13
问题 I am creating a software on Mac and I would like to change the value of an IORegistryEntry. I can view it on the IORegistryExplorer, but I can't edit it. So it's my understanding that I have to edit it via code. Here is my code: CFMutableDictionaryRef matchingDict = IOServiceNameMatching("AppleUSBMultitouchDriver"); io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict); if(service) { CFStringRef manufacturer = IORegistryEntryCreateCFProperty(service, CFSTR(

In OSX, how to determine which keyboard generated an NSEvent?

无人久伴 提交于 2019-12-10 14:22:07
问题 I've been trying to determine (from within the event handler) which keyboard triggered the event. I've been using these two posts: http://www.cocoabuilder.com/archive/cocoa/229902-which-keyboard-barcode-scanner-did-the-event-come-from.html http://www.cocoabuilder.com/archive/cocoa/274586-getting-keyboard-type-carbon-vs-cg.html#274586 In the second article, the author successfully separate out his keyboards using a Carbon technique, but attempting the same trick using Cocoa fails. On my own

Monitor changes on Thunderbolt port connection

删除回忆录丶 提交于 2019-12-10 11:22:22
问题 I am working on a requirement where i need to monitor changes in Thunderbolt port connection. (When Thunderbolt cable is connected or disconnected). I tried to use IOServiceMatching(kIOUSBInterfaceClassName) from IOKit framework but i cannot monitor changes on Thunderbolt port. Is there any way i can achieve it? Any help is appreciated. 回答1: Thunderbolt devices (except displays that use the DisplayPort portion of the Thunderbolt port) are PCI devices, not USB, so they will show up in the

Mac Mouse/Trackpad Speed Programmatically

我的未来我决定 提交于 2019-12-10 10:09:26
问题 I'm trying to change the mouse tracking speed (Notice: Not acceleration) for an application I'm working on. I've searched everywhere for a way to do this, but couldn't find anything. I suspect that has to do with the value I give in this function on the IOKit/hidsystem Framework: IOHIDSetAccelerationWithKey(handle, CFSTR(kIOHIDMouseAccelerationType), mouseAcceleration); Being mouseAcceleration the value, I suspect there is a hex value that defines both acceleration and speed. Does anyone came