阅读:3367回复:5
怎么读出来的idVendor, idProduct,bcdDevice的值老是变化?
这个是ddk vista 6000版本的一个toast例子中的,我只是改写filter.c中的这段想获得设备描述符。
每次读到的都不一样。怎么会这样啊。ddk下的。其他地方都没有改,就在FilterDispatchPnp中添加一段代码来获得设备描述符。但是问题如标题。每次运行 DebugPrint出来的idVendor, idProduct,bcdDevice的值老是变化的。 具体代码如下 NTSTATUS FilterDispatchPnp ( __in PDEVICE_OBJECT DeviceObject, __in PIRP Irp ) /*++ Routine Description: The plug and play dispatch routines. Most of these the driver will completely ignore. In all cases it must pass on the IRP to the lower driver. Arguments: DeviceObject - pointer to a device object. Irp - pointer to an I/O Request Packet. Return Value: NT status code --*/ { PDEVICE_EXTENSION deviceExtension; PIO_STACK_LOCATION irpStack; NTSTATUS status; KEVENT event; PURB pUrb = NULL; PUSB_DEVICE_DESCRIPTOR deviceDescriptor = NULL; ULONG dwSize; NTSTATUS Status = STATUS_SUCCESS; LARGE_INTEGER RunTime; KEVENT Event; IO_STATUS_BLOCK IoStatus; PIO_STACK_LOCATION NextStack; PIRP newIrp; USHORT myidVendor; PAGED_CODE(); deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; irpStack = IoGetCurrentIrpStackLocation(Irp); //DbgPrint(("FilterDO %s IRP:0x%p \n", // PnPMinorFunctionString(irpStack->MinorFunction), Irp)); status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); if (!NT_SUCCESS (status)) { Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } ////////////////////////////////////////////////////////////// // Added by me pUrb = (PURB)ExAllocatePool(NonPagedPool, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST)); if(pUrb) { //DbgPrint("URB OK\n"); dwSize = sizeof(USB_DEVICE_DESCRIPTOR); deviceDescriptor = (PUSB_DEVICE_DESCRIPTOR)ExAllocatePool(NonPagedPool, dwSize); if(deviceDescriptor) { //DbgPrint("DeviceDescriptor OK\n"); UsbBuildGetDescriptorRequest(pUrb, (USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, deviceDescriptor, NULL, dwSize, NULL); RunTime.QuadPart = -2000 * 10; KeInitializeEvent(&Event, NotificationEvent, FALSE); newIrp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB, DeviceObject, NULL, 0, NULL, 0, TRUE, &Event, &IoStatus); NextStack = IoGetNextIrpStackLocation(newIrp); NextStack->Parameters.Others.Argument1 = pUrb; //DbgPrint("Before Call\n"); Status = IoCallDriver(DeviceObject, newIrp); if(Status == STATUS_PENDING) { DbgPrint("Pending\n"); Status = KeWaitForSingleObject( &Event, Suspended, KernelMode, FALSE, &RunTime); if(Status == STATUS_TIMEOUT) { DbgPrint("Cancel\n"); Status = STATUS_UNSUCCESSFUL; IoCancelIrp(newIrp); KeWaitForSingleObject( &Event, Suspended, KernelMode, FALSE, NULL); } } DbgPrint(" idVendor: %d, bcdDevice:%d, idProduct:%d\n", deviceDescriptor->idVendor,deviceDescriptor->bcdDevice,deviceDescriptor->idProduct); DbgPrint(" bDeviceClass: %d,bDeviceSubClass:%d\n",deviceDescriptor->bDeviceClass,deviceDescriptor->bDeviceSubClass); myidVendor = deviceDescriptor->idVendor; } ExFreePool(deviceDescriptor); } else { Status = STATUS_NO_MEMORY; } ExFreePool(pUrb); } else { Status = STATUS_NO_MEMORY; } DbgPrint("Return\n"); // End of addition /////////////////////////////////////////////////////////////////////////// switch (irpStack->MinorFunction) { case IRP_MN_START_DEVICE: |
|
驱动牛犊
|
沙发#
发布于:2007-08-02 13:31
读法有问题吧!我猜的。
|
驱动牛犊
|
板凳#
发布于:2007-08-02 13:32
你还在吗?
|
地板#
发布于:2007-08-02 13:43
还在啊。哪里有问题啊。多谢指导。
|
|
地下室#
发布于:2007-08-03 13:51
请大家百忙中抽点时间帮我看看,不胜感激。
|
|
5楼#
发布于:2007-08-07 09:13
请大家百忙中抽点时间帮我看看,不胜感激。不然帖子都沉了。
|
|