Фреймворк DiskArbitration
в macOS предоставляет простой способ перехватывать монтирование томов и авторизовать его или нет с помощью DARegisterDiskMountApprovalCallback
.
Я ищу что-то подобное для всех других USB-устройств, таких как устройства HID, сетевые интерфейсы и вообще все периферийные устройства USB.
Я двигаюсь в направлении IOKit
: Введение в руководство по интерфейсу USB-устройства, и я вижу, как взаимодействовать с USB-устройством, но не могу найти ничего похожего на механизм арбитража.
Есть идеи? Расширение ядра не вариант.
обновление macOS 11
В macOS появилось новое событие AUTH под названием ES_EVENT_TYPE_AUTH_IOKIT_OPEN
. Событие называется правильно, но копаясь в заголовках объектов, я финансирую:
/**
* @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;
:(
Это разрушает мои планы:
The event does not correspond to driver <-> device communication and is neither providing visibility nor access control into devices being attached.
Любая идея о том, как получить информацию об устройстве другим способом?