3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: Compression and decompression functions
24 * FILE: ntoskrnl/rtl/compress.c
25 * PROGRAMER: Eric Kohl (ekohl@zr-online.de)
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
33 /* MACROS *******************************************************************/
35 #define COMPRESSION_FORMAT_MASK 0x00FF
36 #define COMPRESSION_ENGINE_MASK 0xFF00
39 /* FUNCTIONS ****************************************************************/
43 RtlpCompressBufferLZNT1(USHORT Engine,
44 PUCHAR UncompressedBuffer,
45 ULONG UncompressedBufferSize,
46 PUCHAR CompressedBuffer,
47 ULONG CompressedBufferSize,
48 ULONG UncompressedChunkSize,
49 PULONG FinalCompressedSize,
52 return(STATUS_NOT_IMPLEMENTED);
57 RtlpWorkSpaceSizeLZNT1(USHORT Engine,
58 PULONG BufferAndWorkSpaceSize,
59 PULONG FragmentWorkSpaceSize)
61 if (Engine == COMPRESSION_ENGINE_STANDARD)
63 *BufferAndWorkSpaceSize = 0x8010;
64 *FragmentWorkSpaceSize = 0x1000;
65 return(STATUS_SUCCESS);
67 else if (Engine == COMPRESSION_ENGINE_MAXIMUM)
69 *BufferAndWorkSpaceSize = 0x10;
70 *FragmentWorkSpaceSize = 0x1000;
71 return(STATUS_SUCCESS);
74 return(STATUS_NOT_SUPPORTED);
84 RtlCompressBuffer(IN USHORT CompressionFormatAndEngine,
85 IN PUCHAR UncompressedBuffer,
86 IN ULONG UncompressedBufferSize,
87 OUT PUCHAR CompressedBuffer,
88 IN ULONG CompressedBufferSize,
89 IN ULONG UncompressedChunkSize,
90 OUT PULONG FinalCompressedSize,
93 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
94 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
96 if ((Format == COMPRESSION_FORMAT_NONE) ||
97 (Format == COMPRESSION_FORMAT_DEFAULT))
98 return(STATUS_INVALID_PARAMETER);
100 if (Format == COMPRESSION_FORMAT_LZNT1)
101 return(RtlpCompressBufferLZNT1(Engine,
103 UncompressedBufferSize,
105 CompressedBufferSize,
106 UncompressedChunkSize,
110 return(STATUS_UNSUPPORTED_COMPRESSION);
118 RtlCompressChunks(IN PUCHAR UncompressedBuffer,
119 IN ULONG UncompressedBufferSize,
120 OUT PUCHAR CompressedBuffer,
121 IN ULONG CompressedBufferSize,
122 IN OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
123 IN ULONG CompressedDataInfoLength,
126 return(STATUS_NOT_IMPLEMENTED);
134 RtlDecompressBuffer(IN USHORT CompressionFormat,
135 OUT PUCHAR UncompressedBuffer,
136 IN ULONG UncompressedBufferSize,
137 IN PUCHAR CompressedBuffer,
138 IN ULONG CompressedBufferSize,
139 OUT PULONG FinalUncompressedSize)
141 return(STATUS_NOT_IMPLEMENTED);
149 RtlDecompressChunks(OUT PUCHAR UncompressedBuffer,
150 IN ULONG UncompressedBufferSize,
151 IN PUCHAR CompressedBuffer,
152 IN ULONG CompressedBufferSize,
153 IN PUCHAR CompressedTail,
154 IN ULONG CompressedTailSize,
155 IN PCOMPRESSED_DATA_INFO CompressedDataInfo)
157 return(STATUS_NOT_IMPLEMENTED);
165 RtlDecompressFragment(IN USHORT CompressionFormat,
166 OUT PUCHAR UncompressedFragment,
167 IN ULONG UncompressedFragmentSize,
168 IN PUCHAR CompressedBuffer,
169 IN ULONG CompressedBufferSize,
170 IN ULONG FragmentOffset,
171 OUT PULONG FinalUncompressedSize,
174 return(STATUS_NOT_IMPLEMENTED);
182 RtlDescribeChunk(IN USHORT CompressionFormat,
183 IN OUT PUCHAR *CompressedBuffer,
184 IN PUCHAR EndOfCompressedBufferPlus1,
185 OUT PUCHAR *ChunkBuffer,
186 OUT PULONG ChunkSize)
188 return(STATUS_NOT_IMPLEMENTED);
196 RtlGetCompressionWorkSpaceSize(IN USHORT CompressionFormatAndEngine,
197 OUT PULONG CompressBufferAndWorkSpaceSize,
198 OUT PULONG CompressFragmentWorkSpaceSize)
200 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
201 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
203 if ((Format == COMPRESSION_FORMAT_NONE) ||
204 (Format == COMPRESSION_FORMAT_DEFAULT))
205 return(STATUS_INVALID_PARAMETER);
207 if (Format == COMPRESSION_FORMAT_LZNT1)
208 return(RtlpWorkSpaceSizeLZNT1(Engine,
209 CompressBufferAndWorkSpaceSize,
210 CompressFragmentWorkSpaceSize));
212 return(STATUS_UNSUPPORTED_COMPRESSION);
220 RtlReserveChunk(IN USHORT CompressionFormat,
221 IN OUT PUCHAR *CompressedBuffer,
222 IN PUCHAR EndOfCompressedBufferPlus1,
223 OUT PUCHAR *ChunkBuffer,
226 return(STATUS_NOT_IMPLEMENTED);