阅读:3122回复:3
奶奶的,bulkusb 居然得不到pipe信息??
NTSTATUS
BulkUsb_DispatchCreate( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { ULONG i; NTSTATUS ntStatus; PFILE_OBJECT fileObject; PDEVICE_EXTENSION deviceExtension; PIO_STACK_LOCATION irpStack; PBULKUSB_PIPE_CONTEXT pipeContext; PUSBD_INTERFACE_INFORMATION interface; PAGED_CODE(); BulkUsb_DbgPrint(1, ("BulkUsb_DispatchCreate - begins\n")); // // initialize variables // irpStack = IoGetCurrentIrpStackLocation(Irp); fileObject = irpStack->FileObject; deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; if(deviceExtension->DeviceState != Working) { BulkUsb_DbgPrint(1, ("Usb not working\n")); ntStatus = STATUS_INVALID_DEVICE_STATE; goto BulkUsb_DispatchCreate_Exit; } if(deviceExtension->UsbInterface) { interface = deviceExtension->UsbInterface; } else { BulkUsb_DbgPrint(1, ("UsbInterface not found\n")); ntStatus = STATUS_INVALID_DEVICE_STATE; goto BulkUsb_DispatchCreate_Exit; } // // FsContext is Null for the device // if(fileObject) { fileObject->FsContext = NULL; } else { BulkUsb_DbgPrint(1, ("Usb invalid parameter\n")); ntStatus = STATUS_INVALID_PARAMETER; goto BulkUsb_DispatchCreate_Exit; } BulkUsb_DbgPrint(1, ("Filename = %ws\n", fileObject->FileName)); if(0 == fileObject->FileName.Length) { // // opening a device as opposed to pipe. // ntStatus = STATUS_SUCCESS; InterlockedIncrement(&deviceExtension->OpenHandleCount); // // the device is idle if it has no open handles or pending PnP Irps // since we just received an open handle request, cancel idle req. // if(deviceExtension->SSEnable) { CancelSelectSuspend(deviceExtension); } BulkUsb_DbgPrint(1, ("Usb filename.length == 0\n"));//////////////到这里就跳转了,得不到pipe信息了,打不开pipe,咋回事? goto BulkUsb_DispatchCreate_Exit; } pipeContext = BulkUsb_PipeWithName(DeviceObject, &fileObject->FileName); if(pipeContext == NULL) { ntStatus = STATUS_INVALID_PARAMETER; BulkUsb_DbgPrint(1, ("Usb get pipe failed\n")); goto BulkUsb_DispatchCreate_Exit; } ntStatus = STATUS_INVALID_PARAMETER; BulkUsb_DbgPrint(1, ("begin open pipes\n")); for(i=0; i<interface->NumberOfPipes; i++) { if(pipeContext == &deviceExtension->PipeContext) { // // found a match // BulkUsb_DbgPrint(1, ("open pipe %d\n", i)); fileObject->FsContext = &interface->Pipes; ASSERT(fileObject->FsContext); pipeContext->PipeOpen = TRUE; ntStatus = STATUS_SUCCESS; // // increment OpenHandleCounts // InterlockedIncrement(&deviceExtension->OpenHandleCount); // // the device is idle if it has no open handles or pending PnP Irps // since we just received an open handle request, cancel idle req. // if(deviceExtension->SSEnable) { CancelSelectSuspend(deviceExtension); } } } BulkUsb_DispatchCreate_Exit: Irp->IoStatus.Status = ntStatus; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); BulkUsb_DbgPrint(1, ("BulkUsb_DispatchCreate - ends\n")); return ntStatus; } +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ BulkUsb_DbgPrint(1, ("Usb filename.length == 0\n"));//////////////到这里就跳转了,得不到pipe信息了,打不开pipe,咋回事? +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
沙发#
发布于:2009-03-13 11:08
....例程没看清楚
|
|
板凳#
发布于:2010-07-27 13:49
据说这个例子里面的pipeInformation设置有问题,用fileObject保存pipeHandle没有理由,应该改成用deviceExtension来保存
|
|
地板#
发布于:2010-08-11 12:53
传入的打开的管道信息为空了,当然会得不到正确的响应。 检查你的参数传递过程吧
|
|