【发布时间】:2015-10-21 10:45:17
【问题描述】:
我正在为 OS X 上的 USB 设备开发 kext 驱动程序。在这个驱动程序中,我有一个指向对象 IOUSBDevice *device 的指针(它可以在 start() 和 probe() 函数中接收),我有一个问题: 可以在 probe() 函数中打开设备 (device->open(this, kIOServiceSeize)),但在其他函数中 open()return false,因为它看起来像经典驱动程序控制设备。
我找到文章User-Mode USB Device Arbitration并尝试创建“skeleton”kext将“ClassicMustNotSeize”属性设置为true,但似乎不起作用,我仍然无法打开设备。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.sample.iokit.ClassicNotSeizeDriver</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>IOKitPersonalities</key>
<dict>
<key>MyUSBDevice</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.driver.AppleUSBMergeNub</string>
<key>IOClass</key>
<string>AppleUSBMergeNub</string>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>IOProviderMergeProperties</key>
<dict>
<key>ClassicMustNotSeize</key>
<true/>
</dict>
<key>idProduct</key>
<integer>1</integer>
<key>idVendor</key>
<integer>10978</integer>
</dict>
</dict>
<key>OSBundleLibraries</key>
<dict>
<key>com.apple.driver.AppleUSBMergeNub</key>
<string>1.8.3b1</string>
<key>com.apple.iokit.IOUSBFamily</key>
<string>1.8</string>
</dict>
</dict>
</plist>
是否可以通过编程方式设置“ClassicMustNotSeize”属性,例如在我的驱动程序的 probe() 函数中?
我试过了:
device->setProperty("ClassicMustNotSeize", true);
而且好像也不行。
【问题讨论】:
标签: macos usb driver iokit kernel-extension