In some cases, the MdlAddress or UserBuffer provided by Irp is not big enough for returning data, Can I replace MdlAddress or UserBuffer to a buffer allocated in my driver and how to?
Well, everything depends on the context you are asking your question in…
If you are passing IRP down the stack, you can allocate your own IRP, specify a buffer that has been allocated by your driver, and pass it down the stack instead of the original one - this is out of question. The “only” question is what you are going to do with the data that underlying driver returns if the buffer that has been specified by the original caller is too small to hold it.
Probably, it makes sense just to return STATUS_BUFFER_TOO_SMALL if you believe the buffer is not large enough to hold all data???
Anton Bassov
a) Replace them both to maintain that MDL’s base address is ->UserBuffer
b) Replace them back in the completion routine.
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
wrote in message news:xxxxx@ntfsd…
> In some cases, the MdlAddress or UserBuffer provided by Irp is not big enough
for returning data, Can I replace MdlAddress or UserBuffer to a buffer
allocated in my driver and how to?
>
Maxim,
a) Replace them both to maintain that MDL’s base address is ->UserBuffer
b) Replace them back in the completion routine.
What is the point of doing anything here if you have to return, say, 8192 bytes at the time when the client has specified the output buffer of the size, say, 4096 bytes? Even if you get all data from the underlying driver, where are you going to output the remaining 4096 bytes? Let’s face it - no matter what you do the client will be unable to see all data anyway. I think the only reasonable thing to do here is just to inform the client that the buffer it has provided is too small for all data…
Anton Bassov
Yeah. Just as I had thought, maybe the only way is to return STATUS_BUFFER_TOO_SMALL.