阅读:1560回复:1
发现USBDeviceAttach的参数UsbInterface为NULL,请版主及各位大哥帮帮忙
我在跟踪USBDeviceAttach函数时,发现第三个参数LPCUSB_INTERFACE UsbInterface 为NULL,那是什么原因造成的呢?我知道UsbInterface表示USB设备的接口信息。是不是我将USB设备信息写到注册表时没有写对?
我的USB设备的信息如下: Device Descriptor: bcdUSB: 0x0200 bDeviceClass: 0x00 bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 bMaxPacketSize0: 0x40(64) idVendor: 0x3344 idProduct: 0x1122 bcdDevice: 0x0000 iManufacturer: 0x01 iProduct: 0x02 iSerialNumber: 0x03 bNumConfigurations: 0x01 ConnectionStatus: DeviceConnected Current Configure Value: 0x01 Device Bus Speed: Full Device Address: 0x02 Open Pipes: 0 #define LME_USB_VENDORID 0x3344 #define LME_USB_PRODUCTID 0x1122 #define DRIVER_SETTINGS \ sizeof(USB_DRIVER_SETTINGS), \ LME_USB_VENDORID, \ LME_USB_PRODUCTID, \ USB_NO_INFO, \ USB_NO_INFO, \ USB_NO_INFO, \ USB_NO_INFO, \ USB_NO_INFO, \ USB_NO_INFO, \ USB_NO_INFO BOOL USBInstallDriver(LPCWSTR szDriverLibFile) { BOOL bRc; const WCHAR wsUsbDeviceID[] = CLASS_NAME_SZ; WCHAR wsSubClassRegKey[sizeof(CLIENT_REGKEY_SZ)+16] = CLIENT_REGKEY_SZ; //Set lmeusb device descriptor USB_DRIVER_SETTINGS usbDriverSettings = { DRIVER_SETTINGS }; DWORD dwPortStatusTimeout = GET_PORT_STATUS_TIMEOUT; DWORD dwDeviceIdTimeout = GET_DEVICE_ID_TIMEOUT; DWORD dwSoftResetTimeout = SOFT_RESET_TIMEOUT; DWORD dwReadTimeoutMultiplier = READ_TIMEOUT_MULTIPLIER; DWORD dwReadTimeoutConstant = READ_TIMEOUT_CONSTANT; DWORD dwWriteTimeoutMultiplier = WRITE_TIMEOUT_MULTIPLIER; DWORD dwWriteTimeoutConstant = WRITE_TIMEOUT_CONSTANT; REG_VALUE_DESCR LmeusbKeyValues[] = { TEXT("Dll"), REG_SZ, 0, (PBYTE)(DRIVER_NAME), TEXT("Prefix"), REG_SZ, 0, (PBYTE)(DEVICE_PREFIX), GET_PORT_STATUS_TIMEOUT_SZ, REG_DWORD, 0, (PUCHAR)(&dwPortStatusTimeout), GET_DEVICE_ID_TIMEOUT_SZ, REG_DWORD, 0, (PUCHAR)(&dwDeviceIdTimeout), SOFT_RESET_TIMEOUT_SZ, REG_DWORD, 0, (PUCHAR)(&dwSoftResetTimeout), READ_TIMEOUT_MULTIPLIER_SZ, REG_DWORD, 0, (PUCHAR)(&dwReadTimeoutMultiplier), READ_TIMEOUT_CONSTANT_SZ, REG_DWORD, 0, (PUCHAR)(&dwReadTimeoutConstant), WRITE_TIMEOUT_MULTIPLIER_SZ, REG_DWORD, 0, (PUCHAR)(&dwWriteTimeoutMultiplier), WRITE_TIMEOUT_CONSTANT_SZ, REG_DWORD, 0, (PUCHAR)(&dwWriteTimeoutConstant), NULL, 0, 0, NULL }; //Register Unique Driver ID, [HKEY_LOCAL_MACHINE\Drivers\USB\ClientDrivers\LMEUSB_Class] bRc = RegisterClientDriverID(wsUsbDeviceID); if(!bRc) { DEBUGMSG(ZONE_ERR, (TEXT("RegisterClientDriverID error:%d\n"),GetLastError())); return FALSE; } //Register relative device info, [HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\DriverName] bRc = RegisterClientSettings(szDriverLibFile,wsUsbDeviceID,NULL,&usbDriverSettings); if (!bRc) { DEBUGMSG(ZONE_ERR, (TEXT("RegisterClientSettings error:%d\n"), GetLastError())); return FALSE; } //Set our default values to the register if (!GetSetKeyValues(wsSubClassRegKey , LmeusbKeyValues, TRUE, TRUE)) { MessageBox(NULL,_T("Wrong to Set Registry Values!!"), _T("OK"), MB_OK); return FALSE; } MessageBox(NULL, _T("Enter USBInstallDriver"), _T("OK"), MB_OK); return bRc; } |
|
沙发#
发布于:2007-05-30 10:41
我遇到了一样的问题,我估计应该是USB_DRIVER_SETTINGS这些参数没设对,但我一直没找到关于CLASS,SUBCLASS,Protoco的参考文档,因为USBview给出的芯片信息也是:
bDeviceClass: 0x00 bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 我试过USB_DRIVER_SETTINGS的后3个参数都设成0x0或者USB_NO_INFO,但USBDeviceAttach的interface都是NULL,加载失败。网上流传甚广的OV511的源码里,把那个CLASS设成0xe,我不知道是否有参考的依据。有人能给点意见吗? |
|