Writing Multiple Buffers to file using single IRP

Hi,

I want to implement the functionality of

WriteFileGather(win32 API for scatter/gather IO) in Kernel Mode.

I want to write multiple buffers to file using single IRP.

For this I have followed folowing procedure

1.I have opened file using ZwCreateFile

2.obtained FILE_OBJECT related to file handle

3.created MDL for multiple buffers using IOAllocateMdl

4.Obtained the Device Object using IoGetRelatedDeviceObject

5.created Irp using IoAllocateIrp

6.Initialized the fields of Irp

7.called the IoCallDriver for device object in step 4

I am getting NTSTATUS as 259 for IoCallDriver.

Am I doing some thing wrong ?

Is there any alternative way to do this?

Note:I am using Windows 2003 server with SP2. and for driver compilation I am using WDK.

Thanks in advance.

I have followed the same procedure for reading the multiple buffers from file using sinfgle IRP and it is working fine(It is some what similar to ReadFileScatter(win32 API for scatter/gather IO))

> 3.created MDL for multiple buffers using IOAllocateMdl

IoAllocateMdl only supports a single buffer. How are you managing multiple buffers?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Status 259 is STATUS_PENDING (0x103).

What were you expecting? That it would complete synchronously each time?

It’s async I/O. You have to be prepared to let the system complete the I/O
and signal that completion asynchronously.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@spsoftindia.com
Sent: Wednesday, September 16, 2009 12:31 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Writing Multiple Buffers to file using single IRP

Hi,

I want to implement the functionality of

WriteFileGather(win32 API for scatter/gather IO) in Kernel Mode.

I want to write multiple buffers to file using single IRP.

For this I have followed folowing procedure

1.I have opened file using ZwCreateFile

2.obtained FILE_OBJECT related to file handle

3.created MDL for multiple buffers using IOAllocateMdl

4.Obtained the Device Object using IoGetRelatedDeviceObject

5.created Irp using IoAllocateIrp

6.Initialized the fields of Irp

7.called the IoCallDriver for device object in step 4

I am getting NTSTATUS as 259 for IoCallDriver.

Am I doing some thing wrong ?

Is there any alternative way to do this?

Note:I am using Windows 2003 server with SP2. and for driver compilation I
am using WDK.

Thanks in advance.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

hi David,

when I get the NTSTATUS as 259, I wait for the Event.
After succesfull wait ,status in IO_STATUS_BLOCK is 0.
But nothing is written to a file

Thanks,

Your post made it seem like you did not expect or understand what status 259
was. My mistake.

I don’t know what is going wrong but I suspect that it is related to you
trying to roll your own IRP_MJ_WRITE request that you expect to be processed
by a FSD. Perhaps someone on the list has some guidance on whether or not
that is a reasonable thing to do and/or how to do so.

I suspect that it is *not* a reasonable thing to do and/or that the
restrictions & rules on how to factor in all of the possible permutations to
setup the IRP_MJ_WRITE correctly are not easily expressed.

I did note that NTOSKRNL public symbols show the existence of
ZwWriteFileGather/NtWriteFileGather as a function but the export table for
Windows XP does not seem to list that routine. In other words, somebody
decided that doing gather I/O on a file from kernel mode is just not that
important a feature. Perhaps that is a clue that simply doing multiple
writes from kernel mode is going to be ‘close enough’.

Sorry I can’t help you.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@spsoftindia.com
Sent: Thursday, September 17, 2009 4:00 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Writing Multiple Buffers to file using single IRP

hi David,

when I get the NTSTATUS as 259, I wait for the Event.
After succesfull wait ,status in IO_STATUS_BLOCK is 0.
But nothing is written to a file

Thanks,


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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