Re[2]: Can I replace Irp's MdlAddress or UserBuffer to a buffer allocated in my driver?

> Probably, it makes sense just to return STATUS_BUFFER_TOO_SMALL if

you believe the buffer is not large enough to hold all data???

This is definitely not a good idea.

Usually, when I use WriteFile function, I check the result
and if it fails, I assume disk is full. And I guess almost
everyone does this. It’s logical to expect WriteFile
just write all data or fail. Adjusting a buffer according to
data is usual in some read APIs (like registry), not in case of
WriteFile.

Moreover WriteFile does not have any
“dwNumberOfBytesNeededBecauseOfThirdPartyDriver” parameter,
neither has NtWriteFile.

L.

Please, ignore my previous post, I mixed it with
something else here, so the answer was not apropriate
to the question.

L.

> Usually, when I use WriteFile function, I check the result and if it fails, I assume disk is full.

Actually, we are speaking about reading from the device and not about writing to it - if we were speaking about writing, the whole problem just would not make sense, because, unlike output buffer, an input buffer just cannot be too small to hold all data, no matter how you look at it. Think about it carefully, and you will understand it yourself…

Anton Bassov