TdiCopyBufferToMdl

NTSTATUS
    TdiCopyBufferToMdl (
        IN PVOID  SourceBuffer,
        IN ULONG  SourceOffset,
        IN ULONG  SourceBytesToCopy,
        IN PMDL  DestinationMdlChain,
        IN ULONG  DestinationOffset,
        IN PULONG  BytesCopied
        );

TdiCopyBufferToMdl copies data from a buffer range into a set of one or more destination buffers mapped by a given MDL chain.

Parameters

SourceBuffer
Specifies the base virtual address of the source buffer containing the data to be copied.
SourceOffset
Specifies the byte offset within the source buffer at which to begin the copy.
SourceBytesToCopy
Specifies the number of bytes to copy from SourceBuffer to the buffer mapped by the given MDL.
DestinationMdlChain
Points to the initial MDL in a chain of linked MDLs mapping the destination buffers into which to copy the data.
DestinationOffset
Specifies the byte offset within the destination buffer(s) at which to begin the copy. Effectively, this is the number of bytes mapped by the given MDLs to skip before beginning the copy operation.
BytesCopied
Points to a caller-supplied variable in which TdiCopyBufferToMdl returns the number of bytes copied from the source to the destination buffer.

Return Value

TdiCopyBufferToMdl returns STATUS_SUCCESS if it copied SourceBytesToCopy into the mapped destination buffer(s). Otherwise, it returns STATUS_BUFFER_OVERFLOW if SourceBytesToCopy was too large to fit into the destination buffer space available from the given DestinationOffset.

Comments

TdiCopyBufferToMdl always copies as much data as possible from the source buffer to the destination buffer(s), even if it returns STATUS_BUFFER_OVERFLOW. At most, the return value of BytesCopied is equal to the given SourceBytesToCopy.

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

Callers of TdiCopyBufferToMdl 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, TdiCopyMdlToBuffer