renhao153
驱动牛犊
驱动牛犊
  • 注册日期2009-05-29
  • 最后登录2010-09-05
  • 粉丝0
  • 关注0
  • 积分35分
  • 威望271点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2318回复:1

USBD_ParseConfigurationDescriptorEx使用问题,我在IRP_MN_PNP中使用不知为什么常得不到接口描述符

楼主#
更多 发布于:2010-07-27 10:50
VOID GetInterface(IN PDEVICE_OBJECT fido)
{

PURB pUrb = NULL;
ULONG dwSize;
LONG AlternateSetting,InterfaceClass,InterfaceSubClass,InterfaceProtocol,interfaceindex;
AlternateSetting =0;
InterfaceClass = 0;
InterfaceSubClass = 0;
InterfaceProtocol =0;
interfaceindex= 0;
pUrb = (PURB)ExAllocatePool(NonPagedPool, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));
if(pUrb)
{
dwSize = sizeof(USB_CONFIGURATION_DESCRIPTOR);
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor =NULL;
ConfigurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)ExAllocatePool(NonPagedPool, dwSize);
if(ConfigurationDescriptor)
{
UsbBuildGetDescriptorRequest(pUrb,
(USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE,
0,
0,
ConfigurationDescriptor,
NULL,
dwSize,
NULL); //此函数这得到设备描述符命令
SendAwaitUrb(fido,pUrb);
}
dwSize = ConfigurationDescriptor->wTotalLength; //这个长度是正确的
ExFreePool(ConfigurationDescriptor);
KdPrint(("dwSize = %d\n",dwSize));
ConfigurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)ExAllocatePool(NonPagedPool, dwSize);
if(ConfigurationDescriptor)
{
UsbBuildGetDescriptorRequest(
pUrb,
(USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE,
0,
0,
ConfigurationDescriptor,
NULL,
dwSize,
NULL);
SendAwaitUrb(fido,pUrb);
}
PUSB_INTERFACE_DESCRIPTOR interfaceDescriptor=NULL;
interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
ConfigurationDescriptor, //search from start of config descriptro
interfaceindex, // interface number not a criteria; we only support one interface
AlternateSetting, // not interested in alternate setting here either
InterfaceClass, // interface class not a criteria
InterfaceSubClass, // interface subclass not a criteria
InterfaceProtocol // interface protocol not a criteria
);

if(interfaceDescriptor)
{
KdPrint(("interfaceDescriptor InterfaceClass=0x%X\n",interfaceDescriptor->bInterfaceClass));
KdPrint(("interfaceDescriptor InterfaceSubClass =0x%X\n",interfaceDescriptor->bInterfaceSubClass ));
}
ExFreePool(ConfigurationDescriptor);
}

ExFreePool(pUrb);
}
interfaceDescriptor 常为NULL

renhao153
驱动牛犊
驱动牛犊
  • 注册日期2009-05-29
  • 最后登录2010-09-05
  • 粉丝0
  • 关注0
  • 积分35分
  • 威望271点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2010-07-27 10:51
版主请回答一下急用
游客

返回顶部