The DiskArbitration
framework on macOS provides a simple way to intercept volumes mounts and authorise it or not using DARegisterDiskMountApprovalCallback
.
I'm looking for something similar for all the other USB devices like HID devices, network interfaces and in general every USB peripheral.
I'm moving in the direction of IOKit
: Introduction to USB Device Interface Guide and I can see how to communicate with a USB device but I can't find anything similar to an arbitration mechanism.
Any idea? Kernel extension isn't an option.
macOS 11 update
With macOS a new AUTH event called ES_EVENT_TYPE_AUTH_IOKIT_OPEN
has been introduced.
The event is called correctly but digging in the object headers I fund:
/**
* @brief Open a connection to an I/O Kit IOService
*
* @field user_client_type A constant specifying the type of connection to be
* created, interpreted only by the IOService's family.
* This field corresponds to the type argument to IOServiceOpen().
* @field user_client_class Meta class name of the user client instance.
*
* This event is fired when a process calls IOServiceOpen() in order to open
* a communications channel with an I/O Kit driver. The event does not
* correspond to driver <-> device communication and is neither providing
* visibility nor access control into devices being attached.
*/
typedef struct {
uint32_t user_client_type;
es_string_token_t user_client_class;
uint8_t reserved[64];
} es_event_iokit_open_t;
:(
This screws my plans:
The event does not correspond to driver <-> device communication and is neither providing visibility nor access control into devices being attached.
Any idea on how to get the device info in another way?