TdiCopyMdlToBuffer

NTSTATUS
    TdiCopyMdlToBuffer (
        IN PMDL  SourceMdlChain,
        IN ULONG  SourceOffset,
        IN PVOID  DestinationBuffer,
        IN ULONG  DestinationOffset,
        IN ULONG  DestinationBufferSize,
        OUT PULONG  BytesCopied
        );

TdiCopyMdlToBuffer copies data from a set of buffer(s) mapped by a given MDL chain into a caller-supplied destination buffer range.

Parameters

SourceMdlChain
Points to the initial MDL in a chain of MDLs mapping buffers containing the data to be copied.
SourceOffset
Specifies the byte offset within the mapped source buffer(s) at which to begin the copy. Effectively, this is the number of mapped source bytes to skip before beginning the copy.
DestinationBuffer
Points to the caller-supplied destination buffer.
DestinationOffset
Specifies the byte offset within the destination buffer at which to begin copying the data from the source buffer(s).
DestinationBufferSize
Specifies the size in bytes of the buffer at DestinationBuffer.
BytesCopied
Points to a caller-supplied variable in which TdiCopyMdlToBuffer returns the number of bytes it copied.

Return Value

TdiCopyMdlToBuffer returns STATUS_SUCCESS if it copied (DestinationBufferSize - DestinationOffset) bytes into the destination buffer. Otherwise, it returns STATUS_BUFFER_OVERFLOW if the given SourceMdlChain, starting at SourceOffset, maps more data than the range (DestinationBufferSize - DestinationOffset) can contain.

Comments

TdiCopyMdlToBuffer always copies as much data as possible from the given mapped source buffer(s) into the given destination buffer range, even if it returns STATUS_BUFFER_OVERFLOW.

At most, the return value of BytesCopied can be the given DestinationBufferSize if DestinationOffset is zero.

Both transports and their kernel-mode clients can call TdiCopyMdlToBuffer.

Callers of TdiCopyMdlToBuffer can be running at IRQL <= DISPATCH_LEVEL if the source and destination buffers are resident. If either is pageable, the caller must be running at IRQL < DISPATCH_LEVEL.

See Also

TdiCopyLookaheadData, TdiCopyBufferToMdl