我有一个USB HID设备(没有鼠标,没有键盘),在启动时插入OS X Mojave即可。当我尝试通过libusb与之通信时,我收到设备忙的错误,直到拔下USB设备并重新插入。之后,它可以正常工作。
在启动时未插入USB设备并且在启动后立即将其插入时,它也可以正常工作。
在/ Library / Extensions中安装了一个已签名的无代码kext。
所有这些行为都是与莫哈韦有关的。在所有以前的版本(El Capitan等)上,都没有发生此问题。在以前的版本中,kext位于/ System / Library / Extensions中。但这在Mojave上根本不起作用,因此我将其移至/ Library / Extensions,结果如上所述。
在info.plist中添加值为“ Root”的键“ OSBundleRequired”并没有更改它,我的想法已经用完了。
这是使用的Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- This is a dummy driver which binds to SG-LOCK. It -->
<!-- contains no actual code; its only purpose is to -->
<!-- prevent Apple's USBHID driver from exclusively -->
<!-- opening the device. -->
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.domain.driver.dummy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.0d1</string>
<key>IOKitPersonalities</key>
<dict>
<key>USB Device</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBInterface</string>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
<key>idProduct</key>
<integer>1000</integer>
<key>idVendor</key>
<integer>1000</integer>
</dict>
</dict>
</dict>
</plist>
在这两种情况下使用ioreg进行检查都将给出以下输出:
在没有访问权限的引导后立即输出ioreg -lirc IOUSBHostDevice输出:
+-o MyLock USB Key@14400000 <class IORegistryEntry:IOService:IOUSBNub:IOUSBDevice, id 0x10000033b, registered, matched, active, busy 0 (64 ms), retain 24>
| {
| "sessionID" = 2407103480
| "USBSpeed" = 1
| "IOServiceLegacyMatchingRegistryID" = 4294968128
| "idProduct" = 4096
| "bDeviceClass" = 0
| "IOPowerManagement" = {"PowerOverrideOn"=Yes,"CapabilityFlags"=32768,"MaxPowerState"=2,"DevicePowerState"=2,"ChildrenPowerState"=1,"DriverPowerState"=0,"CurrentPowerState"=2}
| "bcdDevice" = 1
| "USB Product Name" = „MyLock USB Key"
| "AppleUSBAlternateServiceRegistryID" = 4294968128
| "locationID" = 339738624
| "bDeviceSubClass" = 0
| "kUSBCurrentConfiguration" = 1
| "IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
| "bDeviceProtocol" = 0
| "USBPortType" = 0
| "USB Vendor Name" = „MyLock"
| "idVendor" = 1447
| "IOGeneralInterest" = "IOCommand is not serializable"
| "kUSBVendorString" = „MyLock"
| "IOClassNameOverride" = "IOUSBDevice"
| }
|
+-o AppleUSBHostLegacyClient <class IORegistryEntry:IOService:AppleUSBHostLegacyClient, id 0x100000341, !registered, !matched, active, busy 0, retain 9>
| {
| "kUSBHostDeviceForceSuspend" = No
| "IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=1,"CapabilityFlags"=65536,"MaxPowerState"=2,"DriverPowerState"=1}
| }
|
+-o AppleUSBHostCompositeDevice <class IORegistryEntry:IOService:AppleUSBHostCompositeDevice, id 0x100000346, !registered, !matched, active, busy 0, retain 4>
| {
| "IOProbeScore" = 50000
| "CFBundleIdentifier" = "com.apple.driver.usb.AppleUSBHostCompositeDevice"
| "IOProviderClass" = "IOUSBHostDevice"
| "IOClass" = "AppleUSBHostCompositeDevice"
| "bDeviceSubClass" = 0
| "IOMatchCategory" = "IODefaultMatchCategory"
| "kUSBPreferredConfiguration" = 1
| "bDeviceClass" = 0
| }
|
+-o IOUSBHostInterface@0 <class IORegistryEntry:IOService:IOUSBNub:IOUSBInterface, id 0x100000348, registered, matched, active, busy 0 (58 ms), retain 11>
| {
| "USBPortType" = 0
| "IOCFPlugInTypes" = {"2d9786c6-9ef3-11d4-ad51-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
| "bcdDevice" = 1
| "USBSpeed" = 1
| "idProduct" = 4096
| "bConfigurationValue" = 1
| "bInterfaceSubClass" = 0
| "locationID" = 339738624
| "IOGeneralInterest" = "IOCommand is not serializable"
| "IOServiceLegacyMatchingRegistryID" = 4294968137
| "IOClassNameOverride" = "IOUSBInterface"
| "AppleUSBAlternateServiceRegistryID" = 4294968137
| "idVendor" = 1447
| "bInterfaceProtocol" = 0
| "bAlternateSetting" = 0
| "bInterfaceNumber" = 0
| "bInterfaceClass" = 3
| }
|
+-o IOUSBHostHIDDevice@14400000,0 <class IORegistryEntry:IOService:IOHIDDevice:IOUSBHostHIDDevice, id 0x100000425, registered, matched, active, busy 0 (21 ms), retain 8>
| {
| "IOClass" = "IOUSBHostHIDDevice"
| "Transport" = "USB"
| "BootProtocol" = 0
| "IOPersonalityPublisher" = "com.apple.driver.usb.IOUSBHostHIDDeviceSafeBoot"
| "HIDDefaultBehavior" = ""
| "MaxInputReportSize" = 23
| "IOProviderClass" = "IOUSBHostInterface"
| "Manufacturer" = „MyLock"
| "Product" = „MyLock USB Key"
| "DeviceUsagePairs" = ({"DeviceUsagePage"=65440,"DeviceUsage"=1})
| "IOProbeScore" = 50000
| "MaxOutputReportSize" = 23
| "ReportDescriptor" = <06a0ff0901a10109021580257f75089517810209031580257f750895179102c0>
| "IOUserClientClass" = "IOHIDLibUserClient"
| "bInterfaceSubClass" = 0
| "bInterfaceClass" = 3
| "IOCFPlugInTypes" = {"7DDEECA8-A7B4-11DA-8A0E-0014519758EF"="IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin","FA12FA38-6F1A-11D4-BA0C-0005028F18D5"="IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin"}
| "CountryCode" = 0
| "VendorID" = 1447
| "VersionNumber" = 1
| "IOMatchCategory" = "IODefaultMatchCategory"
| "CFBundleIdentifier" = "com.apple.driver.usb.IOUSBHostHIDDevice"
| "PrimaryUsage" = 1
| "LocationID" = 339738624
| "ProductID" = 4096
| "Elements" = ({"ReportID"=0,"ElementCookie"=1,"CollectionType"=1,"Type"=513,"VariableSize"=0,"Elements"=({"VariableSize"=0,"UnitExponent"=0,"IsRelative"=No,"UsagePage"=65440,"Max"=127,"IsArray"=No,"Min"=18446744073709551488,"$
| "IOGeneralInterest" = "IOCommand is not serializable"
| "ReportInterval" = 8000
| "PrimaryUsagePage" = 65440
| "MaxFeatureReportSize" = 0
| "InputReportElements" = ({"ReportID"=0,"ElementCookie"=50,"Size"=184,"ReportCount"=1,"Type"=1,"VariableSize"=0,"UsagePage"=0,"ReportSize"=184,"Usage"=0})
| }
|
+-o IOHIDInterface <class IORegistryEntry:IOService:IOHIDInterface, id 0x10000043e, registered, matched, active, busy 0 (6 ms), retain 6>
| {
| "MaxOutputReportSize" = 23
| "VendorID" = 1447
| "CountryCode" = 0
| "Product" = „MyLock USB Key"
| "VersionNumber" = 1
| "PrimaryUsage" = 1
| "LocationID" = 339738624
| "BootProtocol" = 0
| "ProductID" = 4096
| "DeviceUsagePairs" = ({"DeviceUsagePage"=65440,"DeviceUsage"=1})
| "Transport" = "USB"
| "ReportInterval" = 8000
| "ReportDescriptor" = <06a0ff0901a10109021580257f75089517810209031580257f750895179102c0>
| "HIDDefaultBehavior" = ""
| "PrimaryUsagePage" = 65440
| "Manufacturer" = „MyLock"
| "MaxFeatureReportSize" = 0
| "MaxInputReportSize" = 23
| }
|
+-o IOHIDLibUserClient <class IORegistryEntry:IOService:IOUserClient:IOHIDLibUserClient, id 0x1000004fb, !registered, !matched, active, busy 0, retain 6>
{
"DebugState" = {"EventQueueMap"=(),"Privileged"=Yes}
"IOUserClientCreator" = "pid 86, loginwindow"
}
ioreg -lirc带有访问权限的重新插入后的IOUSBHostDevice输出:
+-o MyLock USB Key@14400000 <class IORegistryEntry:IOService:IOUSBNub:IOUSBDevice, id 0x1000006e5, registered, matched, active, busy 0 (3280 ms), retain 22>
| {
| "sessionID" = 962218587513
| "USBSpeed" = 1
| "IOServiceLegacyMatchingRegistryID" = 4294969063
| "idProduct" = 4096
| "bDeviceClass" = 0
| "IOPowerManagement" = {"PowerOverrideOn"=Yes,"CapabilityFlags"=32768,"MaxPowerState"=2,"DevicePowerState"=2,"ChildrenPowerState"=2,"DriverPowerState"=0,"CurrentPowerState"=2}
| "bcdDevice" = 1
| "USB Product Name" = „MyLock USB Key"
| "AppleUSBAlternateServiceRegistryID" = 4294969063
| "locationID" = 339738624
| "bDeviceSubClass" = 0
| "kUSBCurrentConfiguration" = 1
| "IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
| "bDeviceProtocol" = 0
| "USBPortType" = 0
| "USB Vendor Name" = „MyLock"
| "idVendor" = 1447
| "IOGeneralInterest" = "IOCommand is not serializable"
| "kUSBVendorString" = „MyLock"
| "IOClassNameOverride" = "IOUSBDevice"
| }
|
+-o AppleUSBHostLegacyClient <class IORegistryEntry:IOService:AppleUSBHostLegacyClient, id 0x1000006e8, !registered, !matched, active, busy 0, retain 9>
| {
| "kUSBHostDeviceForceSuspend" = No
| "IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=1,"CapabilityFlags"=65536,"MaxPowerState"=2,"DriverPowerState"=1}
| }
|
+-o AppleUSBHostCompositeDevice <class IORegistryEntry:IOService:AppleUSBHostCompositeDevice, id 0x1000006f4, !registered, !matched, active, busy 0, retain 4>
| {
| "IOProbeScore" = 50000
| "CFBundleIdentifier" = "com.apple.driver.usb.AppleUSBHostCompositeDevice"
| "IOProviderClass" = "IOUSBHostDevice"
| "IOClass" = "AppleUSBHostCompositeDevice"
| "bDeviceSubClass" = 0
| "IOMatchCategory" = "IODefaultMatchCategory"
| "kUSBPreferredConfiguration" = 1
| "bDeviceClass" = 0
| }
|
+-o IOUSBHostInterface@0 <class IORegistryEntry:IOService:IOUSBNub:IOUSBInterface, id 0x1000006f6, !registered, !matched, active, busy 0, retain 6>
{
"USBPortType" = 0
"IOCFPlugInTypes" = {"2d9786c6-9ef3-11d4-ad51-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
"bcdDevice" = 1
"USBSpeed" = 1
"idProduct" = 4096
"bConfigurationValue" = 1
"bInterfaceSubClass" = 0
"locationID" = 339738624
"IOGeneralInterest" = "IOCommand is not serializable"
"IOServiceLegacyMatchingRegistryID" = 4294969079
"IOClassNameOverride" = "IOUSBInterface"
"AppleUSBAlternateServiceRegistryID" = 4294969079
"idVendor" = 1447
"bInterfaceProtocol" = 0
"bAlternateSetting" = 0
"bInterfaceNumber" = 0
"bInterfaceClass" = 3
}