Skip to content

Commit fc8e433

Browse files
committed
Added GPL license.
1 parent 60ba940 commit fc8e433

19 files changed

+1010
-8
lines changed

Diff for: gpl.txt

+674
Large diffs are not rendered by default.

Diff for: library/Bitstream.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "Bitstream.h"
219

320
#ifdef __cplusplus_cli

Diff for: library/Bitstream.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
////////////////////////////// Bitstreams //////////////////////////////////////////////////////////
219
// A bitstream that allows either reading or writing, but not both at the same time.
320
// It reads uint16s for bits and 16 bits can be reliably read at a time

Diff for: library/Dictionary.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "Dictionary.h"
219

320
// Implementation designed for being extremely fast at the expense of memory

Diff for: library/Dictionary.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
/////////////////// Dictionary /////////////////////////////////////////////////
219
// The dictionary system used for LZNT1 and XPRESS compression.
320
//

Diff for: library/compression-api.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
18+
// General include file which includes necessary files, defines, and typedefs.
19+
120
#ifndef COMPRESSION_API_H
221
#define COMPRESSION_API_H
322

@@ -142,7 +161,7 @@
142161
#define E_INVALID_DATA 0x103
143162

144163
// Define types used
145-
typedef uint8_t byte;
164+
typedef uint8_t byte; // should always be unsigned char (there is a check for CHAR_BIT == 8 above)
146165
typedef byte* bytes;
147166
typedef const byte const_byte;
148167
typedef const_byte* const_bytes;

Diff for: library/compression.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "compression.h"
219

320
#include "lznt1.h"
@@ -13,6 +30,7 @@
1330
#define ARRAYSIZE(x) sizeof(x)/sizeof(x[0])
1431
#endif
1532

33+
// no-compression compression function
1634
size_t copy_data(const_bytes in, size_t in_len, bytes out, size_t out_len)
1735
{
1836
if (in_len > out_len)

Diff for: library/compression.h

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
// Compression and Decompression Functions
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
217

18+
// Compression and Decompression Functions
19+
//
320
// These mimic RtlCompressBuffer and RtlDecompressBuffer from NTDLL.DLL. They provide access to
421
// LZX (WIM), LZNT1, Xpress (LZ), and Xpress Huffman algorithms. They attempt to provide results
522
// similar to the RTL functions in terms of speed and compression rate. The RTL functions do not
623
// accept the LZX format. Also, the provided functions always use the 'maximum engine'. For
724
// differences in the specific algorithms see their header files.
825

926
// Here is how to convert between the RTL functions and these functions:
10-
11-
//err = RtlCompressBuffer(FORMAT|MAX, in, in_len, out, out_len, 4096, &size, ***);
27+
//
28+
//err = RtlCompressBuffer(FORMAT|MAX, in, in_len, out, out_len, 4096, &size, ***); // chunk size and temporary buffer arguments dropped
1229
//size = compress(FORMAT, in, in_len, out, out_len); if (size == 0) err = errno;
13-
14-
//err = RtlDecompressBuffer(FORMAT, out, out_len, in, in_len, &size); // (switched order of in and out!)
30+
//
31+
//err = RtlDecompressBuffer(FORMAT, out, out_len, in, in_len, &size); // switched order of in and out!
1532
//size = decompress(FORMAT, in, in_len, out, out_len); if (size == 0) err = errno;
1633

1734
#ifndef COMPRESSION_H

Diff for: library/lznt1.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "lznt1.h"
219

320
#include "Dictionary.h"

Diff for: library/lznt1.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
// LZNT1 Compression and Decompression Functions
219
//
320
// This algorithm is used for NTFS file compression, Windows 2000 hibernation file, Active

Diff for: library/lzx.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
// This code is adapted from 7-zip. See http://www.7-zip.org/.
18+
119
#include "lzx.h"
220

321
#include "Bitstream.h"

Diff for: library/lzx.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
// Implements the LZX decompression algorithm used in WIM files.
219
// This is very similar to LZX decompression for CAB files with some minor differences.
320
//

Diff for: library/xpress.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "xpress.h"
219

320
#ifdef __cplusplus_cli
@@ -68,6 +85,24 @@ static void xpress_hashes_init_lcg()
6885
}
6986
xpress_hashes_initialized = true;
7087
}
88+
// Common LCG parameters:
89+
//MSVCRT: inline static void xpress_hashes_init() { xpress_hashes_init_lcg<SEED, 214013ul, 2531011ul, (1ull << 32), 16>(); }
90+
//RtlUniform: inline static void xpress_hashes_init() { xpress_hashes_init_lcg<SEED, 0x 7FFFFFEDul, 0x7FFFFFC3ul, (1ull << 31)-1, 15>(); }
91+
//Java: inline static void xpress_hashes_init() { xpress_hashes_init_lcg<SEED, 0x5DEECE66Dul, 11ul, (1ull << 48), 48-15>(); } // the SEED is processed with (SEED ^ 0x5DEECE66Dul) % (1ull << 48)
92+
//GLIBC: inline static void xpress_hashes_init() { xpress_hashes_init_lcg<SEED, 0x 41C64E6Dul, 12345ul, (1ull << 32), 16>(); }
93+
//CarbonLib: inline static void xpress_hashes_init() { xpress_hashes_init_lcg<SEED, 16807ul, 0ul, (1ull << 31)-1, 15>(); } // Also called MINSTD
94+
// The real Microsoft one for XPRESS is similar to a LCG but not quite the same. It uses a seed of 0x13579BDFul. The inside loop of the LCG is changed to:
95+
// uint32_t a = 0, b = hash, c = 0x87654321u;
96+
// int k;
97+
// for (k = 0; k < 32; ++k)
98+
// {
99+
// uint32_t d;
100+
// a -= 0x61C88647u; b += a; c += a;
101+
// d = ((c + 0x3B2A1908) ^ (b + 0x43B2A19) ^ (a - 0x789ABCDF)) + hash;
102+
// hash = ((a + d) ^ (c + (d >> 5)) ^ (b + (d << 3))) + d;
103+
// }
104+
// table[j] = (hash -= 0x789ABCDFu) & (MAX_HASH - 1);
105+
71106
// Initialize using the LCG with constants from GLIBC rand() and a "random" seed
72107
inline static void xpress_hashes_init() { xpress_hashes_init_lcg<0x001A5BA5u, 0x41C64E6Du, 12345u, 1ull << 32, 16>(); }
73108
inline static uint_fast16_t xpress_hash(const const_bytes x) { return xpress_hashes[0][x[0]] ^ xpress_hashes[1][x[1]] ^ xpress_hashes[2][x[2]]; }

Diff for: library/xpress.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
// Xpress Compression and Decompression Functions
219
//
320
// This is the LZ version of the Xpress algorithm, used for Windows XP and newer hibernation file,

Diff for: library/xpress_huff.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "xpress_huff.h"
219

320
#include "Dictionary.h"

Diff for: library/xpress_huff.h

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// ms-compress: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
// Xpress Huffman Compression and Decompression Functions
219
//
320
// This is the Xpress compression used in WIM files not the hibernation file.

Diff for: stdafx.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
// ms-compress-test: implements Microsoft compression algorithms
2+
// Copyright (C) 2012 Jeffrey Bush [email protected]
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
118
#include "stdafx.h"

0 commit comments

Comments
 (0)