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);
80 RtlCompressBuffer(IN USHORT CompressionFormatAndEngine,
81 IN PUCHAR UncompressedBuffer,
82 IN ULONG UncompressedBufferSize,
83 OUT PUCHAR CompressedBuffer,
84 IN ULONG CompressedBufferSize,
85 IN ULONG UncompressedChunkSize,
86 OUT PULONG FinalCompressedSize,
89 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
90 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
92 if ((Format == COMPRESSION_FORMAT_NONE) ||
93 (Format == COMPRESSION_FORMAT_DEFAULT))
94 return(STATUS_INVALID_PARAMETER);
96 if (Format == COMPRESSION_FORMAT_LZNT1)
97 return(RtlpCompressBufferLZNT1(Engine,
99 UncompressedBufferSize,
101 CompressedBufferSize,
102 UncompressedChunkSize,
106 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);
126 RtlDecompressBuffer(IN USHORT CompressionFormat,
127 OUT PUCHAR UncompressedBuffer,
128 IN ULONG UncompressedBufferSize,
129 IN PUCHAR CompressedBuffer,
130 IN ULONG CompressedBufferSize,
131 OUT PULONG FinalUncompressedSize)
133 return(STATUS_NOT_IMPLEMENTED);
139 RtlDecompressChunks(OUT PUCHAR UncompressedBuffer,
140 IN ULONG UncompressedBufferSize,
141 IN PUCHAR CompressedBuffer,
142 IN ULONG CompressedBufferSize,
143 IN PUCHAR CompressedTail,
144 IN ULONG CompressedTailSize,
145 IN PCOMPRESSED_DATA_INFO CompressedDataInfo)
147 return(STATUS_NOT_IMPLEMENTED);
153 RtlDecompressFragment(IN USHORT CompressionFormat,
154 OUT PUCHAR UncompressedFragment,
155 IN ULONG UncompressedFragmentSize,
156 IN PUCHAR CompressedBuffer,
157 IN ULONG CompressedBufferSize,
158 IN ULONG FragmentOffset,
159 OUT PULONG FinalUncompressedSize,
162 return(STATUS_NOT_IMPLEMENTED);
168 RtlDescribeChunk(IN USHORT CompressionFormat,
169 IN OUT PUCHAR *CompressedBuffer,
170 IN PUCHAR EndOfCompressedBufferPlus1,
171 OUT PUCHAR *ChunkBuffer,
172 OUT PULONG ChunkSize)
174 return(STATUS_NOT_IMPLEMENTED);
180 RtlGetCompressionWorkSpaceSize(IN USHORT CompressionFormatAndEngine,
181 OUT PULONG CompressBufferAndWorkSpaceSize,
182 OUT PULONG CompressFragmentWorkSpaceSize)
184 USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
185 USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
187 if ((Format == COMPRESSION_FORMAT_NONE) ||
188 (Format == COMPRESSION_FORMAT_DEFAULT))
189 return(STATUS_INVALID_PARAMETER);
191 if (Format == COMPRESSION_FORMAT_LZNT1)
192 return(RtlpWorkSpaceSizeLZNT1(Engine,
193 CompressBufferAndWorkSpaceSize,
194 CompressFragmentWorkSpaceSize));
196 return(STATUS_UNSUPPORTED_COMPRESSION);
202 RtlReserveChunk(IN USHORT CompressionFormat,
203 IN OUT PUCHAR *CompressedBuffer,
204 IN PUCHAR EndOfCompressedBufferPlus1,
205 OUT PUCHAR *ChunkBuffer,
208 return(STATUS_NOT_IMPLEMENTED);