How to toggle usb device

Can i use iokit usb lib to disable build-in camera?

Answered by DTS Engineer in 844832022

Can i use iokit usb lib to disable build-in camera?

No, at least not reliably. While, in theory, the USB user clients* can be opened with exclusive access (thus blocking the access of other clients), in practice I think race condition issues mean that it would be hard to make it reliable. I think the better approach would be to block the user client open itself, particularly with the new Endpoint Security API described here.

*Note that the IOUSBHost framework is the modern API, not the older IOUSBLib API.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

my env: macos15.5 intel i5

Can i use iokit usb lib to disable build-in camera?

No, at least not reliably. While, in theory, the USB user clients* can be opened with exclusive access (thus blocking the access of other clients), in practice I think race condition issues mean that it would be hard to make it reliable. I think the better approach would be to block the user client open itself, particularly with the new Endpoint Security API described here.

*Note that the IOUSBHost framework is the modern API, not the older IOUSBLib API.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

ES API can block opening device, but not blocking the access in process.

ES API can block opening device, but not blocking the access in process.

Well... yes.

The problem here is that, to a large extent and by design, the actual process of moving data from the physical device to the target app isn't really "visible" to the larger system. In some cases, that entire process is largely done by mapping physical pages from the physical I/O pages (meaning, the memory that the DMA hardware wrote to) directly into the address space of the final receiving app, then using "ring buffer" timing logic to cycle through those buffers. That means that, from the larger system perspective, the actual data transfer process is largely invisible. It also means that there isn't really any good way to disrupt that process, short of tearing down the driver stack via hotplug. That's effectively what the IOUSBHost framework does, however, other issues (as noted above) make that unreliable.

What's the actual product you're trying to build here? From a security/reliability perspective ES is the best option, however, if the user has some "involvement" in the process there maybe other options.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

How to toggle usb device
 
 
Q