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: lib/ntdll/rtl/compress.c
25 * PROGRAMER: Eric Kohl (ekohl@rz-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);
83 RtlCompressBuffer(IN USHORT CompressionFormatAndEngine,
84 IN PUCHAR UncompressedBuffer,
85 IN ULONG UncompressedBufferSize,
86 OUT PUCHAR CompressedBuffer,
87 IN ULONG CompressedBufferSize,
88 IN ULONG UncompressedChunkSize,
89 OUT PULONG FinalCompressedSize,
92 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
93 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
95 if ((Format == COMPRESSION_FORMAT_NONE) ||
96 (Format == COMPRESSION_FORMAT_DEFAULT))
97 return(STATUS_INVALID_PARAMETER);
99 if (Format == COMPRESSION_FORMAT_LZNT1)
100 return(RtlpCompressBufferLZNT1(Engine,
102 UncompressedBufferSize,
104 CompressedBufferSize,
105 UncompressedChunkSize,
109 return(STATUS_UNSUPPORTED_COMPRESSION);
115 RtlCompressChunks(IN PUCHAR UncompressedBuffer,
116 IN ULONG UncompressedBufferSize,
117 OUT PUCHAR CompressedBuffer,
118 IN ULONG CompressedBufferSize,
119 IN OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
120 IN ULONG CompressedDataInfoLength,
123 return(STATUS_NOT_IMPLEMENTED);
132 RtlDecompressBuffer(IN USHORT CompressionFormat,
133 OUT PUCHAR UncompressedBuffer,
134 IN ULONG UncompressedBufferSize,
135 IN PUCHAR CompressedBuffer,
136 IN ULONG CompressedBufferSize,
137 OUT PULONG FinalUncompressedSize)
139 return(STATUS_NOT_IMPLEMENTED);
145 RtlDecompressChunks(OUT PUCHAR UncompressedBuffer,
146 IN ULONG UncompressedBufferSize,
147 IN PUCHAR CompressedBuffer,
148 IN ULONG CompressedBufferSize,
149 IN PUCHAR CompressedTail,
150 IN ULONG CompressedTailSize,
151 IN PCOMPRESSED_DATA_INFO CompressedDataInfo)
153 return(STATUS_NOT_IMPLEMENTED);
162 RtlDecompressFragment(IN USHORT CompressionFormat,
163 OUT PUCHAR UncompressedFragment,
164 IN ULONG UncompressedFragmentSize,
165 IN PUCHAR CompressedBuffer,
166 IN ULONG CompressedBufferSize,
167 IN ULONG FragmentOffset,
168 OUT PULONG FinalUncompressedSize,
171 return(STATUS_NOT_IMPLEMENTED);
177 RtlDescribeChunk(IN USHORT CompressionFormat,
178 IN OUT PUCHAR *CompressedBuffer,
179 IN PUCHAR EndOfCompressedBufferPlus1,
180 OUT PUCHAR *ChunkBuffer,
181 OUT PULONG ChunkSize)
183 return(STATUS_NOT_IMPLEMENTED);
192 RtlGetCompressionWorkSpaceSize(IN USHORT CompressionFormatAndEngine,
193 OUT PULONG CompressBufferAndWorkSpaceSize,
194 OUT PULONG CompressFragmentWorkSpaceSize)
196 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
197 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
199 if ((Format == COMPRESSION_FORMAT_NONE) ||
200 (Format == COMPRESSION_FORMAT_DEFAULT))
201 return(STATUS_INVALID_PARAMETER);
203 if (Format == COMPRESSION_FORMAT_LZNT1)
204 return(RtlpWorkSpaceSizeLZNT1(Engine,
205 CompressBufferAndWorkSpaceSize,
206 CompressFragmentWorkSpaceSize));
208 return(STATUS_UNSUPPORTED_COMPRESSION);
214 RtlReserveChunk(IN USHORT CompressionFormat,
215 IN OUT PUCHAR *CompressedBuffer,
216 IN PUCHAR EndOfCompressedBufferPlus1,
217 OUT PUCHAR *ChunkBuffer,
220 return(STATUS_NOT_IMPLEMENTED);