#ifndef _NTRTL_H
/**
* The RtlDecompressBuffer routine decompresses an entire compressed buffer.
*
* \param CompressionFormat The compression format used to compress the buffer.
* \param UncompressedBuffer A buffer that receives the decompressed data.
* \param UncompressedBufferSize The size, in bytes, of the uncompressed buffer.
* \param CompressedBuffer A pointer to the compressed data.
* \param CompressedBufferSize The size, in bytes, of the compressed buffer.
* \param FinalUncompressedSize A pointer to a variable that receives the number of bytes written to the uncompressed buffer.
* \return NTSTATUS Successful or errant status.
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtldecompressbuffer
* \remarks The dispatcher accepts a format, not format-or-engine flags: values below 2 return STATUS_INVALID_PARAMETER and values above 8 return STATUS_UNSUPPORTED_COMPRESSION. Support within that range depends on the implementation. Bound input and output and use the returned decompressed byte count.
*/
NTSYSAPI
NTSTATUS
NTAPI
RtlDecompressBuffer(
_In_ USHORT CompressionFormat,
_Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
_In_ ULONG UncompressedBufferSize,
_In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
_In_ ULONG CompressedBufferSize,
_Out_ PULONG FinalUncompressedSize
);
View code on GitHub// ntifs.h
NT_RTL_COMPRESS_API NTSTATUS RtlDecompressBuffer(
[in] USHORT CompressionFormat,
[out] PUCHAR UncompressedBuffer,
[in] ULONG UncompressedBufferSize,
[in] PUCHAR CompressedBuffer,
[in] ULONG CompressedBufferSize,
[out] PULONG FinalUncompressedSize
);
View the official Windows Driver Kit DDI referenceNo description available.
The RtlDecompressBuffer function decompresses an entire compressed buffer.
CompressionFormat [in]A bitmask that specifies the compression format of the compressed buffer. This parameter must be set to COMPRESSION_FORMAT_LZNT1. The meaning of this and other related compression format values are as follows.
| Value | Meaning |
|---|---|
| COMPRESSION_FORMAT_NONE | Not supported by this function. |
| COMPRESSION_FORMAT_DEFAULT | Not supported by this function. |
| COMPRESSION_FORMAT_LZNT1 | The function will perform LZ compression. |
| COMPRESSION_FORMAT_XPRESS | The function will perform Xpress compression. |
UncompressedBuffer [out]A pointer to a caller-allocated buffer (allocated from paged or non-paged pool) that receives the decompressed data from CompressedBuffer. This parameter is required and cannot be NULL.
UncompressedBufferSize [in]The size, in bytes, of the UncompressedBuffer buffer.
CompressedBuffer [in]A pointer to the buffer that contains the data to decompress. This parameter is required and cannot be NULL.
CompressedBufferSize [in]The size, in bytes, of the CompressedBuffer buffer.
FinalUncompressedSize [out]A pointer to a caller-allocated variable that receives the size, in bytes, of the decompressed data stored in UncompressedBuffer. This parameter is required and cannot be NULL.
RtlDecompressBuffer returns an appropriate error status value, such as one of the following.
| Return code | Description |
|---|---|
| STATUS_SUCCESS | The CompressedBuffer buffer was successfully decompressed. |
| STATUS_INVALID_PARAMETER | An invalid compression format was specified through the CompressionFormat parameter. If CompressionFormat is either COMPRESSION_FORMAT_NONE or COMPRESSION_FORMAT_DEFAULT (but not both), this value is returned. |
| STATUS_UNSUPPORTED_COMPRESSION | An invalid compression format was specified through the CompressionFormat parameter. If CompressionFormat is not one of the following, STATUS_UNSUPPORTED_COMPRESSION is returned: COMPRESSION_FORMAT_LZNT1, COMPRESSION_FORMAT_XPRESS |
| STATUS_BAD_COMPRESSION_BUFFER | UncompressedBuffer is not large enough to contain the uncompressed data. |
The RtlDecompressBuffer function takes as input an entire compressed buffer and produces its decompressed equivalent provided that the uncompressed data fits within the specified destination buffer.
To decompress only a portion of a compressed buffer (that is, a "fragment" of the buffer), use the RtlDecompressFragment function.
To compress an uncompressed buffer, use the RtlCompressBuffer function.
This function is documented in Windows Driver Kit.
See RtlCompressBuffer for possible compression formats. Compression engine is not used
in RtlDecompressBuffer.