阅读:771回复:0
一个DS的问题!
为什么SubmitUrb总是不能成功?
NTSTATUS USBDOGDevice::Write(KIrp I) { t << \"Entering USBDOGDevice::Write, \" << 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. NTSTATUS status = STATUS_SUCCESS; KMemory Mem(I.Mdl()); // Declare a memory object // Use the memory object to create a pointer to the caller\'s buffer PUCHAR pBuffer = (PUCHAR) Mem.VirtualAddress(); ULONG dwTotalSize = I.WriteSize(CURRENT); ULONG dwBytesSent = 0; // TODO: If the write can be satisfied immediately, set the Information // and Status fields now, then call NextIrp to complete this IRP // and start processing the next IRP in the queue. PURB pUrb = m_Lower.BuildClassRequest( pBuffer, // TransferBufferMDL dwTotalSize, // TransferBufferLength=dwTotalSize 0, // RequestTypeReservedBits=0 0x09, //Request =0x09 just for the dog 0x0200, //Value =0x0200,for Unknow reason FALSE, //BOOLEAN bIn=FALSE FALSE, //BOOLEAN bShortOk=FALSE NULL, //PURB Link=NULL 0, //UCHAR Index=0 URB_FUNCTION_CLASS_DEVICE, //USHORT Function=URB_FUNCTION_CLASS_DEVICE NULL //PURB Link=NULL ); // Submit the URB to our USB device, synchronously if (pUrb != NULL) { status = m_Lower.SubmitUrb(pUrb, NULL, NULL,0); if ( NT_SUCCESS(status) ) { dwBytesSent = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength; } else { t<<\"SubmitUrb fialed \\n \" ; } delete pUrb; } else { t<<\"no enough resource by \\n \" ; } // TODO: If the device cannot accept all of the data yet, initiate a // request to the physical device here, and defer the Information, // Status, and NextIrp handling until the hardware indicates that // the write is complete. Typically, this might be handled in a // DPC that is called after the hardware finishes transferring // the data. // TODO: To satisfy the write now, transfer data to the device // from caller\'s buffer at \"pBuffer\". Then, indicate how much // data was transferred: I.Information() = dwBytesSent; return I.PnpComplete(this, status); } |
|