阅读:2101回复:3
求救!用DDKXP +DS3.1+VC6自生成的USBBULK驱动蓝屏问题!
用DDKXPSP1+DS3.1+VC6自动生成USB BULK驱动,2个EP一个IN 一个OUT,用WRITEFILE READFILE读写操作,驱动的READ部分程序如下:
NTSTATUS Usb4Device::Read(KIrp I) { t << "Entering Usb4Device::Read, " << I << EOL; // TODO: Check the incoming request. Replace "FALSE" in the following // line with a check that returns TRUE if the request is not valid. if (FALSE) // If (Request is invalid) { // Invalid parameter in the Read request I.Information() = 0; return I.PnpComplete(this, STATUS_INVALID_PARAMETER); } // Always ok to read 0 elements. if (I.ReadSize() == 0) { I.Information() = 0; return I.PnpComplete(this, STATUS_SUCCESS); } // Declare a memory object KMemory Mem(I.Mdl()); ULONG dwTotalSize = I.ReadSize(CURRENT); ULONG dwMaxSize = m_Endpoint1IN.MaximumTransferSize(); // If the total requested read size is greater than the Maximum Transfer // Size for the Pipe, request to read only the Maximum Transfer Size since // the bus driver will fail an URB with a TransferBufferLength of greater // than the Maximum Transfer Size. if (dwTotalSize > dwMaxSize) { ASSERT(dwMaxSize); dwTotalSize = dwMaxSize; } // Allocate a new context structure for Irp completion USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO; if (pCompInfo == NULL) { I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } // TODO: Select the correct pipe to read from // Create an URB to do actual Bulk read from the pipe PURB pUrb = m_Endpoint1IN.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to read? TRUE, // direction (TRUE = IN) NULL, // Link to next URB TRUE // Allow a short transfer ); if (pUrb == NULL) { delete pCompInfo; I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } // Initialize context structure pCompInfo->m_pClass = this; pCompInfo->m_pUrb = pUrb; // Submit the URB to our USB device NTSTATUS status; status = m_Endpoint1IN.SubmitUrb(I, pUrb, LinkTo(ReadComplete), pCompInfo, 0); return status; } 问题是,我只要对这个Kmemory类的 Mem进行任何操作比方说:加入一行Mem.Size() ; 或 Mem.MapToSystemSpace() 等等,只要一进行readfile的操作,立即就蓝屏! 照着武安和的《Windows 2000/xp wdm 设备驱动程序开发》一书中的RegSample中也有对KMEMORY操作,我编译运行后却不会蓝屏。实在搞不懂为什么我在自动生成的Read代码中加入对Kmemory对象的操作就会导致蓝屏?搞了好几天了,实在不明白,还请大伙指点指点啊 |
|
沙发#
发布于:2008-03-20 11:10
我使用的结果也一样。用的是DDK2003,WriteFile正常,D12能够正常接收到PC机发的数据,但是只要一运行ReadFile,立即篮屏死机。估计要正版的软件才能解决。
DS3.2有个明显的错误,WriteFile虽然可以发送,但是比WinDriver开发的驱动,速度要慢一些,不过纠正后就可以了,速度与WinDriver不相上下。 篮屏问题就一直没有解决。 |
|
板凳#
发布于:2008-04-19 16:01
楼主的XPDDK在哪下载的,能告诉我地址么?或加QQ好友传给我一下.QQ:342954055
|
|
|
地板#
发布于:2008-05-29 16:45
writefile()可以,而readflie()就蓝屏.这个是因为你的驱动原理.驱动用DS3.1或者3.2生成的.会有一个问题.就是在驱动程序中对端点的地址的设定问题.
writefile()能成功是因为端点是出. 而readfile()的端点是进.有方向. 但这两个值在代码中用的时十进制的.你用十六进制来表示.就OK啦. m_Pipe0.Initialize(m_Lower, 0x81, 0x40); m_Pipe1.Initialize(m_Lower, 0x2, 0x40); |
|