how to get the transfer data buffer address in disk lower filter driver?

Hi, everyone.
I write a disk lower filter driver and filter the IRP_MJ_SCSI::SCSI_READ/SCSI_WRITE
request. Now I want to get the transfer data buffer address.
Should I use MmGetSystemAddressForMdlSafe( Irp->MdlAddress, …);
or Srb->DataBuffer;
or Irp->UserBuffer;

Thank you very much!

You have the source code for the storage class drivers in the DDK. Look at SetupReadWriteTransferPacket. If you want to get a kernel virtual address for the data buffer you need the MDL for this request plus the offset into the system address for the portion of the request covered by this SRB (Srb.DataBuffer - MmGetMdlVirtualAddress(Irp->MdlAddress). However you need the OriginalIrp for all of this, not the Irp for the SRB. The original irp is at Srb.OriginalRequest.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-289258-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, June 05, 2007 10:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] how to get the transfer data buffer address in disk
lower filter driver?

Hi, everyone.
I write a disk lower filter driver and filter the
IRP_MJ_SCSI::SCSI_READ/SCSI_WRITE
request. Now I want to get the transfer data buffer address.
Should I use MmGetSystemAddressForMdlSafe( Irp->MdlAddress,
…);
or Srb->DataBuffer;
or Irp->UserBuffer;

Thank you very much!


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you.
I have checked the SetupReadWriteTransferPacket source code.
It use MmGetMdlVirtualAddress to get the buffer address and
save in srb->DataBuffer.
In C, It’s like this srb->DataBuffer = MmGetMdlVirtualAddress( Irp->MdlAddress );
But in my lower filter driver, srb->DataBuffer is a NULL pointer in 99%.

> request. Now I want to get the transfer data buffer address.

Should I use MmGetSystemAddressForMdlSafe( Irp->MdlAddress, …);

This one. Check for possible NULL failure.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>for all of this, not the Irp for the SRB. The original irp is at
Srb.OriginalRequest.

Starting from w2k, Srb.OriginalRequest points to the internal SCSIPORT’s
structure and not to the IRP.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com