2,641
社区成员
发帖
与我相关
我的任务
分享
NTSTATUS UsbIntDevice::Write(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
NTSTATUS status = STATUS_SUCCESS;
// TODO: Validate the parameters of the IRP. Replace "FALSE"
// in the following line with error checking code that
// evaulates to TRUE if the request is not valid.
if (FALSE)
{
status = STATUS_INVALID_PARAMETER;
I.Information() = 0;
I.PnpComplete(status);
T.Trace(TraceWarning, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
// Always ok to write 0 elements
if (I.WriteSize() == 0)
{
I.Information() = 0;
I.PnpComplete(this, status);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
KMemory Mem(I.Mdl()); // Declare a memory object
// Get a pointer to the caller's buffer. Note that this
// routine is safe on all platforms.
PUCHAR pBuffer = (PUCHAR) Mem.MapToSystemSpace();
ULONG writeSize = I.WriteSize();
ULONG bytesSent = 0;
// TODO: At this point, perform any processing for IRP_MJ_WRITE
// To satisfy the write now, transfer data to the driver
// from the caller's buffer at "pBuffer". Then, indicate
// how much data was transferred:
//////////////////////////////////////////////////// Kondy Add Start
PURB pUrb =EP2_OUT.BuildBulkTransfer(
Mem,
I.IoctlInputBufferSize(),
FALSE,
NULL);
if(pUrb==NULL)
{
I.Information()=0;
return I.PnpComplete(this,STATUS_INSUFFICIENT_RESOURCES);
}
status=EP2_OUT.SubmitUrb(pUrb,NULL,NULL,1500L);
bytesSent=pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;
////////////////////////////////////////////////////Kondy Add End
I.Information() = bytesSent;
I.PnpComplete(this, status);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}