在一個項目中,我最近嘗試通過osx 10.9.5上的libusb訪問USB存儲設備。但顯然有些默認驅動程序聲稱該設備,我無法訪問它。當我嘗試通過libusb訪問它時,它會返回「我沒有足夠的權限」。用於USB存儲設備的無代碼kext
當我在Ubuntu中執行(java)應用程序時,一切正常。
我在互聯網上的研究證明,提供一個與更高探測器核心上的設備相匹配的無代碼kext可以防止默認驅動程序聲明該設備。這將完全解決問題,因爲卸載IOUSBMassStorage kext使得可以使用設備執行我們想要的操作。
我的創建無代碼kext的嘗試沒有解決,因爲它似乎不會在啓動時加載,也不會在我使用kextload
時加載。至少這就是我猜測的,因爲我無法卸載它,也無法在列出的任何地方找到它。
我的Info.plist的最新版本是這樣的:在運行sudo kextutil -t -n /path/to/my.kext
當這些診斷返回
<?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>OSBundleLibraries</key>
<dict/>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>Test USB Stick</string>
<key>CFBundleIdentifier</key>
<string>de.mischok.testkext</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Test USB Device</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>IOKitPersonalities</key>
<dict>
<key>Device Driver</key>
<dict>
<key>CFBundleIdentifier</key>
<string>de.mischok.testkext</string>
<key>IOClass</key>
<string>IOUSBUserClientInit</string>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>idProduct</key>
<integer>357</integer>
<key>idVendor</key>
<integer>4871</integer>
<key>bcdDevice</key>
<integer>4352</integer>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
</dict>
<key>Interface Driver</key>
<dict>
<key>CFBundleIdentifier</key>
<string>de.mischok.testkext</string>
<key>IOClass</key>
<string>IOUSBUserClientInit</string>
<key>IOProviderClass</key>
<string>IOUSBInterface</string>
<key>idProduct</key>
<integer>357</integer>
<key>idVendor</key>
<integer>4871</integer>
<key>bcdDevice</key>
<integer>4352</integer>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
</dict>
</dict>
<key>OSBundleRequired</key>
<string>Local-Root</string>
</dict>
</plist>
:
Diagnostics for /Users/user/Desktop/testv1-0.kext:
Warnings:
Personality CFBundleIdentifier names a kext that doesn't declare an executable:
'Interface Driver' -> 'de.mischok.testkext'
'Device Driver' -> 'de.mischok.testkext'
Code Signing Failure: not code signed
Warnings:
Personality CFBundleIdentifier names a kext that doesn't declare an executable:
'Interface Driver' -> 'de.mischok.testkext'
'Device Driver' -> 'de.mischok.testkext'
/Users/user/Desktop/testv1-0.kext appears to be loadable (including linkage for on-disk libraries).
,因爲它說的內核擴展應該是可加載的,我認爲它應該管用。但是,而不是工作,SYSTEM.LOG中記錄此,與sudo kextload /path/to/my.kext
加載內核擴展時:
Nov 5 12:28:58 users-MacBook-Pro.local sudo[528]: user : TTY=ttys000 ; PWD=/Users/user ; USER=root ; COMMAND=/sbin/kextload /Users/user/Desktop/testv1-0.kext
Nov 5 12:28:58 users-MacBook-Pro.local com.apple.kextd[12]: WARNING - Invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext "/Users/user/Desktop/testv1-0.kext"
因爲它僅僅是一個警告,我認爲這是成功加載。但只要我插上設備的,將USB探測器輸出看起來是這樣的:
Nov 5 12:57:11.911 [6] Device Descriptor Dump
Nov 5 12:57:11.911 [6] bLength 18
Nov 5 12:57:11.911 [6] bDescriptorType 1
Nov 5 12:57:11.911 [6] bcdUSB 768 (0x0300)
Nov 5 12:57:11.911 [6] bDeviceClass 0
Nov 5 12:57:11.911 [6] bDeviceSubClass 0
Nov 5 12:57:11.911 [6] bDeviceProtocol 0
Nov 5 12:57:11.911 [6] bMaxPacketSize0 9
Nov 5 12:57:11.911 [6] idVendor 4871 (0x1307)
Nov 5 12:57:11.911 [6] idProduct 357 (0x0165)
Nov 5 12:57:11.911 [6] bcdDevice 4352 (0x1100)
Nov 5 12:57:11.911 [6] iManufacturer 1
Nov 5 12:57:11.911 [6] iProduct 2
Nov 5 12:57:11.911 [6] iSerialNumber 3
Nov 5 12:57:11.911 [6] bNumConfigurations 1
Nov 5 12:57:11.916 [5] Finding device driver for DEVICE, matching personality using com.apple.iokit.IOUSBUserClient, score: 106999, wildCard = 3
Nov 5 12:57:11.916 [6] Matched: idVendor (4871) idProduct (357) bcdDevice (4352)
Nov 5 12:57:11.916 [6] Didn't Match: nothing
Nov 5 12:57:11.917 [5] Finding device driver for DEVICE, matching personality using com.apple.driver.AppleUSBComposite, score: 50000, wildCard = 0
Nov 5 12:57:11.917 [6] Matched: bDeviceClass (0) bDeviceSubClass (0)
Nov 5 12:57:11.917 [6] Didn't Match: nothing
Nov 5 12:57:11.918 [5] Finding device driver for DEVICE, matching personality using com.apple.driver.AppleUSBCDC, score: 60000, wildCard = 0
Nov 5 12:57:11.918 [6] Matched: bDeviceClass (0) bDeviceSubClass (0) bDeviceProtocol (0)
Nov 5 12:57:11.918 [6] Didn't Match: nothing
這是唯一的個性相匹配的發生,所以我不知道,我所應該做的,所以我的內核擴展將匹配我的設備甚至是負載?
非常感謝!這對我很有幫助,雖然我不再使用'IOUSBUserClientInit',因爲我的設備是存儲設備。你的答案仍然是100%正確的。 – daniel