The RtlCompressBuffer function compresses a buffer and can be used by a file system driver to facilitate the implementation of file compression.
NT_RTL_COMPRESS_API NTSTATUS RtlCompressBuffer( USHORT CompressionFormatAndEngine, PUCHAR UncompressedBuffer, ULONG UncompressedBufferSize, PUCHAR CompressedBuffer, ULONG CompressedBufferSize, ULONG UncompressedChunkSize, PULONG FinalCompressedSize, PVOID WorkSpace );
A bitmask that specifies the compression format and engine type. This parameter must be set to a valid bitwise OR combination of one format type and one engine type. For example, COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_STANDARD.
The meanings of these, and other related values, are as follows.
A pointer to a caller-allocated buffer (allocated from paged or non-paged pool) that contains the data to be compressed. This parameter is required and cannot be NULL.
The size, in bytes, of the UncompressedBuffer buffer.
A pointer to a caller-allocated buffer (allocated from paged or non-paged pool) that receives the compressed data. This parameter is required and cannot be NULL.
The size, in bytes, of the CompressedBuffer buffer.
The chunk size to use when compressing the UncompressedBuffer buffer. This parameter must be one of the following values: 512, 1024, 2048, or 4096. The operating system uses 4096, and the recommended value for this parameter is also 4096.
A pointer to a caller-allocated variable that receives the size, in bytes, of the compressed data stored in CompressedBuffer. This parameter is required and cannot be NULL.
A pointer to a caller-allocated work space buffer used by the RtlCompressBuffer function during compression. Use the RtlGetCompressionWorkSpaceSize function to determine the correct work space buffer size.
RtlCompressBuffer returns an appropriate error status value, such as one of the following.
||The UncompressedBuffer buffer was successfully compressed.|
||The UncompressedBuffer buffer was successfully compressed, but this buffer contains only zeros.|
||An invalid compression engine was specified through the CompressionFormatAndEngine parameter. If CompressionFormatAndEngine is not COMPRESSION_ENGINE_STANDARD or COMPRESSION_ENGINE_MAXIMUM (but not both), this value is returned.|
||The compressed buffer is too small to hold the compressed data. That is, FinalCompressedSize is greater than CompressedBufferSize.|
The RtlCompressBuffer function takes as input an uncompressed buffer and produces its compressed equivalent provided that the compressed data fits within the specified destination buffer.
To determine the correct buffer size for the WorkSpace parameter, use the RtlGetCompressionWorkSpaceSize function.
To decompress a compressed buffer, use the RtlDecompressBuffer function.
To extract an uncompressed fragment from a compressed buffer, use the RtlDecompressFragment function.
|Minimum supported client||Available starting in Windows XP.|
|Header||ntifs.h (include Fltkernel.h, Ntifs.h)|