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);
81 RtlCompressBuffer(IN USHORT CompressionFormatAndEngine,
82 IN PUCHAR UncompressedBuffer,
83 IN ULONG UncompressedBufferSize,
84 OUT PUCHAR CompressedBuffer,
85 IN ULONG CompressedBufferSize,
86 IN ULONG UncompressedChunkSize,
87 OUT PULONG FinalCompressedSize,
90 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
91 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
93 if ((Format == COMPRESSION_FORMAT_NONE) ||
94 (Format == COMPRESSION_FORMAT_DEFAULT))
95 return(STATUS_INVALID_PARAMETER);
97 if (Format == COMPRESSION_FORMAT_LZNT1)
98 return(RtlpCompressBufferLZNT1(Engine,
100 UncompressedBufferSize,
102 CompressedBufferSize,
103 UncompressedChunkSize,
107 return(STATUS_UNSUPPORTED_COMPRESSION);
112 RtlCompressChunks(IN PUCHAR UncompressedBuffer,
113 IN ULONG UncompressedBufferSize,
114 OUT PUCHAR CompressedBuffer,
115 IN ULONG CompressedBufferSize,
116 IN OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
117 IN ULONG CompressedDataInfoLength,
120 return(STATUS_NOT_IMPLEMENTED);
125 RtlDecompressBuffer(IN USHORT CompressionFormat,
126 OUT PUCHAR UncompressedBuffer,
127 IN ULONG UncompressedBufferSize,
128 IN PUCHAR CompressedBuffer,
129 IN ULONG CompressedBufferSize,
130 OUT PULONG FinalUncompressedSize)
132 return(STATUS_NOT_IMPLEMENTED);
137 RtlDecompressChunks(OUT PUCHAR UncompressedBuffer,
138 IN ULONG UncompressedBufferSize,
139 IN PUCHAR CompressedBuffer,
140 IN ULONG CompressedBufferSize,
141 IN PUCHAR CompressedTail,
142 IN ULONG CompressedTailSize,
143 IN PCOMPRESSED_DATA_INFO CompressedDataInfo)
145 return(STATUS_NOT_IMPLEMENTED);
150 RtlDecompressFragment(IN USHORT CompressionFormat,
151 OUT PUCHAR UncompressedFragment,
152 IN ULONG UncompressedFragmentSize,
153 IN PUCHAR CompressedBuffer,
154 IN ULONG CompressedBufferSize,
155 IN ULONG FragmentOffset,
156 OUT PULONG FinalUncompressedSize,
159 return(STATUS_NOT_IMPLEMENTED);
164 RtlDescribeChunk(IN USHORT CompressionFormat,
165 IN OUT PUCHAR *CompressedBuffer,
166 IN PUCHAR EndOfCompressedBufferPlus1,
167 OUT PUCHAR *ChunkBuffer,
168 OUT PULONG ChunkSize)
170 return(STATUS_NOT_IMPLEMENTED);
175 RtlGetCompressionWorkSpaceSize(IN USHORT CompressionFormatAndEngine,
176 OUT PULONG CompressBufferAndWorkSpaceSize,
177 OUT PULONG CompressFragmentWorkSpaceSize)
179 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
180 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
182 if ((Format == COMPRESSION_FORMAT_NONE) ||
183 (Format == COMPRESSION_FORMAT_DEFAULT))
184 return(STATUS_INVALID_PARAMETER);
186 if (Format == COMPRESSION_FORMAT_LZNT1)
187 return(RtlpWorkSpaceSizeLZNT1(Engine,
188 CompressBufferAndWorkSpaceSize,
189 CompressFragmentWorkSpaceSize));
191 return(STATUS_UNSUPPORTED_COMPRESSION);
196 RtlReserveChunk(IN USHORT CompressionFormat,
197 IN OUT PUCHAR *CompressedBuffer,
198 IN PUCHAR EndOfCompressedBufferPlus1,
199 OUT PUCHAR *ChunkBuffer,
202 return(STATUS_NOT_IMPLEMENTED);