阅读:2319回复:1
NDIS Miniport driver with USB interface
各位大虾: 我最近正在学习调试 usb wifi 驱动, 代码是用 driverStudio3.2生成的., 可是在调的时候发现, 在创建 URB 发下去之后, IoCallDriver 总是返回 0xC0000010, 代码是这样的:
/////////////////////////////////////////////////////////////////////////////////////////////////// // usbwifiSubmitUrbSynch // method to synchronously submit an urb to the bus driver. // // Arguments: // IN Adapter // our adapter object // // IN Urb // URB to submit // // Return Value: // NT status code. // NTSTATUS usbwifiSubmitUrbSynch( IN PUSBWIFI_ADAPTER Adapter, IN PURB Urb ) { NTSTATUS status; PIRP irp; IO_STATUS_BLOCK ioStatus; KEVENT event; PIO_STACK_LOCATION irpStack; usbwifiDebugPrint(DBG_IO, DBG_INFO, __FUNCTION__"++"); KeInitializeEvent(&event, NotificationEvent, FALSE); irp = IoBuildDeviceIoControlRequest( IOCTL_INTERNAL_USB_SUBMIT_URB, //IOCTL_INTERNAL_USB_SUBMIT_URB, Adapter->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event, &ioStatus ); if (irp != NULL) { irpStack = IoGetNextIrpStackLocation(irp); irpStack->Parameters.Others.Argument1 = Urb; status = IoCallDriver(Adapter->LowerDeviceObject, irp); if (status == STATUS_PENDING) { KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); status = ioStatus.Status; } } else { status = STATUS_INSUFFICIENT_RESOURCES; } usbwifiDebugPrint(DBG_IO, DBG_INFO, __FUNCTION__"--. STATUS %x", status); return status; } URB 的创建代码如下: // we need to allocate an URB to talk // to usb bus driver urb = (PURB)ExAllocatePoolWithTag( NonPagedPool, sizeof(URB), USBWIFI_POOL_TAG ); if (urb == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; break; } // first let's read device descriptor deviceDescriptor = (PUSB_DEVICE_DESCRIPTOR)ExAllocatePoolWithTag( NonPagedPool, sizeof(USB_DEVICE_DESCRIPTOR), USBWIFI_POOL_TAG ); if (deviceDescriptor == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; break; } UsbBuildGetDescriptorRequest( urb, (USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, deviceDescriptor, NULL, sizeof(USB_DEVICE_DESCRIPTOR), NULL ); status = usbwifiSubmitUrbSynch(Adapter, urb); if (!NT_SUCCESS(status)) { break; } 请各位牛人们指教啊...., 谢谢先.. |
|
|
沙发#
发布于:2009-09-08 23:56
你调KeWaitForSingleObject()时,底层的driver会不会来激活event呢?如果没有,就要设置完成例程来激活才行。仅供参考。
|
|