阅读:3189回复:6
请教jinghuiren等大虾ezusb.sys改称异步后DDK通过但应用程序蓝屏问题(附code)参考的是DDK下的bulkusb程序,在xp下的ddk2600编译通过,加载驱动,应用程序DeviceIoControl一调用xp就蓝屏 用softice调试,前面驱动运行都正常,但是到了Ezusb_ReadCompletion中的IobuildpartialMdl时,系统就出现page fault 0x000000fe,我看microsoft关网上对此的解决方案是装成sp3,装sp3后仍然蓝屏,好像还是内存空间出错 不知各位大虾碰到这个问题了么?如何解决的?十分感谢!! NTSTATUS Ezusb_ReadCompletion( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context ) /*++ Routine Description: directory structure nomenclature. Arguments: fdo - pointer to the device object for this instance of the Ezusb device Return Value: NT status code --*/ { ULONG stageLength; NTSTATUS ntStatus; PIO_STACK_LOCATION nextStack; PBULKUSB_RW_CONTEXT rwContext; rwContext=(PBULKUSB_RW_CONTEXT) Context; ntStatus=Irp->IoStatus.Status; UNREFERENCED_PARAMETER(DeviceObject); Ezusb_KdPrint(("BulkUsb_ReadWriteCompletion-begins\n")); Ezusb_KdPrint(("irp is %x\n",Irp)); //successfull performed a stagedlength of transfer //check is we need to recirculate the irp if(NT_SUCCESS(ntStatus)){ Ezusb_KdPrint(("NT SUccess entered!\n")); if(rwContext){ rwContext->Numxfer+= rwContext->Urb->UrbBulkOrInterruptTransfer.TransferBufferLength; Ezusb_KdPrint(("rwContext Numxfer defined\n")); if(rwContext->Length){ Ezusb_KdPrint(("Another stage transfer\n")); if(rwContext->Length>BULKUSB_MAX_TRANSFER_SIZE){ stageLength=BULKUSB_MAX_TRANSFER_SIZE; Ezusb_KdPrint(("stageLength=%x \n",stageLength)); } else { stageLength=rwContext->Length; } !!!!!!!!!!到这里系统就跳出page fault 0x000000FE IoBuildPartialMdl(Irp->MdlAddress, rwContext->Mdl, (PVOID) rwContext->VirtualAddress, stageLength); //reinitialize URB Ezusb_KdPrint(("reinitialize URB")); rwContext->Urb->UrbBulkOrInterruptTransfer.TransferBufferLength=stageLength; rwContext->VirtualAddress+=stageLength; rwContext->Length-=stageLength; nextStack=IoGetNextIrpStackLocation(Irp); nextStack->MajorFunction=IRP_MJ_INTERNAL_DEVICE_CONTROL; nextStack->Parameters.Others.Argument1=rwContext->Urb; nextStack->Parameters.DeviceIoControl.IoControlCode= IOCTL_INTERNAL_USB_SUBMIT_URB; IoSetCompletionRoutine(Irp, Ezusb_ReadCompletion, rwContext, TRUE, TRUE, TRUE); IoCallDriver(rwContext->DeviceExtension->StackDeviceObject, Irp); return STATUS_MORE_PROCESSING_REQUIRED; } else{ //the last transfer UnlockDevice(DeviceObject); Irp->IoStatus.Information=rwContext->Numxfer; } } } else { Ezusb_KdPrint(("ReadWriteCompletion-failed with the status=%X\n",ntStatus)); } if(rwContext){ //dump rwContext Ezusb_KdPrint(("rwContext->Urb=%X\n",rwContext->Urb)); Ezusb_KdPrint(("rwContext->Mdl=%X\n",rwContext->Mdl)); Ezusb_KdPrint(("rwContext->Length=%X\n",rwContext->Length)); Ezusb_KdPrint(("rwContext->Numxfer=%X\n",rwContext->Numxfer)); Ezusb_KdPrint(("rwContext->VirtualAddress=%X\n",rwContext->VirtualAddress)); Ezusb_KdPrint(("rwContext->DeviceExtension=%X\n",rwContext->DeviceExtension)); Ezusb_KdPrint(("Bulk_ReadWriteCompletion::")); ExFreePool(rwContext->Urb); IoFreeMdl(rwContext->Mdl); ExFreePool(rwContext); } Ezusb_KdPrint(("BulkUsb_ReadWriteCompletion-ends\n")); return ntStatus; } |
|
沙发#
发布于:2008-09-18 23:07
没人顶,自己顶一下
|
|
板凳#
发布于:2009-03-15 16:11
楼主这个问题解决了吗? 碰到一样的问题了,网上贴出的那个代码不知道是不是有问题,一调用DeviceIoControl就是蓝屏
|
|
地板#
发布于:2009-12-19 14:18
我也正在研究这个问题,可能上位机要动动,谁研究出来给大家讲讲啊。
|
|
地下室#
发布于:2009-12-31 23:54
其实这个问题是个大家都想解决的问题,牛人可以出来讲一下啊,这样就能解决大块传输的问题了,谢谢牛人们 呵呵
|
|
5楼#
发布于:2010-02-19 02:37
你把这段代码应当放在Nonpage内存中没有?你把同步改成异步,就意味着completion例程工作在任意线程中,而不是原来的非任意线程,所以completion例程必须能够在DISPATCH_LEVEL下工作,换句话说就是completion例程必须被放在Nonpage内存中,当在某个任一线程中执行到此,要找page,却发现page不在那里,出现page fault错误。
要不在IoBuildPartialMdl前面增加一句MmPrepareMdlForReuse(rwContext->Mdl),仅作参考 |
|
6楼#
发布于:2010-03-11 15:08
IoBuildPartialMdl() 前的MmPrepareMdlForReuse(rwContext->Mdl) 是必不可少的,否则有system PTE的泄露。除非再IoAllocateMdl出新的Mdl
|
|
|