scripts
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000041 RID: 65
|
||||
public enum DeflateStrategy
|
||||
{
|
||||
// Token: 0x0400018B RID: 395
|
||||
Default,
|
||||
// Token: 0x0400018C RID: 396
|
||||
Filtered,
|
||||
// Token: 0x0400018D RID: 397
|
||||
HuffmanOnly
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x0200003F RID: 63
|
||||
public class Deflater
|
||||
{
|
||||
// Token: 0x06000278 RID: 632 RVA: 0x0000CE3A File Offset: 0x0000BE3A
|
||||
public Deflater()
|
||||
: this(-1, false)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000279 RID: 633 RVA: 0x0000CE44 File Offset: 0x0000BE44
|
||||
public Deflater(int level)
|
||||
: this(level, false)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600027A RID: 634 RVA: 0x0000CE50 File Offset: 0x0000BE50
|
||||
public Deflater(int level, bool noZlibHeaderOrFooter)
|
||||
{
|
||||
if (level == -1)
|
||||
{
|
||||
level = 6;
|
||||
}
|
||||
else if (level < 0 || level > 9)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("level");
|
||||
}
|
||||
this.pending = new DeflaterPending();
|
||||
this.engine = new DeflaterEngine(this.pending);
|
||||
this.noZlibHeaderOrFooter = noZlibHeaderOrFooter;
|
||||
this.SetStrategy(DeflateStrategy.Default);
|
||||
this.SetLevel(level);
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x0600027B RID: 635 RVA: 0x0000CEB7 File Offset: 0x0000BEB7
|
||||
public void Reset()
|
||||
{
|
||||
this.state = (this.noZlibHeaderOrFooter ? 16 : 0);
|
||||
this.totalOut = 0L;
|
||||
this.pending.Reset();
|
||||
this.engine.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x1700008C RID: 140
|
||||
// (get) Token: 0x0600027C RID: 636 RVA: 0x0000CEEA File Offset: 0x0000BEEA
|
||||
public int Adler
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.engine.Adler;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700008D RID: 141
|
||||
// (get) Token: 0x0600027D RID: 637 RVA: 0x0000CEF7 File Offset: 0x0000BEF7
|
||||
public long TotalIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.engine.TotalIn;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700008E RID: 142
|
||||
// (get) Token: 0x0600027E RID: 638 RVA: 0x0000CF04 File Offset: 0x0000BF04
|
||||
public long TotalOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalOut;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600027F RID: 639 RVA: 0x0000CF0C File Offset: 0x0000BF0C
|
||||
public void Flush()
|
||||
{
|
||||
this.state |= 4;
|
||||
}
|
||||
|
||||
// Token: 0x06000280 RID: 640 RVA: 0x0000CF1C File Offset: 0x0000BF1C
|
||||
public void Finish()
|
||||
{
|
||||
this.state |= 12;
|
||||
}
|
||||
|
||||
// Token: 0x1700008F RID: 143
|
||||
// (get) Token: 0x06000281 RID: 641 RVA: 0x0000CF2D File Offset: 0x0000BF2D
|
||||
public bool IsFinished
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.state == 30 && this.pending.IsFlushed;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000090 RID: 144
|
||||
// (get) Token: 0x06000282 RID: 642 RVA: 0x0000CF46 File Offset: 0x0000BF46
|
||||
public bool IsNeedingInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.engine.NeedsInput();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000283 RID: 643 RVA: 0x0000CF53 File Offset: 0x0000BF53
|
||||
public void SetInput(byte[] input)
|
||||
{
|
||||
this.SetInput(input, 0, input.Length);
|
||||
}
|
||||
|
||||
// Token: 0x06000284 RID: 644 RVA: 0x0000CF60 File Offset: 0x0000BF60
|
||||
public void SetInput(byte[] input, int offset, int count)
|
||||
{
|
||||
if ((this.state & 8) != 0)
|
||||
{
|
||||
throw new InvalidOperationException("Finish() already called");
|
||||
}
|
||||
this.engine.SetInput(input, offset, count);
|
||||
}
|
||||
|
||||
// Token: 0x06000285 RID: 645 RVA: 0x0000CF85 File Offset: 0x0000BF85
|
||||
public void SetLevel(int level)
|
||||
{
|
||||
if (level == -1)
|
||||
{
|
||||
level = 6;
|
||||
}
|
||||
else if (level < 0 || level > 9)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("level");
|
||||
}
|
||||
if (this.level != level)
|
||||
{
|
||||
this.level = level;
|
||||
this.engine.SetLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000286 RID: 646 RVA: 0x0000CFC0 File Offset: 0x0000BFC0
|
||||
public int GetLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
// Token: 0x06000287 RID: 647 RVA: 0x0000CFC8 File Offset: 0x0000BFC8
|
||||
public void SetStrategy(DeflateStrategy strategy)
|
||||
{
|
||||
this.engine.Strategy = strategy;
|
||||
}
|
||||
|
||||
// Token: 0x06000288 RID: 648 RVA: 0x0000CFD6 File Offset: 0x0000BFD6
|
||||
public int Deflate(byte[] output)
|
||||
{
|
||||
return this.Deflate(output, 0, output.Length);
|
||||
}
|
||||
|
||||
// Token: 0x06000289 RID: 649 RVA: 0x0000CFE4 File Offset: 0x0000BFE4
|
||||
public int Deflate(byte[] output, int offset, int length)
|
||||
{
|
||||
int num = length;
|
||||
if (this.state == 127)
|
||||
{
|
||||
throw new InvalidOperationException("Deflater closed");
|
||||
}
|
||||
if (this.state < 16)
|
||||
{
|
||||
int num2 = 30720;
|
||||
int num3 = this.level - 1 >> 1;
|
||||
if (num3 < 0 || num3 > 3)
|
||||
{
|
||||
num3 = 3;
|
||||
}
|
||||
num2 |= num3 << 6;
|
||||
if ((this.state & 1) != 0)
|
||||
{
|
||||
num2 |= 32;
|
||||
}
|
||||
num2 += 31 - num2 % 31;
|
||||
this.pending.WriteShortMSB(num2);
|
||||
if ((this.state & 1) != 0)
|
||||
{
|
||||
int adler = this.engine.Adler;
|
||||
this.engine.ResetAdler();
|
||||
this.pending.WriteShortMSB(adler >> 16);
|
||||
this.pending.WriteShortMSB(adler & 65535);
|
||||
}
|
||||
this.state = 16 | (this.state & 12);
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
int num4 = this.pending.Flush(output, offset, length);
|
||||
offset += num4;
|
||||
this.totalOut += (long)num4;
|
||||
length -= num4;
|
||||
if (length == 0 || this.state == 30)
|
||||
{
|
||||
goto IL_1DE;
|
||||
}
|
||||
if (!this.engine.Deflate((this.state & 4) != 0, (this.state & 8) != 0))
|
||||
{
|
||||
if (this.state == 16)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (this.state == 20)
|
||||
{
|
||||
if (this.level != 0)
|
||||
{
|
||||
for (int i = 8 + (-this.pending.BitCount & 7); i > 0; i -= 10)
|
||||
{
|
||||
this.pending.WriteBits(2, 10);
|
||||
}
|
||||
}
|
||||
this.state = 16;
|
||||
}
|
||||
else if (this.state == 28)
|
||||
{
|
||||
this.pending.AlignToByte();
|
||||
if (!this.noZlibHeaderOrFooter)
|
||||
{
|
||||
int adler2 = this.engine.Adler;
|
||||
this.pending.WriteShortMSB(adler2 >> 16);
|
||||
this.pending.WriteShortMSB(adler2 & 65535);
|
||||
}
|
||||
this.state = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
return num - length;
|
||||
IL_1DE:
|
||||
return num - length;
|
||||
}
|
||||
|
||||
// Token: 0x0600028A RID: 650 RVA: 0x0000D1D2 File Offset: 0x0000C1D2
|
||||
public void SetDictionary(byte[] dictionary)
|
||||
{
|
||||
this.SetDictionary(dictionary, 0, dictionary.Length);
|
||||
}
|
||||
|
||||
// Token: 0x0600028B RID: 651 RVA: 0x0000D1DF File Offset: 0x0000C1DF
|
||||
public void SetDictionary(byte[] dictionary, int index, int count)
|
||||
{
|
||||
if (this.state != 0)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
this.state = 1;
|
||||
this.engine.SetDictionary(dictionary, index, count);
|
||||
}
|
||||
|
||||
// Token: 0x0400015A RID: 346
|
||||
public const int BEST_COMPRESSION = 9;
|
||||
|
||||
// Token: 0x0400015B RID: 347
|
||||
public const int BEST_SPEED = 1;
|
||||
|
||||
// Token: 0x0400015C RID: 348
|
||||
public const int DEFAULT_COMPRESSION = -1;
|
||||
|
||||
// Token: 0x0400015D RID: 349
|
||||
public const int NO_COMPRESSION = 0;
|
||||
|
||||
// Token: 0x0400015E RID: 350
|
||||
public const int DEFLATED = 8;
|
||||
|
||||
// Token: 0x0400015F RID: 351
|
||||
private const int IS_SETDICT = 1;
|
||||
|
||||
// Token: 0x04000160 RID: 352
|
||||
private const int IS_FLUSHING = 4;
|
||||
|
||||
// Token: 0x04000161 RID: 353
|
||||
private const int IS_FINISHING = 8;
|
||||
|
||||
// Token: 0x04000162 RID: 354
|
||||
private const int INIT_STATE = 0;
|
||||
|
||||
// Token: 0x04000163 RID: 355
|
||||
private const int SETDICT_STATE = 1;
|
||||
|
||||
// Token: 0x04000164 RID: 356
|
||||
private const int BUSY_STATE = 16;
|
||||
|
||||
// Token: 0x04000165 RID: 357
|
||||
private const int FLUSHING_STATE = 20;
|
||||
|
||||
// Token: 0x04000166 RID: 358
|
||||
private const int FINISHING_STATE = 28;
|
||||
|
||||
// Token: 0x04000167 RID: 359
|
||||
private const int FINISHED_STATE = 30;
|
||||
|
||||
// Token: 0x04000168 RID: 360
|
||||
private const int CLOSED_STATE = 127;
|
||||
|
||||
// Token: 0x04000169 RID: 361
|
||||
private int level;
|
||||
|
||||
// Token: 0x0400016A RID: 362
|
||||
private bool noZlibHeaderOrFooter;
|
||||
|
||||
// Token: 0x0400016B RID: 363
|
||||
private int state;
|
||||
|
||||
// Token: 0x0400016C RID: 364
|
||||
private long totalOut;
|
||||
|
||||
// Token: 0x0400016D RID: 365
|
||||
private DeflaterPending pending;
|
||||
|
||||
// Token: 0x0400016E RID: 366
|
||||
private DeflaterEngine engine;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000040 RID: 64
|
||||
public class DeflaterConstants
|
||||
{
|
||||
// Token: 0x0400016F RID: 367
|
||||
public const bool DEBUGGING = false;
|
||||
|
||||
// Token: 0x04000170 RID: 368
|
||||
public const int STORED_BLOCK = 0;
|
||||
|
||||
// Token: 0x04000171 RID: 369
|
||||
public const int STATIC_TREES = 1;
|
||||
|
||||
// Token: 0x04000172 RID: 370
|
||||
public const int DYN_TREES = 2;
|
||||
|
||||
// Token: 0x04000173 RID: 371
|
||||
public const int PRESET_DICT = 32;
|
||||
|
||||
// Token: 0x04000174 RID: 372
|
||||
public const int DEFAULT_MEM_LEVEL = 8;
|
||||
|
||||
// Token: 0x04000175 RID: 373
|
||||
public const int MAX_MATCH = 258;
|
||||
|
||||
// Token: 0x04000176 RID: 374
|
||||
public const int MIN_MATCH = 3;
|
||||
|
||||
// Token: 0x04000177 RID: 375
|
||||
public const int MAX_WBITS = 15;
|
||||
|
||||
// Token: 0x04000178 RID: 376
|
||||
public const int WSIZE = 32768;
|
||||
|
||||
// Token: 0x04000179 RID: 377
|
||||
public const int WMASK = 32767;
|
||||
|
||||
// Token: 0x0400017A RID: 378
|
||||
public const int HASH_BITS = 15;
|
||||
|
||||
// Token: 0x0400017B RID: 379
|
||||
public const int HASH_SIZE = 32768;
|
||||
|
||||
// Token: 0x0400017C RID: 380
|
||||
public const int HASH_MASK = 32767;
|
||||
|
||||
// Token: 0x0400017D RID: 381
|
||||
public const int HASH_SHIFT = 5;
|
||||
|
||||
// Token: 0x0400017E RID: 382
|
||||
public const int MIN_LOOKAHEAD = 262;
|
||||
|
||||
// Token: 0x0400017F RID: 383
|
||||
public const int MAX_DIST = 32506;
|
||||
|
||||
// Token: 0x04000180 RID: 384
|
||||
public const int PENDING_BUF_SIZE = 65536;
|
||||
|
||||
// Token: 0x04000181 RID: 385
|
||||
public const int DEFLATE_STORED = 0;
|
||||
|
||||
// Token: 0x04000182 RID: 386
|
||||
public const int DEFLATE_FAST = 1;
|
||||
|
||||
// Token: 0x04000183 RID: 387
|
||||
public const int DEFLATE_SLOW = 2;
|
||||
|
||||
// Token: 0x04000184 RID: 388
|
||||
public static int MAX_BLOCK_SIZE = Math.Min(65535, 65531);
|
||||
|
||||
// Token: 0x04000185 RID: 389
|
||||
public static int[] GOOD_LENGTH = new int[] { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 };
|
||||
|
||||
// Token: 0x04000186 RID: 390
|
||||
public static int[] MAX_LAZY = new int[] { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 };
|
||||
|
||||
// Token: 0x04000187 RID: 391
|
||||
public static int[] NICE_LENGTH = new int[] { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 };
|
||||
|
||||
// Token: 0x04000188 RID: 392
|
||||
public static int[] MAX_CHAIN = new int[] { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 };
|
||||
|
||||
// Token: 0x04000189 RID: 393
|
||||
public static int[] COMPR_FUNC = new int[] { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,571 @@
|
||||
using System;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000042 RID: 66
|
||||
public class DeflaterEngine : DeflaterConstants
|
||||
{
|
||||
// Token: 0x0600028E RID: 654 RVA: 0x0000D36C File Offset: 0x0000C36C
|
||||
public DeflaterEngine(DeflaterPending pending)
|
||||
{
|
||||
this.pending = pending;
|
||||
this.huffman = new DeflaterHuffman(pending);
|
||||
this.adler = new Adler32();
|
||||
this.window = new byte[65536];
|
||||
this.head = new short[32768];
|
||||
this.prev = new short[32768];
|
||||
this.blockStart = (this.strstart = 1);
|
||||
}
|
||||
|
||||
// Token: 0x0600028F RID: 655 RVA: 0x0000D3E0 File Offset: 0x0000C3E0
|
||||
public bool Deflate(bool flush, bool finish)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
this.FillWindow();
|
||||
bool flag = flush && this.inputOff == this.inputEnd;
|
||||
bool flag2;
|
||||
switch (this.compressionFunction)
|
||||
{
|
||||
case 0:
|
||||
flag2 = this.DeflateStored(flag, finish);
|
||||
goto IL_62;
|
||||
case 1:
|
||||
flag2 = this.DeflateFast(flag, finish);
|
||||
goto IL_62;
|
||||
case 2:
|
||||
flag2 = this.DeflateSlow(flag, finish);
|
||||
goto IL_62;
|
||||
}
|
||||
break;
|
||||
IL_62:
|
||||
if (!this.pending.IsFlushed || !flag2)
|
||||
{
|
||||
return flag2;
|
||||
}
|
||||
}
|
||||
throw new InvalidOperationException("unknown compressionFunction");
|
||||
}
|
||||
|
||||
// Token: 0x06000290 RID: 656 RVA: 0x0000D460 File Offset: 0x0000C460
|
||||
public void SetInput(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
if (this.inputOff < this.inputEnd)
|
||||
{
|
||||
throw new InvalidOperationException("Old input was not completely processed");
|
||||
}
|
||||
int num = offset + count;
|
||||
if (offset > num || num > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
this.inputBuf = buffer;
|
||||
this.inputOff = offset;
|
||||
this.inputEnd = num;
|
||||
}
|
||||
|
||||
// Token: 0x06000291 RID: 657 RVA: 0x0000D4E0 File Offset: 0x0000C4E0
|
||||
public bool NeedsInput()
|
||||
{
|
||||
return this.inputEnd == this.inputOff;
|
||||
}
|
||||
|
||||
// Token: 0x06000292 RID: 658 RVA: 0x0000D4F0 File Offset: 0x0000C4F0
|
||||
public void SetDictionary(byte[] buffer, int offset, int length)
|
||||
{
|
||||
this.adler.Update(buffer, offset, length);
|
||||
if (length < 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (length > 32506)
|
||||
{
|
||||
offset += length - 32506;
|
||||
length = 32506;
|
||||
}
|
||||
Array.Copy(buffer, offset, this.window, this.strstart, length);
|
||||
this.UpdateHash();
|
||||
length--;
|
||||
while (--length > 0)
|
||||
{
|
||||
this.InsertString();
|
||||
this.strstart++;
|
||||
}
|
||||
this.strstart += 2;
|
||||
this.blockStart = this.strstart;
|
||||
}
|
||||
|
||||
// Token: 0x06000293 RID: 659 RVA: 0x0000D584 File Offset: 0x0000C584
|
||||
public void Reset()
|
||||
{
|
||||
this.huffman.Reset();
|
||||
this.adler.Reset();
|
||||
this.blockStart = (this.strstart = 1);
|
||||
this.lookahead = 0;
|
||||
this.totalIn = 0L;
|
||||
this.prevAvailable = false;
|
||||
this.matchLen = 2;
|
||||
for (int i = 0; i < 32768; i++)
|
||||
{
|
||||
this.head[i] = 0;
|
||||
}
|
||||
for (int j = 0; j < 32768; j++)
|
||||
{
|
||||
this.prev[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000294 RID: 660 RVA: 0x0000D606 File Offset: 0x0000C606
|
||||
public void ResetAdler()
|
||||
{
|
||||
this.adler.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x17000091 RID: 145
|
||||
// (get) Token: 0x06000295 RID: 661 RVA: 0x0000D613 File Offset: 0x0000C613
|
||||
public int Adler
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)this.adler.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000092 RID: 146
|
||||
// (get) Token: 0x06000296 RID: 662 RVA: 0x0000D621 File Offset: 0x0000C621
|
||||
public long TotalIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalIn;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000093 RID: 147
|
||||
// (get) Token: 0x06000297 RID: 663 RVA: 0x0000D629 File Offset: 0x0000C629
|
||||
// (set) Token: 0x06000298 RID: 664 RVA: 0x0000D631 File Offset: 0x0000C631
|
||||
public DeflateStrategy Strategy
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.strategy;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.strategy = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000299 RID: 665 RVA: 0x0000D63C File Offset: 0x0000C63C
|
||||
public void SetLevel(int level)
|
||||
{
|
||||
if (level < 0 || level > 9)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("level");
|
||||
}
|
||||
this.goodLength = DeflaterConstants.GOOD_LENGTH[level];
|
||||
this.max_lazy = DeflaterConstants.MAX_LAZY[level];
|
||||
this.niceLength = DeflaterConstants.NICE_LENGTH[level];
|
||||
this.max_chain = DeflaterConstants.MAX_CHAIN[level];
|
||||
if (DeflaterConstants.COMPR_FUNC[level] != this.compressionFunction)
|
||||
{
|
||||
switch (this.compressionFunction)
|
||||
{
|
||||
case 0:
|
||||
if (this.strstart > this.blockStart)
|
||||
{
|
||||
this.huffman.FlushStoredBlock(this.window, this.blockStart, this.strstart - this.blockStart, false);
|
||||
this.blockStart = this.strstart;
|
||||
}
|
||||
this.UpdateHash();
|
||||
break;
|
||||
case 1:
|
||||
if (this.strstart > this.blockStart)
|
||||
{
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, this.strstart - this.blockStart, false);
|
||||
this.blockStart = this.strstart;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.prevAvailable)
|
||||
{
|
||||
this.huffman.TallyLit((int)(this.window[this.strstart - 1] & byte.MaxValue));
|
||||
}
|
||||
if (this.strstart > this.blockStart)
|
||||
{
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, this.strstart - this.blockStart, false);
|
||||
this.blockStart = this.strstart;
|
||||
}
|
||||
this.prevAvailable = false;
|
||||
this.matchLen = 2;
|
||||
break;
|
||||
}
|
||||
this.compressionFunction = DeflaterConstants.COMPR_FUNC[level];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600029A RID: 666 RVA: 0x0000D7D4 File Offset: 0x0000C7D4
|
||||
public void FillWindow()
|
||||
{
|
||||
if (this.strstart >= 65274)
|
||||
{
|
||||
this.SlideWindow();
|
||||
}
|
||||
while (this.lookahead < 262 && this.inputOff < this.inputEnd)
|
||||
{
|
||||
int num = 65536 - this.lookahead - this.strstart;
|
||||
if (num > this.inputEnd - this.inputOff)
|
||||
{
|
||||
num = this.inputEnd - this.inputOff;
|
||||
}
|
||||
Array.Copy(this.inputBuf, this.inputOff, this.window, this.strstart + this.lookahead, num);
|
||||
this.adler.Update(this.inputBuf, this.inputOff, num);
|
||||
this.inputOff += num;
|
||||
this.totalIn += (long)num;
|
||||
this.lookahead += num;
|
||||
}
|
||||
if (this.lookahead >= 3)
|
||||
{
|
||||
this.UpdateHash();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600029B RID: 667 RVA: 0x0000D8C3 File Offset: 0x0000C8C3
|
||||
private void UpdateHash()
|
||||
{
|
||||
this.ins_h = ((int)this.window[this.strstart] << 5) ^ (int)this.window[this.strstart + 1];
|
||||
}
|
||||
|
||||
// Token: 0x0600029C RID: 668 RVA: 0x0000D8EC File Offset: 0x0000C8EC
|
||||
private int InsertString()
|
||||
{
|
||||
int num = ((this.ins_h << 5) ^ (int)this.window[this.strstart + 2]) & 32767;
|
||||
short num2 = (this.prev[this.strstart & 32767] = this.head[num]);
|
||||
this.head[num] = (short)this.strstart;
|
||||
this.ins_h = num;
|
||||
return (int)num2 & 65535;
|
||||
}
|
||||
|
||||
// Token: 0x0600029D RID: 669 RVA: 0x0000D954 File Offset: 0x0000C954
|
||||
private void SlideWindow()
|
||||
{
|
||||
Array.Copy(this.window, 32768, this.window, 0, 32768);
|
||||
this.matchStart -= 32768;
|
||||
this.strstart -= 32768;
|
||||
this.blockStart -= 32768;
|
||||
for (int i = 0; i < 32768; i++)
|
||||
{
|
||||
int num = (int)this.head[i] & 65535;
|
||||
this.head[i] = (short)((num >= 32768) ? (num - 32768) : 0);
|
||||
}
|
||||
for (int j = 0; j < 32768; j++)
|
||||
{
|
||||
int num2 = (int)this.prev[j] & 65535;
|
||||
this.prev[j] = (short)((num2 >= 32768) ? (num2 - 32768) : 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600029E RID: 670 RVA: 0x0000DA28 File Offset: 0x0000CA28
|
||||
private bool FindLongestMatch(int curMatch)
|
||||
{
|
||||
int num = this.max_chain;
|
||||
int num2 = this.niceLength;
|
||||
short[] array = this.prev;
|
||||
int num3 = this.strstart;
|
||||
int num4 = this.strstart + this.matchLen;
|
||||
int num5 = Math.Max(this.matchLen, 2);
|
||||
int num6 = Math.Max(this.strstart - 32506, 0);
|
||||
int num7 = this.strstart + 258 - 1;
|
||||
byte b = this.window[num4 - 1];
|
||||
byte b2 = this.window[num4];
|
||||
if (num5 >= this.goodLength)
|
||||
{
|
||||
num >>= 2;
|
||||
}
|
||||
if (num2 > this.lookahead)
|
||||
{
|
||||
num2 = this.lookahead;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (this.window[curMatch + num5] == b2 && this.window[curMatch + num5 - 1] == b && this.window[curMatch] == this.window[num3] && this.window[curMatch + 1] == this.window[num3 + 1])
|
||||
{
|
||||
int num8 = curMatch + 2;
|
||||
num3 += 2;
|
||||
while (this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && this.window[++num3] == this.window[++num8] && num3 < num7)
|
||||
{
|
||||
}
|
||||
if (num3 > num4)
|
||||
{
|
||||
this.matchStart = curMatch;
|
||||
num4 = num3;
|
||||
num5 = num3 - this.strstart;
|
||||
if (num5 >= num2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
b = this.window[num4 - 1];
|
||||
b2 = this.window[num4];
|
||||
}
|
||||
num3 = this.strstart;
|
||||
}
|
||||
}
|
||||
while ((curMatch = (int)array[curMatch & 32767] & 65535) > num6 && --num != 0);
|
||||
this.matchLen = Math.Min(num5, this.lookahead);
|
||||
return this.matchLen >= 3;
|
||||
}
|
||||
|
||||
// Token: 0x0600029F RID: 671 RVA: 0x0000DC94 File Offset: 0x0000CC94
|
||||
private bool DeflateStored(bool flush, bool finish)
|
||||
{
|
||||
if (!flush && this.lookahead == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.strstart += this.lookahead;
|
||||
this.lookahead = 0;
|
||||
int num = this.strstart - this.blockStart;
|
||||
if (num >= DeflaterConstants.MAX_BLOCK_SIZE || (this.blockStart < 32768 && num >= 32506) || flush)
|
||||
{
|
||||
bool flag = finish;
|
||||
if (num > DeflaterConstants.MAX_BLOCK_SIZE)
|
||||
{
|
||||
num = DeflaterConstants.MAX_BLOCK_SIZE;
|
||||
flag = false;
|
||||
}
|
||||
this.huffman.FlushStoredBlock(this.window, this.blockStart, num, flag);
|
||||
this.blockStart += num;
|
||||
return !flag;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060002A0 RID: 672 RVA: 0x0000DD38 File Offset: 0x0000CD38
|
||||
private bool DeflateFast(bool flush, bool finish)
|
||||
{
|
||||
if (this.lookahead < 262 && !flush)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
while (this.lookahead >= 262 || flush)
|
||||
{
|
||||
if (this.lookahead == 0)
|
||||
{
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, this.strstart - this.blockStart, finish);
|
||||
this.blockStart = this.strstart;
|
||||
return false;
|
||||
}
|
||||
if (this.strstart > 65274)
|
||||
{
|
||||
this.SlideWindow();
|
||||
}
|
||||
int num;
|
||||
if (this.lookahead >= 3 && (num = this.InsertString()) != 0 && this.strategy != DeflateStrategy.HuffmanOnly && this.strstart - num <= 32506 && this.FindLongestMatch(num))
|
||||
{
|
||||
bool flag = this.huffman.TallyDist(this.strstart - this.matchStart, this.matchLen);
|
||||
this.lookahead -= this.matchLen;
|
||||
if (this.matchLen <= this.max_lazy && this.lookahead >= 3)
|
||||
{
|
||||
while (--this.matchLen > 0)
|
||||
{
|
||||
this.strstart++;
|
||||
this.InsertString();
|
||||
}
|
||||
this.strstart++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.strstart += this.matchLen;
|
||||
if (this.lookahead >= 2)
|
||||
{
|
||||
this.UpdateHash();
|
||||
}
|
||||
}
|
||||
this.matchLen = 2;
|
||||
if (!flag)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.huffman.TallyLit((int)(this.window[this.strstart] & byte.MaxValue));
|
||||
this.strstart++;
|
||||
this.lookahead--;
|
||||
}
|
||||
if (this.huffman.IsFull())
|
||||
{
|
||||
bool flag2 = finish && this.lookahead == 0;
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, this.strstart - this.blockStart, flag2);
|
||||
this.blockStart = this.strstart;
|
||||
return !flag2;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060002A1 RID: 673 RVA: 0x0000DF48 File Offset: 0x0000CF48
|
||||
private bool DeflateSlow(bool flush, bool finish)
|
||||
{
|
||||
if (this.lookahead < 262 && !flush)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
while (this.lookahead >= 262 || flush)
|
||||
{
|
||||
if (this.lookahead == 0)
|
||||
{
|
||||
if (this.prevAvailable)
|
||||
{
|
||||
this.huffman.TallyLit((int)(this.window[this.strstart - 1] & byte.MaxValue));
|
||||
}
|
||||
this.prevAvailable = false;
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, this.strstart - this.blockStart, finish);
|
||||
this.blockStart = this.strstart;
|
||||
return false;
|
||||
}
|
||||
if (this.strstart >= 65274)
|
||||
{
|
||||
this.SlideWindow();
|
||||
}
|
||||
int num = this.matchStart;
|
||||
int num2 = this.matchLen;
|
||||
if (this.lookahead >= 3)
|
||||
{
|
||||
int num3 = this.InsertString();
|
||||
if (this.strategy != DeflateStrategy.HuffmanOnly && num3 != 0 && this.strstart - num3 <= 32506 && this.FindLongestMatch(num3) && this.matchLen <= 5 && (this.strategy == DeflateStrategy.Filtered || (this.matchLen == 3 && this.strstart - this.matchStart > 4096)))
|
||||
{
|
||||
this.matchLen = 2;
|
||||
}
|
||||
}
|
||||
if (num2 >= 3 && this.matchLen <= num2)
|
||||
{
|
||||
this.huffman.TallyDist(this.strstart - 1 - num, num2);
|
||||
num2 -= 2;
|
||||
do
|
||||
{
|
||||
this.strstart++;
|
||||
this.lookahead--;
|
||||
if (this.lookahead >= 3)
|
||||
{
|
||||
this.InsertString();
|
||||
}
|
||||
}
|
||||
while (--num2 > 0);
|
||||
this.strstart++;
|
||||
this.lookahead--;
|
||||
this.prevAvailable = false;
|
||||
this.matchLen = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.prevAvailable)
|
||||
{
|
||||
this.huffman.TallyLit((int)(this.window[this.strstart - 1] & byte.MaxValue));
|
||||
}
|
||||
this.prevAvailable = true;
|
||||
this.strstart++;
|
||||
this.lookahead--;
|
||||
}
|
||||
if (this.huffman.IsFull())
|
||||
{
|
||||
int num4 = this.strstart - this.blockStart;
|
||||
if (this.prevAvailable)
|
||||
{
|
||||
num4--;
|
||||
}
|
||||
bool flag = finish && this.lookahead == 0 && !this.prevAvailable;
|
||||
this.huffman.FlushBlock(this.window, this.blockStart, num4, flag);
|
||||
this.blockStart += num4;
|
||||
return !flag;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0400018E RID: 398
|
||||
private const int TooFar = 4096;
|
||||
|
||||
// Token: 0x0400018F RID: 399
|
||||
private int ins_h;
|
||||
|
||||
// Token: 0x04000190 RID: 400
|
||||
private short[] head;
|
||||
|
||||
// Token: 0x04000191 RID: 401
|
||||
private short[] prev;
|
||||
|
||||
// Token: 0x04000192 RID: 402
|
||||
private int matchStart;
|
||||
|
||||
// Token: 0x04000193 RID: 403
|
||||
private int matchLen;
|
||||
|
||||
// Token: 0x04000194 RID: 404
|
||||
private bool prevAvailable;
|
||||
|
||||
// Token: 0x04000195 RID: 405
|
||||
private int blockStart;
|
||||
|
||||
// Token: 0x04000196 RID: 406
|
||||
private int strstart;
|
||||
|
||||
// Token: 0x04000197 RID: 407
|
||||
private int lookahead;
|
||||
|
||||
// Token: 0x04000198 RID: 408
|
||||
private byte[] window;
|
||||
|
||||
// Token: 0x04000199 RID: 409
|
||||
private DeflateStrategy strategy;
|
||||
|
||||
// Token: 0x0400019A RID: 410
|
||||
private int max_chain;
|
||||
|
||||
// Token: 0x0400019B RID: 411
|
||||
private int max_lazy;
|
||||
|
||||
// Token: 0x0400019C RID: 412
|
||||
private int niceLength;
|
||||
|
||||
// Token: 0x0400019D RID: 413
|
||||
private int goodLength;
|
||||
|
||||
// Token: 0x0400019E RID: 414
|
||||
private int compressionFunction;
|
||||
|
||||
// Token: 0x0400019F RID: 415
|
||||
private byte[] inputBuf;
|
||||
|
||||
// Token: 0x040001A0 RID: 416
|
||||
private long totalIn;
|
||||
|
||||
// Token: 0x040001A1 RID: 417
|
||||
private int inputOff;
|
||||
|
||||
// Token: 0x040001A2 RID: 418
|
||||
private int inputEnd;
|
||||
|
||||
// Token: 0x040001A3 RID: 419
|
||||
private DeflaterPending pending;
|
||||
|
||||
// Token: 0x040001A4 RID: 420
|
||||
private DeflaterHuffman huffman;
|
||||
|
||||
// Token: 0x040001A5 RID: 421
|
||||
private Adler32 adler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,726 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000043 RID: 67
|
||||
public class DeflaterHuffman
|
||||
{
|
||||
// Token: 0x060002A2 RID: 674 RVA: 0x0000E220 File Offset: 0x0000D220
|
||||
static DeflaterHuffman()
|
||||
{
|
||||
int i = 0;
|
||||
while (i < 144)
|
||||
{
|
||||
DeflaterHuffman.staticLCodes[i] = DeflaterHuffman.BitReverse(48 + i << 8);
|
||||
DeflaterHuffman.staticLLength[i++] = 8;
|
||||
}
|
||||
while (i < 256)
|
||||
{
|
||||
DeflaterHuffman.staticLCodes[i] = DeflaterHuffman.BitReverse(256 + i << 7);
|
||||
DeflaterHuffman.staticLLength[i++] = 9;
|
||||
}
|
||||
while (i < 280)
|
||||
{
|
||||
DeflaterHuffman.staticLCodes[i] = DeflaterHuffman.BitReverse(-256 + i << 9);
|
||||
DeflaterHuffman.staticLLength[i++] = 7;
|
||||
}
|
||||
while (i < 286)
|
||||
{
|
||||
DeflaterHuffman.staticLCodes[i] = DeflaterHuffman.BitReverse(-88 + i << 8);
|
||||
DeflaterHuffman.staticLLength[i++] = 8;
|
||||
}
|
||||
DeflaterHuffman.staticDCodes = new short[30];
|
||||
DeflaterHuffman.staticDLength = new byte[30];
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
DeflaterHuffman.staticDCodes[i] = DeflaterHuffman.BitReverse(i << 11);
|
||||
DeflaterHuffman.staticDLength[i] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002A3 RID: 675 RVA: 0x0000E360 File Offset: 0x0000D360
|
||||
public DeflaterHuffman(DeflaterPending pending)
|
||||
{
|
||||
this.pending = pending;
|
||||
this.literalTree = new DeflaterHuffman.Tree(this, 286, 257, 15);
|
||||
this.distTree = new DeflaterHuffman.Tree(this, 30, 1, 15);
|
||||
this.blTree = new DeflaterHuffman.Tree(this, 19, 4, 7);
|
||||
this.d_buf = new short[16384];
|
||||
this.l_buf = new byte[16384];
|
||||
}
|
||||
|
||||
// Token: 0x060002A4 RID: 676 RVA: 0x0000E3D3 File Offset: 0x0000D3D3
|
||||
public void Reset()
|
||||
{
|
||||
this.last_lit = 0;
|
||||
this.extra_bits = 0;
|
||||
this.literalTree.Reset();
|
||||
this.distTree.Reset();
|
||||
this.blTree.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060002A5 RID: 677 RVA: 0x0000E404 File Offset: 0x0000D404
|
||||
public void SendAllTrees(int blTreeCodes)
|
||||
{
|
||||
this.blTree.BuildCodes();
|
||||
this.literalTree.BuildCodes();
|
||||
this.distTree.BuildCodes();
|
||||
this.pending.WriteBits(this.literalTree.numCodes - 257, 5);
|
||||
this.pending.WriteBits(this.distTree.numCodes - 1, 5);
|
||||
this.pending.WriteBits(blTreeCodes - 4, 4);
|
||||
for (int i = 0; i < blTreeCodes; i++)
|
||||
{
|
||||
this.pending.WriteBits((int)this.blTree.length[DeflaterHuffman.BL_ORDER[i]], 3);
|
||||
}
|
||||
this.literalTree.WriteTree(this.blTree);
|
||||
this.distTree.WriteTree(this.blTree);
|
||||
}
|
||||
|
||||
// Token: 0x060002A6 RID: 678 RVA: 0x0000E4C4 File Offset: 0x0000D4C4
|
||||
public void CompressBlock()
|
||||
{
|
||||
for (int i = 0; i < this.last_lit; i++)
|
||||
{
|
||||
int num = (int)(this.l_buf[i] & byte.MaxValue);
|
||||
int num2 = (int)this.d_buf[i];
|
||||
if (num2-- != 0)
|
||||
{
|
||||
int num3 = DeflaterHuffman.Lcode(num);
|
||||
this.literalTree.WriteSymbol(num3);
|
||||
int num4 = (num3 - 261) / 4;
|
||||
if (num4 > 0 && num4 <= 5)
|
||||
{
|
||||
this.pending.WriteBits(num & ((1 << num4) - 1), num4);
|
||||
}
|
||||
int num5 = DeflaterHuffman.Dcode(num2);
|
||||
this.distTree.WriteSymbol(num5);
|
||||
num4 = num5 / 2 - 1;
|
||||
if (num4 > 0)
|
||||
{
|
||||
this.pending.WriteBits(num2 & ((1 << num4) - 1), num4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.literalTree.WriteSymbol(num);
|
||||
}
|
||||
}
|
||||
this.literalTree.WriteSymbol(256);
|
||||
}
|
||||
|
||||
// Token: 0x060002A7 RID: 679 RVA: 0x0000E5A0 File Offset: 0x0000D5A0
|
||||
public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
{
|
||||
this.pending.WriteBits(lastBlock ? 1 : 0, 3);
|
||||
this.pending.AlignToByte();
|
||||
this.pending.WriteShort(storedLength);
|
||||
this.pending.WriteShort(~storedLength);
|
||||
this.pending.WriteBlock(stored, storedOffset, storedLength);
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060002A8 RID: 680 RVA: 0x0000E5FC File Offset: 0x0000D5FC
|
||||
public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
|
||||
{
|
||||
short[] freqs = this.literalTree.freqs;
|
||||
int num = 256;
|
||||
freqs[num] += 1;
|
||||
this.literalTree.BuildTree();
|
||||
this.distTree.BuildTree();
|
||||
this.literalTree.CalcBLFreq(this.blTree);
|
||||
this.distTree.CalcBLFreq(this.blTree);
|
||||
this.blTree.BuildTree();
|
||||
int num2 = 4;
|
||||
for (int i = 18; i > num2; i--)
|
||||
{
|
||||
if (this.blTree.length[DeflaterHuffman.BL_ORDER[i]] > 0)
|
||||
{
|
||||
num2 = i + 1;
|
||||
}
|
||||
}
|
||||
int num3 = 14 + num2 * 3 + this.blTree.GetEncodedLength() + this.literalTree.GetEncodedLength() + this.distTree.GetEncodedLength() + this.extra_bits;
|
||||
int num4 = this.extra_bits;
|
||||
for (int j = 0; j < 286; j++)
|
||||
{
|
||||
num4 += (int)(this.literalTree.freqs[j] * (short)DeflaterHuffman.staticLLength[j]);
|
||||
}
|
||||
for (int k = 0; k < 30; k++)
|
||||
{
|
||||
num4 += (int)(this.distTree.freqs[k] * (short)DeflaterHuffman.staticDLength[k]);
|
||||
}
|
||||
if (num3 >= num4)
|
||||
{
|
||||
num3 = num4;
|
||||
}
|
||||
if (storedOffset >= 0 && storedLength + 4 < num3 >> 3)
|
||||
{
|
||||
this.FlushStoredBlock(stored, storedOffset, storedLength, lastBlock);
|
||||
return;
|
||||
}
|
||||
if (num3 == num4)
|
||||
{
|
||||
this.pending.WriteBits(2 + (lastBlock ? 1 : 0), 3);
|
||||
this.literalTree.SetStaticCodes(DeflaterHuffman.staticLCodes, DeflaterHuffman.staticLLength);
|
||||
this.distTree.SetStaticCodes(DeflaterHuffman.staticDCodes, DeflaterHuffman.staticDLength);
|
||||
this.CompressBlock();
|
||||
this.Reset();
|
||||
return;
|
||||
}
|
||||
this.pending.WriteBits(4 + (lastBlock ? 1 : 0), 3);
|
||||
this.SendAllTrees(num2);
|
||||
this.CompressBlock();
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060002A9 RID: 681 RVA: 0x0000E7C2 File Offset: 0x0000D7C2
|
||||
public bool IsFull()
|
||||
{
|
||||
return this.last_lit >= 16384;
|
||||
}
|
||||
|
||||
// Token: 0x060002AA RID: 682 RVA: 0x0000E7D4 File Offset: 0x0000D7D4
|
||||
public bool TallyLit(int literal)
|
||||
{
|
||||
this.d_buf[this.last_lit] = 0;
|
||||
this.l_buf[this.last_lit++] = (byte)literal;
|
||||
short[] freqs = this.literalTree.freqs;
|
||||
freqs[literal] += 1;
|
||||
return this.IsFull();
|
||||
}
|
||||
|
||||
// Token: 0x060002AB RID: 683 RVA: 0x0000E830 File Offset: 0x0000D830
|
||||
public bool TallyDist(int distance, int length)
|
||||
{
|
||||
this.d_buf[this.last_lit] = (short)distance;
|
||||
this.l_buf[this.last_lit++] = (byte)(length - 3);
|
||||
int num = DeflaterHuffman.Lcode(length - 3);
|
||||
short[] freqs = this.literalTree.freqs;
|
||||
int num2 = num;
|
||||
freqs[num2] += 1;
|
||||
if (num >= 265 && num < 285)
|
||||
{
|
||||
this.extra_bits += (num - 261) / 4;
|
||||
}
|
||||
int num3 = DeflaterHuffman.Dcode(distance - 1);
|
||||
short[] freqs2 = this.distTree.freqs;
|
||||
int num4 = num3;
|
||||
freqs2[num4] += 1;
|
||||
if (num3 >= 4)
|
||||
{
|
||||
this.extra_bits += num3 / 2 - 1;
|
||||
}
|
||||
return this.IsFull();
|
||||
}
|
||||
|
||||
// Token: 0x060002AC RID: 684 RVA: 0x0000E8FA File Offset: 0x0000D8FA
|
||||
public static short BitReverse(int toReverse)
|
||||
{
|
||||
return (short)(((int)DeflaterHuffman.bit4Reverse[toReverse & 15] << 12) | ((int)DeflaterHuffman.bit4Reverse[(toReverse >> 4) & 15] << 8) | ((int)DeflaterHuffman.bit4Reverse[(toReverse >> 8) & 15] << 4) | (int)DeflaterHuffman.bit4Reverse[toReverse >> 12]);
|
||||
}
|
||||
|
||||
// Token: 0x060002AD RID: 685 RVA: 0x0000E934 File Offset: 0x0000D934
|
||||
private static int Lcode(int length)
|
||||
{
|
||||
if (length == 255)
|
||||
{
|
||||
return 285;
|
||||
}
|
||||
int num = 257;
|
||||
while (length >= 8)
|
||||
{
|
||||
num += 4;
|
||||
length >>= 1;
|
||||
}
|
||||
return num + length;
|
||||
}
|
||||
|
||||
// Token: 0x060002AE RID: 686 RVA: 0x0000E968 File Offset: 0x0000D968
|
||||
private static int Dcode(int distance)
|
||||
{
|
||||
int num = 0;
|
||||
while (distance >= 4)
|
||||
{
|
||||
num += 2;
|
||||
distance >>= 1;
|
||||
}
|
||||
return num + distance;
|
||||
}
|
||||
|
||||
// Token: 0x040001A6 RID: 422
|
||||
private const int BUFSIZE = 16384;
|
||||
|
||||
// Token: 0x040001A7 RID: 423
|
||||
private const int LITERAL_NUM = 286;
|
||||
|
||||
// Token: 0x040001A8 RID: 424
|
||||
private const int DIST_NUM = 30;
|
||||
|
||||
// Token: 0x040001A9 RID: 425
|
||||
private const int BITLEN_NUM = 19;
|
||||
|
||||
// Token: 0x040001AA RID: 426
|
||||
private const int REP_3_6 = 16;
|
||||
|
||||
// Token: 0x040001AB RID: 427
|
||||
private const int REP_3_10 = 17;
|
||||
|
||||
// Token: 0x040001AC RID: 428
|
||||
private const int REP_11_138 = 18;
|
||||
|
||||
// Token: 0x040001AD RID: 429
|
||||
private const int EOF_SYMBOL = 256;
|
||||
|
||||
// Token: 0x040001AE RID: 430
|
||||
private static readonly int[] BL_ORDER = new int[]
|
||||
{
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
|
||||
11, 4, 12, 3, 13, 2, 14, 1, 15
|
||||
};
|
||||
|
||||
// Token: 0x040001AF RID: 431
|
||||
private static readonly byte[] bit4Reverse = new byte[]
|
||||
{
|
||||
0, 8, 4, 12, 2, 10, 6, 14, 1, 9,
|
||||
5, 13, 3, 11, 7, 15
|
||||
};
|
||||
|
||||
// Token: 0x040001B0 RID: 432
|
||||
private static short[] staticLCodes = new short[286];
|
||||
|
||||
// Token: 0x040001B1 RID: 433
|
||||
private static byte[] staticLLength = new byte[286];
|
||||
|
||||
// Token: 0x040001B2 RID: 434
|
||||
private static short[] staticDCodes;
|
||||
|
||||
// Token: 0x040001B3 RID: 435
|
||||
private static byte[] staticDLength;
|
||||
|
||||
// Token: 0x040001B4 RID: 436
|
||||
public DeflaterPending pending;
|
||||
|
||||
// Token: 0x040001B5 RID: 437
|
||||
private DeflaterHuffman.Tree literalTree;
|
||||
|
||||
// Token: 0x040001B6 RID: 438
|
||||
private DeflaterHuffman.Tree distTree;
|
||||
|
||||
// Token: 0x040001B7 RID: 439
|
||||
private DeflaterHuffman.Tree blTree;
|
||||
|
||||
// Token: 0x040001B8 RID: 440
|
||||
private short[] d_buf;
|
||||
|
||||
// Token: 0x040001B9 RID: 441
|
||||
private byte[] l_buf;
|
||||
|
||||
// Token: 0x040001BA RID: 442
|
||||
private int last_lit;
|
||||
|
||||
// Token: 0x040001BB RID: 443
|
||||
private int extra_bits;
|
||||
|
||||
// Token: 0x02000044 RID: 68
|
||||
private class Tree
|
||||
{
|
||||
// Token: 0x060002AF RID: 687 RVA: 0x0000E989 File Offset: 0x0000D989
|
||||
public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength)
|
||||
{
|
||||
this.dh = dh;
|
||||
this.minNumCodes = minCodes;
|
||||
this.maxLength = maxLength;
|
||||
this.freqs = new short[elems];
|
||||
this.bl_counts = new int[maxLength];
|
||||
}
|
||||
|
||||
// Token: 0x060002B0 RID: 688 RVA: 0x0000E9C0 File Offset: 0x0000D9C0
|
||||
public void Reset()
|
||||
{
|
||||
for (int i = 0; i < this.freqs.Length; i++)
|
||||
{
|
||||
this.freqs[i] = 0;
|
||||
}
|
||||
this.codes = null;
|
||||
this.length = null;
|
||||
}
|
||||
|
||||
// Token: 0x060002B1 RID: 689 RVA: 0x0000E9F7 File Offset: 0x0000D9F7
|
||||
public void WriteSymbol(int code)
|
||||
{
|
||||
this.dh.pending.WriteBits((int)this.codes[code] & 65535, (int)this.length[code]);
|
||||
}
|
||||
|
||||
// Token: 0x060002B2 RID: 690 RVA: 0x0000EA20 File Offset: 0x0000DA20
|
||||
public void CheckEmpty()
|
||||
{
|
||||
bool flag = true;
|
||||
for (int i = 0; i < this.freqs.Length; i++)
|
||||
{
|
||||
if (this.freqs[i] != 0)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
throw new SharpZipBaseException("!Empty");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002B3 RID: 691 RVA: 0x0000EA5C File Offset: 0x0000DA5C
|
||||
public void SetStaticCodes(short[] staticCodes, byte[] staticLengths)
|
||||
{
|
||||
this.codes = staticCodes;
|
||||
this.length = staticLengths;
|
||||
}
|
||||
|
||||
// Token: 0x060002B4 RID: 692 RVA: 0x0000EA6C File Offset: 0x0000DA6C
|
||||
public void BuildCodes()
|
||||
{
|
||||
int num = this.freqs.Length;
|
||||
int[] array = new int[this.maxLength];
|
||||
int num2 = 0;
|
||||
this.codes = new short[this.freqs.Length];
|
||||
for (int i = 0; i < this.maxLength; i++)
|
||||
{
|
||||
array[i] = num2;
|
||||
num2 += this.bl_counts[i] << 15 - i;
|
||||
}
|
||||
for (int j = 0; j < this.numCodes; j++)
|
||||
{
|
||||
int num3 = (int)this.length[j];
|
||||
if (num3 > 0)
|
||||
{
|
||||
this.codes[j] = DeflaterHuffman.BitReverse(array[num3 - 1]);
|
||||
array[num3 - 1] += 1 << 16 - num3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002B5 RID: 693 RVA: 0x0000EB20 File Offset: 0x0000DB20
|
||||
public void BuildTree()
|
||||
{
|
||||
int num = this.freqs.Length;
|
||||
int[] array = new int[num];
|
||||
int i = 0;
|
||||
int num2 = 0;
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
int num3 = (int)this.freqs[j];
|
||||
if (num3 != 0)
|
||||
{
|
||||
int num4 = i++;
|
||||
int num5;
|
||||
while (num4 > 0 && (int)this.freqs[array[num5 = (num4 - 1) / 2]] > num3)
|
||||
{
|
||||
array[num4] = array[num5];
|
||||
num4 = num5;
|
||||
}
|
||||
array[num4] = j;
|
||||
num2 = j;
|
||||
}
|
||||
}
|
||||
while (i < 2)
|
||||
{
|
||||
int num6 = ((num2 < 2) ? (++num2) : 0);
|
||||
array[i++] = num6;
|
||||
}
|
||||
this.numCodes = Math.Max(num2 + 1, this.minNumCodes);
|
||||
int num7 = i;
|
||||
int[] array2 = new int[4 * i - 2];
|
||||
int[] array3 = new int[2 * i - 1];
|
||||
int num8 = num7;
|
||||
for (int k = 0; k < i; k++)
|
||||
{
|
||||
int num9 = array[k];
|
||||
array2[2 * k] = num9;
|
||||
array2[2 * k + 1] = -1;
|
||||
array3[k] = (int)this.freqs[num9] << 8;
|
||||
array[k] = k;
|
||||
}
|
||||
do
|
||||
{
|
||||
int num10 = array[0];
|
||||
int num11 = array[--i];
|
||||
int num12 = 0;
|
||||
int l;
|
||||
for (l = 1; l < i; l = l * 2 + 1)
|
||||
{
|
||||
if (l + 1 < i && array3[array[l]] > array3[array[l + 1]])
|
||||
{
|
||||
l++;
|
||||
}
|
||||
array[num12] = array[l];
|
||||
num12 = l;
|
||||
}
|
||||
int num13 = array3[num11];
|
||||
while ((l = num12) > 0 && array3[array[num12 = (l - 1) / 2]] > num13)
|
||||
{
|
||||
array[l] = array[num12];
|
||||
}
|
||||
array[l] = num11;
|
||||
int num14 = array[0];
|
||||
num11 = num8++;
|
||||
array2[2 * num11] = num10;
|
||||
array2[2 * num11 + 1] = num14;
|
||||
int num15 = Math.Min(array3[num10] & 255, array3[num14] & 255);
|
||||
num13 = (array3[num11] = array3[num10] + array3[num14] - num15 + 1);
|
||||
num12 = 0;
|
||||
for (l = 1; l < i; l = num12 * 2 + 1)
|
||||
{
|
||||
if (l + 1 < i && array3[array[l]] > array3[array[l + 1]])
|
||||
{
|
||||
l++;
|
||||
}
|
||||
array[num12] = array[l];
|
||||
num12 = l;
|
||||
}
|
||||
while ((l = num12) > 0 && array3[array[num12 = (l - 1) / 2]] > num13)
|
||||
{
|
||||
array[l] = array[num12];
|
||||
}
|
||||
array[l] = num11;
|
||||
}
|
||||
while (i > 1);
|
||||
if (array[0] != array2.Length / 2 - 1)
|
||||
{
|
||||
throw new SharpZipBaseException("Heap invariant violated");
|
||||
}
|
||||
this.BuildLength(array2);
|
||||
}
|
||||
|
||||
// Token: 0x060002B6 RID: 694 RVA: 0x0000ED90 File Offset: 0x0000DD90
|
||||
public int GetEncodedLength()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < this.freqs.Length; i++)
|
||||
{
|
||||
num += (int)(this.freqs[i] * (short)this.length[i]);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x060002B7 RID: 695 RVA: 0x0000EDC8 File Offset: 0x0000DDC8
|
||||
public void CalcBLFreq(DeflaterHuffman.Tree blTree)
|
||||
{
|
||||
int num = -1;
|
||||
int i = 0;
|
||||
while (i < this.numCodes)
|
||||
{
|
||||
int num2 = 1;
|
||||
int num3 = (int)this.length[i];
|
||||
int num4;
|
||||
int num5;
|
||||
if (num3 == 0)
|
||||
{
|
||||
num4 = 138;
|
||||
num5 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
num4 = 6;
|
||||
num5 = 3;
|
||||
if (num != num3)
|
||||
{
|
||||
short[] array = blTree.freqs;
|
||||
int num6 = num3;
|
||||
array[num6] += 1;
|
||||
num2 = 0;
|
||||
}
|
||||
}
|
||||
num = num3;
|
||||
i++;
|
||||
while (i < this.numCodes && num == (int)this.length[i])
|
||||
{
|
||||
i++;
|
||||
if (++num2 >= num4)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num2 < num5)
|
||||
{
|
||||
short[] array2 = blTree.freqs;
|
||||
int num7 = num;
|
||||
array2[num7] += (short)num2;
|
||||
}
|
||||
else if (num != 0)
|
||||
{
|
||||
short[] array3 = blTree.freqs;
|
||||
int num8 = 16;
|
||||
array3[num8] += 1;
|
||||
}
|
||||
else if (num2 <= 10)
|
||||
{
|
||||
short[] array4 = blTree.freqs;
|
||||
int num9 = 17;
|
||||
array4[num9] += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
short[] array5 = blTree.freqs;
|
||||
int num10 = 18;
|
||||
array5[num10] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002B8 RID: 696 RVA: 0x0000EEDC File Offset: 0x0000DEDC
|
||||
public void WriteTree(DeflaterHuffman.Tree blTree)
|
||||
{
|
||||
int num = -1;
|
||||
int i = 0;
|
||||
while (i < this.numCodes)
|
||||
{
|
||||
int num2 = 1;
|
||||
int num3 = (int)this.length[i];
|
||||
int num4;
|
||||
int num5;
|
||||
if (num3 == 0)
|
||||
{
|
||||
num4 = 138;
|
||||
num5 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
num4 = 6;
|
||||
num5 = 3;
|
||||
if (num != num3)
|
||||
{
|
||||
blTree.WriteSymbol(num3);
|
||||
num2 = 0;
|
||||
}
|
||||
}
|
||||
num = num3;
|
||||
i++;
|
||||
while (i < this.numCodes && num == (int)this.length[i])
|
||||
{
|
||||
i++;
|
||||
if (++num2 >= num4)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num2 < num5)
|
||||
{
|
||||
while (num2-- > 0)
|
||||
{
|
||||
blTree.WriteSymbol(num);
|
||||
}
|
||||
}
|
||||
else if (num != 0)
|
||||
{
|
||||
blTree.WriteSymbol(16);
|
||||
this.dh.pending.WriteBits(num2 - 3, 2);
|
||||
}
|
||||
else if (num2 <= 10)
|
||||
{
|
||||
blTree.WriteSymbol(17);
|
||||
this.dh.pending.WriteBits(num2 - 3, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
blTree.WriteSymbol(18);
|
||||
this.dh.pending.WriteBits(num2 - 11, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002B9 RID: 697 RVA: 0x0000EFD8 File Offset: 0x0000DFD8
|
||||
private void BuildLength(int[] childs)
|
||||
{
|
||||
this.length = new byte[this.freqs.Length];
|
||||
int num = childs.Length / 2;
|
||||
int num2 = (num + 1) / 2;
|
||||
int num3 = 0;
|
||||
for (int i = 0; i < this.maxLength; i++)
|
||||
{
|
||||
this.bl_counts[i] = 0;
|
||||
}
|
||||
int[] array = new int[num];
|
||||
array[num - 1] = 0;
|
||||
for (int j = num - 1; j >= 0; j--)
|
||||
{
|
||||
if (childs[2 * j + 1] != -1)
|
||||
{
|
||||
int num4 = array[j] + 1;
|
||||
if (num4 > this.maxLength)
|
||||
{
|
||||
num4 = this.maxLength;
|
||||
num3++;
|
||||
}
|
||||
array[childs[2 * j]] = (array[childs[2 * j + 1]] = num4);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num5 = array[j];
|
||||
this.bl_counts[num5 - 1]++;
|
||||
this.length[childs[2 * j]] = (byte)array[j];
|
||||
}
|
||||
}
|
||||
if (num3 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num6 = this.maxLength - 1;
|
||||
for (;;)
|
||||
{
|
||||
if (this.bl_counts[--num6] != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
this.bl_counts[num6]--;
|
||||
this.bl_counts[++num6]++;
|
||||
num3 -= 1 << this.maxLength - 1 - num6;
|
||||
}
|
||||
while (num3 > 0 && num6 < this.maxLength - 1);
|
||||
if (num3 <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.bl_counts[this.maxLength - 1] += num3;
|
||||
this.bl_counts[this.maxLength - 2] -= num3;
|
||||
int num7 = 2 * num2;
|
||||
for (int num8 = this.maxLength; num8 != 0; num8--)
|
||||
{
|
||||
int k = this.bl_counts[num8 - 1];
|
||||
while (k > 0)
|
||||
{
|
||||
int num9 = 2 * childs[num7++];
|
||||
if (childs[num9 + 1] == -1)
|
||||
{
|
||||
this.length[childs[num9]] = (byte)num8;
|
||||
k--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040001BC RID: 444
|
||||
public short[] freqs;
|
||||
|
||||
// Token: 0x040001BD RID: 445
|
||||
public byte[] length;
|
||||
|
||||
// Token: 0x040001BE RID: 446
|
||||
public int minNumCodes;
|
||||
|
||||
// Token: 0x040001BF RID: 447
|
||||
public int numCodes;
|
||||
|
||||
// Token: 0x040001C0 RID: 448
|
||||
private short[] codes;
|
||||
|
||||
// Token: 0x040001C1 RID: 449
|
||||
private int[] bl_counts;
|
||||
|
||||
// Token: 0x040001C2 RID: 450
|
||||
private int maxLength;
|
||||
|
||||
// Token: 0x040001C3 RID: 451
|
||||
private DeflaterHuffman dh;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000046 RID: 70
|
||||
public class DeflaterPending : PendingBuffer
|
||||
{
|
||||
// Token: 0x060002C8 RID: 712 RVA: 0x0000F595 File Offset: 0x0000E595
|
||||
public DeflaterPending()
|
||||
: base(65536)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,631 @@
|
||||
using System;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000047 RID: 71
|
||||
public class Inflater
|
||||
{
|
||||
// Token: 0x060002C9 RID: 713 RVA: 0x0000F5A2 File Offset: 0x0000E5A2
|
||||
public Inflater()
|
||||
: this(false)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060002CA RID: 714 RVA: 0x0000F5AB File Offset: 0x0000E5AB
|
||||
public Inflater(bool noHeader)
|
||||
{
|
||||
this.noHeader = noHeader;
|
||||
this.adler = new Adler32();
|
||||
this.input = new StreamManipulator();
|
||||
this.outputWindow = new OutputWindow();
|
||||
this.mode = (noHeader ? 2 : 0);
|
||||
}
|
||||
|
||||
// Token: 0x060002CB RID: 715 RVA: 0x0000F5E8 File Offset: 0x0000E5E8
|
||||
public void Reset()
|
||||
{
|
||||
this.mode = (this.noHeader ? 2 : 0);
|
||||
this.totalIn = 0L;
|
||||
this.totalOut = 0L;
|
||||
this.input.Reset();
|
||||
this.outputWindow.Reset();
|
||||
this.dynHeader = null;
|
||||
this.litlenTree = null;
|
||||
this.distTree = null;
|
||||
this.isLastBlock = false;
|
||||
this.adler.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060002CC RID: 716 RVA: 0x0000F654 File Offset: 0x0000E654
|
||||
private bool DecodeHeader()
|
||||
{
|
||||
int num = this.input.PeekBits(16);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(16);
|
||||
num = ((num << 8) | (num >> 8)) & 65535;
|
||||
if (num % 31 != 0)
|
||||
{
|
||||
throw new SharpZipBaseException("Header checksum illegal");
|
||||
}
|
||||
if ((num & 3840) != 2048)
|
||||
{
|
||||
throw new SharpZipBaseException("Compression Method unknown");
|
||||
}
|
||||
if ((num & 32) == 0)
|
||||
{
|
||||
this.mode = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mode = 1;
|
||||
this.neededBits = 32;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060002CD RID: 717 RVA: 0x0000F6DC File Offset: 0x0000E6DC
|
||||
private bool DecodeDict()
|
||||
{
|
||||
while (this.neededBits > 0)
|
||||
{
|
||||
int num = this.input.PeekBits(8);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(8);
|
||||
this.readAdler = (this.readAdler << 8) | num;
|
||||
this.neededBits -= 8;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060002CE RID: 718 RVA: 0x0000F734 File Offset: 0x0000E734
|
||||
private bool DecodeHuffman()
|
||||
{
|
||||
int i = this.outputWindow.GetFreeSpace();
|
||||
while (i >= 258)
|
||||
{
|
||||
int num;
|
||||
switch (this.mode)
|
||||
{
|
||||
case 7:
|
||||
while (((num = this.litlenTree.GetSymbol(this.input)) & -256) == 0)
|
||||
{
|
||||
this.outputWindow.Write(num);
|
||||
if (--i < 258)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (num >= 257)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.repLength = Inflater.CPLENS[num - 257];
|
||||
this.neededBits = Inflater.CPLEXT[num - 257];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new SharpZipBaseException("Illegal rep length code");
|
||||
}
|
||||
goto IL_C5;
|
||||
}
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.distTree = null;
|
||||
this.litlenTree = null;
|
||||
this.mode = 2;
|
||||
return true;
|
||||
case 8:
|
||||
goto IL_C5;
|
||||
case 9:
|
||||
goto IL_114;
|
||||
case 10:
|
||||
break;
|
||||
default:
|
||||
throw new SharpZipBaseException("Inflater unknown mode");
|
||||
}
|
||||
IL_154:
|
||||
if (this.neededBits > 0)
|
||||
{
|
||||
this.mode = 10;
|
||||
int num2 = this.input.PeekBits(this.neededBits);
|
||||
if (num2 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(this.neededBits);
|
||||
this.repDist += num2;
|
||||
}
|
||||
this.outputWindow.Repeat(this.repLength, this.repDist);
|
||||
i -= this.repLength;
|
||||
this.mode = 7;
|
||||
continue;
|
||||
IL_114:
|
||||
num = this.distTree.GetSymbol(this.input);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.repDist = Inflater.CPDIST[num];
|
||||
this.neededBits = Inflater.CPDEXT[num];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new SharpZipBaseException("Illegal rep dist code");
|
||||
}
|
||||
goto IL_154;
|
||||
IL_C5:
|
||||
if (this.neededBits > 0)
|
||||
{
|
||||
this.mode = 8;
|
||||
int num3 = this.input.PeekBits(this.neededBits);
|
||||
if (num3 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(this.neededBits);
|
||||
this.repLength += num3;
|
||||
}
|
||||
this.mode = 9;
|
||||
goto IL_114;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060002CF RID: 719 RVA: 0x0000F93C File Offset: 0x0000E93C
|
||||
private bool DecodeChksum()
|
||||
{
|
||||
while (this.neededBits > 0)
|
||||
{
|
||||
int num = this.input.PeekBits(8);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(8);
|
||||
this.readAdler = (this.readAdler << 8) | num;
|
||||
this.neededBits -= 8;
|
||||
}
|
||||
if ((int)this.adler.Value != this.readAdler)
|
||||
{
|
||||
throw new SharpZipBaseException(string.Concat(new object[]
|
||||
{
|
||||
"Adler chksum doesn't match: ",
|
||||
(int)this.adler.Value,
|
||||
" vs. ",
|
||||
this.readAdler
|
||||
}));
|
||||
}
|
||||
this.mode = 12;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060002D0 RID: 720 RVA: 0x0000F9F4 File Offset: 0x0000E9F4
|
||||
private bool Decode()
|
||||
{
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
return this.DecodeHeader();
|
||||
case 1:
|
||||
return this.DecodeDict();
|
||||
case 2:
|
||||
if (this.isLastBlock)
|
||||
{
|
||||
if (this.noHeader)
|
||||
{
|
||||
this.mode = 12;
|
||||
return false;
|
||||
}
|
||||
this.input.SkipToByteBoundary();
|
||||
this.neededBits = 32;
|
||||
this.mode = 11;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = this.input.PeekBits(3);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(3);
|
||||
if ((num & 1) != 0)
|
||||
{
|
||||
this.isLastBlock = true;
|
||||
}
|
||||
switch (num >> 1)
|
||||
{
|
||||
case 0:
|
||||
this.input.SkipToByteBoundary();
|
||||
this.mode = 3;
|
||||
break;
|
||||
case 1:
|
||||
this.litlenTree = InflaterHuffmanTree.defLitLenTree;
|
||||
this.distTree = InflaterHuffmanTree.defDistTree;
|
||||
this.mode = 7;
|
||||
break;
|
||||
case 2:
|
||||
this.dynHeader = new InflaterDynHeader();
|
||||
this.mode = 6;
|
||||
break;
|
||||
default:
|
||||
throw new SharpZipBaseException("Unknown block type " + num);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ((this.uncomprLen = this.input.PeekBits(16)) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(16);
|
||||
this.mode = 4;
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
goto IL_1A9;
|
||||
case 6:
|
||||
if (!this.dynHeader.Decode(this.input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.litlenTree = this.dynHeader.BuildLitLenTree();
|
||||
this.distTree = this.dynHeader.BuildDistTree();
|
||||
this.mode = 7;
|
||||
goto IL_22D;
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
goto IL_22D;
|
||||
case 11:
|
||||
return this.DecodeChksum();
|
||||
case 12:
|
||||
return false;
|
||||
default:
|
||||
throw new SharpZipBaseException("Inflater.Decode unknown mode");
|
||||
}
|
||||
int num2 = this.input.PeekBits(16);
|
||||
if (num2 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.input.DropBits(16);
|
||||
if (num2 != (this.uncomprLen ^ 65535))
|
||||
{
|
||||
throw new SharpZipBaseException("broken uncompressed block");
|
||||
}
|
||||
this.mode = 5;
|
||||
IL_1A9:
|
||||
int num3 = this.outputWindow.CopyStored(this.input, this.uncomprLen);
|
||||
this.uncomprLen -= num3;
|
||||
if (this.uncomprLen == 0)
|
||||
{
|
||||
this.mode = 2;
|
||||
return true;
|
||||
}
|
||||
return !this.input.IsNeedingInput;
|
||||
IL_22D:
|
||||
return this.DecodeHuffman();
|
||||
}
|
||||
|
||||
// Token: 0x060002D1 RID: 721 RVA: 0x0000FC41 File Offset: 0x0000EC41
|
||||
public void SetDictionary(byte[] buffer)
|
||||
{
|
||||
this.SetDictionary(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060002D2 RID: 722 RVA: 0x0000FC50 File Offset: 0x0000EC50
|
||||
public void SetDictionary(byte[] buffer, int index, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
if (!this.IsNeedingDictionary)
|
||||
{
|
||||
throw new InvalidOperationException("Dictionary is not needed");
|
||||
}
|
||||
this.adler.Update(buffer, index, count);
|
||||
if ((int)this.adler.Value != this.readAdler)
|
||||
{
|
||||
throw new SharpZipBaseException("Wrong adler checksum");
|
||||
}
|
||||
this.adler.Reset();
|
||||
this.outputWindow.CopyDict(buffer, index, count);
|
||||
this.mode = 2;
|
||||
}
|
||||
|
||||
// Token: 0x060002D3 RID: 723 RVA: 0x0000FCE9 File Offset: 0x0000ECE9
|
||||
public void SetInput(byte[] buffer)
|
||||
{
|
||||
this.SetInput(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060002D4 RID: 724 RVA: 0x0000FCF6 File Offset: 0x0000ECF6
|
||||
public void SetInput(byte[] buffer, int index, int count)
|
||||
{
|
||||
this.input.SetInput(buffer, index, count);
|
||||
this.totalIn += (long)count;
|
||||
}
|
||||
|
||||
// Token: 0x060002D5 RID: 725 RVA: 0x0000FD15 File Offset: 0x0000ED15
|
||||
public int Inflate(byte[] buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
return this.Inflate(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060002D6 RID: 726 RVA: 0x0000FD30 File Offset: 0x0000ED30
|
||||
public int Inflate(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count", "count cannot be negative");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset", "offset cannot be negative");
|
||||
}
|
||||
if (offset + count > buffer.Length)
|
||||
{
|
||||
throw new ArgumentException("count exceeds buffer bounds");
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
if (!this.IsFinished)
|
||||
{
|
||||
this.Decode();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int num = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (this.mode != 11)
|
||||
{
|
||||
int num2 = this.outputWindow.CopyOutput(buffer, offset, count);
|
||||
if (num2 > 0)
|
||||
{
|
||||
this.adler.Update(buffer, offset, num2);
|
||||
offset += num2;
|
||||
num += num2;
|
||||
this.totalOut += (long)num2;
|
||||
count -= num2;
|
||||
if (count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.Decode() && (this.outputWindow.GetAvailable() <= 0 || this.mode == 11))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x17000096 RID: 150
|
||||
// (get) Token: 0x060002D7 RID: 727 RVA: 0x0000FE0A File Offset: 0x0000EE0A
|
||||
public bool IsNeedingInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.input.IsNeedingInput;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000097 RID: 151
|
||||
// (get) Token: 0x060002D8 RID: 728 RVA: 0x0000FE17 File Offset: 0x0000EE17
|
||||
public bool IsNeedingDictionary
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mode == 1 && this.neededBits == 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000098 RID: 152
|
||||
// (get) Token: 0x060002D9 RID: 729 RVA: 0x0000FE2D File Offset: 0x0000EE2D
|
||||
public bool IsFinished
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mode == 12 && this.outputWindow.GetAvailable() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000099 RID: 153
|
||||
// (get) Token: 0x060002DA RID: 730 RVA: 0x0000FE49 File Offset: 0x0000EE49
|
||||
public int Adler
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.IsNeedingDictionary)
|
||||
{
|
||||
return (int)this.adler.Value;
|
||||
}
|
||||
return this.readAdler;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700009A RID: 154
|
||||
// (get) Token: 0x060002DB RID: 731 RVA: 0x0000FE66 File Offset: 0x0000EE66
|
||||
public long TotalOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalOut;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700009B RID: 155
|
||||
// (get) Token: 0x060002DC RID: 732 RVA: 0x0000FE6E File Offset: 0x0000EE6E
|
||||
public long TotalIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalIn - (long)this.RemainingInput;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700009C RID: 156
|
||||
// (get) Token: 0x060002DD RID: 733 RVA: 0x0000FE7E File Offset: 0x0000EE7E
|
||||
public int RemainingInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.input.AvailableBytes;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040001C9 RID: 457
|
||||
private const int DECODE_HEADER = 0;
|
||||
|
||||
// Token: 0x040001CA RID: 458
|
||||
private const int DECODE_DICT = 1;
|
||||
|
||||
// Token: 0x040001CB RID: 459
|
||||
private const int DECODE_BLOCKS = 2;
|
||||
|
||||
// Token: 0x040001CC RID: 460
|
||||
private const int DECODE_STORED_LEN1 = 3;
|
||||
|
||||
// Token: 0x040001CD RID: 461
|
||||
private const int DECODE_STORED_LEN2 = 4;
|
||||
|
||||
// Token: 0x040001CE RID: 462
|
||||
private const int DECODE_STORED = 5;
|
||||
|
||||
// Token: 0x040001CF RID: 463
|
||||
private const int DECODE_DYN_HEADER = 6;
|
||||
|
||||
// Token: 0x040001D0 RID: 464
|
||||
private const int DECODE_HUFFMAN = 7;
|
||||
|
||||
// Token: 0x040001D1 RID: 465
|
||||
private const int DECODE_HUFFMAN_LENBITS = 8;
|
||||
|
||||
// Token: 0x040001D2 RID: 466
|
||||
private const int DECODE_HUFFMAN_DIST = 9;
|
||||
|
||||
// Token: 0x040001D3 RID: 467
|
||||
private const int DECODE_HUFFMAN_DISTBITS = 10;
|
||||
|
||||
// Token: 0x040001D4 RID: 468
|
||||
private const int DECODE_CHKSUM = 11;
|
||||
|
||||
// Token: 0x040001D5 RID: 469
|
||||
private const int FINISHED = 12;
|
||||
|
||||
// Token: 0x040001D6 RID: 470
|
||||
private static readonly int[] CPLENS = new int[]
|
||||
{
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13,
|
||||
15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
|
||||
67, 83, 99, 115, 131, 163, 195, 227, 258
|
||||
};
|
||||
|
||||
// Token: 0x040001D7 RID: 471
|
||||
private static readonly int[] CPLEXT = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||
1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
// Token: 0x040001D8 RID: 472
|
||||
private static readonly int[] CPDIST = new int[]
|
||||
{
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25,
|
||||
33, 49, 65, 97, 129, 193, 257, 385, 513, 769,
|
||||
1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
// Token: 0x040001D9 RID: 473
|
||||
private static readonly int[] CPDEXT = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3,
|
||||
4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
|
||||
9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
||||
};
|
||||
|
||||
// Token: 0x040001DA RID: 474
|
||||
private int mode;
|
||||
|
||||
// Token: 0x040001DB RID: 475
|
||||
private int readAdler;
|
||||
|
||||
// Token: 0x040001DC RID: 476
|
||||
private int neededBits;
|
||||
|
||||
// Token: 0x040001DD RID: 477
|
||||
private int repLength;
|
||||
|
||||
// Token: 0x040001DE RID: 478
|
||||
private int repDist;
|
||||
|
||||
// Token: 0x040001DF RID: 479
|
||||
private int uncomprLen;
|
||||
|
||||
// Token: 0x040001E0 RID: 480
|
||||
private bool isLastBlock;
|
||||
|
||||
// Token: 0x040001E1 RID: 481
|
||||
private long totalOut;
|
||||
|
||||
// Token: 0x040001E2 RID: 482
|
||||
private long totalIn;
|
||||
|
||||
// Token: 0x040001E3 RID: 483
|
||||
private bool noHeader;
|
||||
|
||||
// Token: 0x040001E4 RID: 484
|
||||
private StreamManipulator input;
|
||||
|
||||
// Token: 0x040001E5 RID: 485
|
||||
private OutputWindow outputWindow;
|
||||
|
||||
// Token: 0x040001E6 RID: 486
|
||||
private InflaterDynHeader dynHeader;
|
||||
|
||||
// Token: 0x040001E7 RID: 487
|
||||
private InflaterHuffmanTree litlenTree;
|
||||
|
||||
// Token: 0x040001E8 RID: 488
|
||||
private InflaterHuffmanTree distTree;
|
||||
|
||||
// Token: 0x040001E9 RID: 489
|
||||
private Adler32 adler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000048 RID: 72
|
||||
internal class InflaterDynHeader
|
||||
{
|
||||
// Token: 0x060002E0 RID: 736 RVA: 0x000100E4 File Offset: 0x0000F0E4
|
||||
public bool Decode(StreamManipulator input)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
this.lnum = input.PeekBits(5);
|
||||
if (this.lnum < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.lnum += 257;
|
||||
input.DropBits(5);
|
||||
this.mode = 1;
|
||||
goto IL_61;
|
||||
case 1:
|
||||
goto IL_61;
|
||||
case 2:
|
||||
goto IL_B9;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
goto IL_1A8;
|
||||
case 5:
|
||||
goto IL_1EE;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
IL_13B:
|
||||
while (this.ptr < this.blnum)
|
||||
{
|
||||
int num = input.PeekBits(3);
|
||||
if (num < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
input.DropBits(3);
|
||||
this.blLens[InflaterDynHeader.BL_ORDER[this.ptr]] = (byte)num;
|
||||
this.ptr++;
|
||||
}
|
||||
this.blTree = new InflaterHuffmanTree(this.blLens);
|
||||
this.blLens = null;
|
||||
this.ptr = 0;
|
||||
this.mode = 4;
|
||||
IL_1A8:
|
||||
int symbol;
|
||||
while (((symbol = this.blTree.GetSymbol(input)) & -16) == 0)
|
||||
{
|
||||
this.litdistLens[this.ptr++] = (this.lastLen = (byte)symbol);
|
||||
if (this.ptr == this.num)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (symbol < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (symbol >= 17)
|
||||
{
|
||||
this.lastLen = 0;
|
||||
}
|
||||
else if (this.ptr == 0)
|
||||
{
|
||||
goto Block_10;
|
||||
}
|
||||
this.repSymbol = symbol - 16;
|
||||
this.mode = 5;
|
||||
IL_1EE:
|
||||
int num2 = InflaterDynHeader.repBits[this.repSymbol];
|
||||
int num3 = input.PeekBits(num2);
|
||||
if (num3 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
input.DropBits(num2);
|
||||
num3 += InflaterDynHeader.repMin[this.repSymbol];
|
||||
if (this.ptr + num3 > this.num)
|
||||
{
|
||||
goto Block_12;
|
||||
}
|
||||
while (num3-- > 0)
|
||||
{
|
||||
this.litdistLens[this.ptr++] = this.lastLen;
|
||||
}
|
||||
if (this.ptr == this.num)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
this.mode = 4;
|
||||
continue;
|
||||
IL_B9:
|
||||
this.blnum = input.PeekBits(4);
|
||||
if (this.blnum < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.blnum += 4;
|
||||
input.DropBits(4);
|
||||
this.blLens = new byte[19];
|
||||
this.ptr = 0;
|
||||
this.mode = 3;
|
||||
goto IL_13B;
|
||||
IL_61:
|
||||
this.dnum = input.PeekBits(5);
|
||||
if (this.dnum < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.dnum++;
|
||||
input.DropBits(5);
|
||||
this.num = this.lnum + this.dnum;
|
||||
this.litdistLens = new byte[this.num];
|
||||
this.mode = 2;
|
||||
goto IL_B9;
|
||||
}
|
||||
return false;
|
||||
Block_10:
|
||||
throw new SharpZipBaseException();
|
||||
Block_12:
|
||||
throw new SharpZipBaseException();
|
||||
}
|
||||
|
||||
// Token: 0x060002E1 RID: 737 RVA: 0x0001036C File Offset: 0x0000F36C
|
||||
public InflaterHuffmanTree BuildLitLenTree()
|
||||
{
|
||||
byte[] array = new byte[this.lnum];
|
||||
Array.Copy(this.litdistLens, 0, array, 0, this.lnum);
|
||||
return new InflaterHuffmanTree(array);
|
||||
}
|
||||
|
||||
// Token: 0x060002E2 RID: 738 RVA: 0x000103A0 File Offset: 0x0000F3A0
|
||||
public InflaterHuffmanTree BuildDistTree()
|
||||
{
|
||||
byte[] array = new byte[this.dnum];
|
||||
Array.Copy(this.litdistLens, this.lnum, array, 0, this.dnum);
|
||||
return new InflaterHuffmanTree(array);
|
||||
}
|
||||
|
||||
// Token: 0x040001EA RID: 490
|
||||
private const int LNUM = 0;
|
||||
|
||||
// Token: 0x040001EB RID: 491
|
||||
private const int DNUM = 1;
|
||||
|
||||
// Token: 0x040001EC RID: 492
|
||||
private const int BLNUM = 2;
|
||||
|
||||
// Token: 0x040001ED RID: 493
|
||||
private const int BLLENS = 3;
|
||||
|
||||
// Token: 0x040001EE RID: 494
|
||||
private const int LENS = 4;
|
||||
|
||||
// Token: 0x040001EF RID: 495
|
||||
private const int REPS = 5;
|
||||
|
||||
// Token: 0x040001F0 RID: 496
|
||||
private static readonly int[] repMin = new int[] { 3, 3, 11 };
|
||||
|
||||
// Token: 0x040001F1 RID: 497
|
||||
private static readonly int[] repBits = new int[] { 2, 3, 7 };
|
||||
|
||||
// Token: 0x040001F2 RID: 498
|
||||
private static readonly int[] BL_ORDER = new int[]
|
||||
{
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
|
||||
11, 4, 12, 3, 13, 2, 14, 1, 15
|
||||
};
|
||||
|
||||
// Token: 0x040001F3 RID: 499
|
||||
private byte[] blLens;
|
||||
|
||||
// Token: 0x040001F4 RID: 500
|
||||
private byte[] litdistLens;
|
||||
|
||||
// Token: 0x040001F5 RID: 501
|
||||
private InflaterHuffmanTree blTree;
|
||||
|
||||
// Token: 0x040001F6 RID: 502
|
||||
private int mode;
|
||||
|
||||
// Token: 0x040001F7 RID: 503
|
||||
private int lnum;
|
||||
|
||||
// Token: 0x040001F8 RID: 504
|
||||
private int dnum;
|
||||
|
||||
// Token: 0x040001F9 RID: 505
|
||||
private int blnum;
|
||||
|
||||
// Token: 0x040001FA RID: 506
|
||||
private int num;
|
||||
|
||||
// Token: 0x040001FB RID: 507
|
||||
private int repSymbol;
|
||||
|
||||
// Token: 0x040001FC RID: 508
|
||||
private byte lastLen;
|
||||
|
||||
// Token: 0x040001FD RID: 509
|
||||
private int ptr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000049 RID: 73
|
||||
public class InflaterHuffmanTree
|
||||
{
|
||||
// Token: 0x060002E4 RID: 740 RVA: 0x00010494 File Offset: 0x0000F494
|
||||
static InflaterHuffmanTree()
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] array = new byte[288];
|
||||
int i = 0;
|
||||
while (i < 144)
|
||||
{
|
||||
array[i++] = 8;
|
||||
}
|
||||
while (i < 256)
|
||||
{
|
||||
array[i++] = 9;
|
||||
}
|
||||
while (i < 280)
|
||||
{
|
||||
array[i++] = 7;
|
||||
}
|
||||
while (i < 288)
|
||||
{
|
||||
array[i++] = 8;
|
||||
}
|
||||
InflaterHuffmanTree.defLitLenTree = new InflaterHuffmanTree(array);
|
||||
array = new byte[32];
|
||||
i = 0;
|
||||
while (i < 32)
|
||||
{
|
||||
array[i++] = 5;
|
||||
}
|
||||
InflaterHuffmanTree.defDistTree = new InflaterHuffmanTree(array);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new SharpZipBaseException("InflaterHuffmanTree: static tree length illegal");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002E5 RID: 741 RVA: 0x00010544 File Offset: 0x0000F544
|
||||
public InflaterHuffmanTree(byte[] codeLengths)
|
||||
{
|
||||
this.BuildTree(codeLengths);
|
||||
}
|
||||
|
||||
// Token: 0x060002E6 RID: 742 RVA: 0x00010554 File Offset: 0x0000F554
|
||||
private void BuildTree(byte[] codeLengths)
|
||||
{
|
||||
int[] array = new int[16];
|
||||
int[] array2 = new int[16];
|
||||
foreach (int num in codeLengths)
|
||||
{
|
||||
if (num > 0)
|
||||
{
|
||||
array[num]++;
|
||||
}
|
||||
}
|
||||
int num2 = 0;
|
||||
int num3 = 512;
|
||||
for (int j = 1; j <= 15; j++)
|
||||
{
|
||||
array2[j] = num2;
|
||||
num2 += array[j] << 16 - j;
|
||||
if (j >= 10)
|
||||
{
|
||||
int num4 = array2[j] & 130944;
|
||||
int num5 = num2 & 130944;
|
||||
num3 += num5 - num4 >> 16 - j;
|
||||
}
|
||||
}
|
||||
this.tree = new short[num3];
|
||||
int num6 = 512;
|
||||
for (int k = 15; k >= 10; k--)
|
||||
{
|
||||
int num7 = num2 & 130944;
|
||||
num2 -= array[k] << 16 - k;
|
||||
int num8 = num2 & 130944;
|
||||
for (int l = num8; l < num7; l += 128)
|
||||
{
|
||||
this.tree[(int)DeflaterHuffman.BitReverse(l)] = (short)((-num6 << 4) | k);
|
||||
num6 += 1 << k - 9;
|
||||
}
|
||||
}
|
||||
for (int m = 0; m < codeLengths.Length; m++)
|
||||
{
|
||||
int num9 = (int)codeLengths[m];
|
||||
if (num9 != 0)
|
||||
{
|
||||
num2 = array2[num9];
|
||||
int num10 = (int)DeflaterHuffman.BitReverse(num2);
|
||||
if (num9 <= 9)
|
||||
{
|
||||
do
|
||||
{
|
||||
this.tree[num10] = (short)((m << 4) | num9);
|
||||
num10 += 1 << num9;
|
||||
}
|
||||
while (num10 < 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num11 = (int)this.tree[num10 & 511];
|
||||
int num12 = 1 << (num11 & 15);
|
||||
num11 = -(num11 >> 4);
|
||||
do
|
||||
{
|
||||
this.tree[num11 | (num10 >> 9)] = (short)((m << 4) | num9);
|
||||
num10 += 1 << num9;
|
||||
}
|
||||
while (num10 < num12);
|
||||
}
|
||||
array2[num9] = num2 + (1 << 16 - num9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002E7 RID: 743 RVA: 0x00010748 File Offset: 0x0000F748
|
||||
public int GetSymbol(StreamManipulator input)
|
||||
{
|
||||
int num;
|
||||
if ((num = input.PeekBits(9)) >= 0)
|
||||
{
|
||||
int num2;
|
||||
if ((num2 = (int)this.tree[num]) >= 0)
|
||||
{
|
||||
input.DropBits(num2 & 15);
|
||||
return num2 >> 4;
|
||||
}
|
||||
int num3 = -(num2 >> 4);
|
||||
int num4 = num2 & 15;
|
||||
if ((num = input.PeekBits(num4)) >= 0)
|
||||
{
|
||||
num2 = (int)this.tree[num3 | (num >> 9)];
|
||||
input.DropBits(num2 & 15);
|
||||
return num2 >> 4;
|
||||
}
|
||||
int availableBits = input.AvailableBits;
|
||||
num = input.PeekBits(availableBits);
|
||||
num2 = (int)this.tree[num3 | (num >> 9)];
|
||||
if ((num2 & 15) <= availableBits)
|
||||
{
|
||||
input.DropBits(num2 & 15);
|
||||
return num2 >> 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int availableBits2 = input.AvailableBits;
|
||||
num = input.PeekBits(availableBits2);
|
||||
int num2 = (int)this.tree[num];
|
||||
if (num2 >= 0 && (num2 & 15) <= availableBits2)
|
||||
{
|
||||
input.DropBits(num2 & 15);
|
||||
return num2 >> 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040001FE RID: 510
|
||||
private const int MAX_BITLEN = 15;
|
||||
|
||||
// Token: 0x040001FF RID: 511
|
||||
private short[] tree;
|
||||
|
||||
// Token: 0x04000200 RID: 512
|
||||
public static InflaterHuffmanTree defLitLenTree;
|
||||
|
||||
// Token: 0x04000201 RID: 513
|
||||
public static InflaterHuffmanTree defDistTree;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression
|
||||
{
|
||||
// Token: 0x02000045 RID: 69
|
||||
public class PendingBuffer
|
||||
{
|
||||
// Token: 0x060002BA RID: 698 RVA: 0x0000F1D9 File Offset: 0x0000E1D9
|
||||
public PendingBuffer()
|
||||
: this(4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060002BB RID: 699 RVA: 0x0000F1E6 File Offset: 0x0000E1E6
|
||||
public PendingBuffer(int bufferSize)
|
||||
{
|
||||
this.buffer_ = new byte[bufferSize];
|
||||
}
|
||||
|
||||
// Token: 0x060002BC RID: 700 RVA: 0x0000F1FC File Offset: 0x0000E1FC
|
||||
public void Reset()
|
||||
{
|
||||
this.start = (this.end = (this.bitCount = 0));
|
||||
}
|
||||
|
||||
// Token: 0x060002BD RID: 701 RVA: 0x0000F224 File Offset: 0x0000E224
|
||||
public void WriteByte(int value)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)value;
|
||||
}
|
||||
|
||||
// Token: 0x060002BE RID: 702 RVA: 0x0000F24C File Offset: 0x0000E24C
|
||||
public void WriteShort(int value)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)value;
|
||||
this.buffer_[this.end++] = (byte)(value >> 8);
|
||||
}
|
||||
|
||||
// Token: 0x060002BF RID: 703 RVA: 0x0000F290 File Offset: 0x0000E290
|
||||
public void WriteInt(int value)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)value;
|
||||
this.buffer_[this.end++] = (byte)(value >> 8);
|
||||
this.buffer_[this.end++] = (byte)(value >> 16);
|
||||
this.buffer_[this.end++] = (byte)(value >> 24);
|
||||
}
|
||||
|
||||
// Token: 0x060002C0 RID: 704 RVA: 0x0000F30D File Offset: 0x0000E30D
|
||||
public void WriteBlock(byte[] block, int offset, int length)
|
||||
{
|
||||
Array.Copy(block, offset, this.buffer_, this.end, length);
|
||||
this.end += length;
|
||||
}
|
||||
|
||||
// Token: 0x17000094 RID: 148
|
||||
// (get) Token: 0x060002C1 RID: 705 RVA: 0x0000F331 File Offset: 0x0000E331
|
||||
public int BitCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.bitCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002C2 RID: 706 RVA: 0x0000F33C File Offset: 0x0000E33C
|
||||
public void AlignToByte()
|
||||
{
|
||||
if (this.bitCount > 0)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)this.bits;
|
||||
if (this.bitCount > 8)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)(this.bits >> 8);
|
||||
}
|
||||
}
|
||||
this.bits = 0U;
|
||||
this.bitCount = 0;
|
||||
}
|
||||
|
||||
// Token: 0x060002C3 RID: 707 RVA: 0x0000F3AC File Offset: 0x0000E3AC
|
||||
public void WriteBits(int b, int count)
|
||||
{
|
||||
this.bits |= (uint)((uint)b << this.bitCount);
|
||||
this.bitCount += count;
|
||||
if (this.bitCount >= 16)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)this.bits;
|
||||
this.buffer_[this.end++] = (byte)(this.bits >> 8);
|
||||
this.bits >>= 16;
|
||||
this.bitCount -= 16;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002C4 RID: 708 RVA: 0x0000F448 File Offset: 0x0000E448
|
||||
public void WriteShortMSB(int s)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)(s >> 8);
|
||||
this.buffer_[this.end++] = (byte)s;
|
||||
}
|
||||
|
||||
// Token: 0x17000095 RID: 149
|
||||
// (get) Token: 0x060002C5 RID: 709 RVA: 0x0000F48B File Offset: 0x0000E48B
|
||||
public bool IsFlushed
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.end == 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060002C6 RID: 710 RVA: 0x0000F498 File Offset: 0x0000E498
|
||||
public int Flush(byte[] output, int offset, int length)
|
||||
{
|
||||
if (this.bitCount >= 8)
|
||||
{
|
||||
this.buffer_[this.end++] = (byte)this.bits;
|
||||
this.bits >>= 8;
|
||||
this.bitCount -= 8;
|
||||
}
|
||||
if (length > this.end - this.start)
|
||||
{
|
||||
length = this.end - this.start;
|
||||
Array.Copy(this.buffer_, this.start, output, offset, length);
|
||||
this.start = 0;
|
||||
this.end = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Copy(this.buffer_, this.start, output, offset, length);
|
||||
this.start += length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
// Token: 0x060002C7 RID: 711 RVA: 0x0000F550 File Offset: 0x0000E550
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] array = new byte[this.end - this.start];
|
||||
Array.Copy(this.buffer_, this.start, array, 0, array.Length);
|
||||
this.start = 0;
|
||||
this.end = 0;
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x040001C4 RID: 452
|
||||
private byte[] buffer_;
|
||||
|
||||
// Token: 0x040001C5 RID: 453
|
||||
private int start;
|
||||
|
||||
// Token: 0x040001C6 RID: 454
|
||||
private int end;
|
||||
|
||||
// Token: 0x040001C7 RID: 455
|
||||
private uint bits;
|
||||
|
||||
// Token: 0x040001C8 RID: 456
|
||||
private int bitCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using ICSharpCode.SharpZipLib.Encryption;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// Token: 0x0200002B RID: 43
|
||||
public class DeflaterOutputStream : Stream
|
||||
{
|
||||
// Token: 0x06000130 RID: 304 RVA: 0x00008B1C File Offset: 0x00007B1C
|
||||
public DeflaterOutputStream(Stream baseOutputStream)
|
||||
: this(baseOutputStream, new Deflater(), 512)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000131 RID: 305 RVA: 0x00008B2F File Offset: 0x00007B2F
|
||||
public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater)
|
||||
: this(baseOutputStream, deflater, 512)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000132 RID: 306 RVA: 0x00008B40 File Offset: 0x00007B40
|
||||
public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater, int bufferSize)
|
||||
{
|
||||
if (baseOutputStream == null)
|
||||
{
|
||||
throw new ArgumentNullException("baseOutputStream");
|
||||
}
|
||||
if (!baseOutputStream.CanWrite)
|
||||
{
|
||||
throw new ArgumentException("Must support writing", "baseOutputStream");
|
||||
}
|
||||
if (deflater == null)
|
||||
{
|
||||
throw new ArgumentNullException("deflater");
|
||||
}
|
||||
if (bufferSize < 512)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("bufferSize");
|
||||
}
|
||||
this.baseOutputStream_ = baseOutputStream;
|
||||
this.buffer_ = new byte[bufferSize];
|
||||
this.deflater_ = deflater;
|
||||
}
|
||||
|
||||
// Token: 0x06000133 RID: 307 RVA: 0x00008BBC File Offset: 0x00007BBC
|
||||
public virtual void Finish()
|
||||
{
|
||||
this.deflater_.Finish();
|
||||
while (!this.deflater_.IsFinished)
|
||||
{
|
||||
int num = this.deflater_.Deflate(this.buffer_, 0, this.buffer_.Length);
|
||||
if (num <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (this.cryptoTransform_ != null)
|
||||
{
|
||||
this.EncryptBlock(this.buffer_, 0, num);
|
||||
}
|
||||
this.baseOutputStream_.Write(this.buffer_, 0, num);
|
||||
}
|
||||
if (!this.deflater_.IsFinished)
|
||||
{
|
||||
throw new SharpZipBaseException("Can't deflate all input?");
|
||||
}
|
||||
this.baseOutputStream_.Flush();
|
||||
if (this.cryptoTransform_ != null)
|
||||
{
|
||||
if (this.cryptoTransform_ is ZipAESTransform)
|
||||
{
|
||||
this.AESAuthCode = ((ZipAESTransform)this.cryptoTransform_).GetAuthCode();
|
||||
}
|
||||
this.cryptoTransform_.Dispose();
|
||||
this.cryptoTransform_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003B RID: 59
|
||||
// (get) Token: 0x06000134 RID: 308 RVA: 0x00008C8B File Offset: 0x00007C8B
|
||||
// (set) Token: 0x06000135 RID: 309 RVA: 0x00008C93 File Offset: 0x00007C93
|
||||
public bool IsStreamOwner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isStreamOwner_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.isStreamOwner_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003C RID: 60
|
||||
// (get) Token: 0x06000136 RID: 310 RVA: 0x00008C9C File Offset: 0x00007C9C
|
||||
public bool CanPatchEntries
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseOutputStream_.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003D RID: 61
|
||||
// (get) Token: 0x06000137 RID: 311 RVA: 0x00008CA9 File Offset: 0x00007CA9
|
||||
// (set) Token: 0x06000138 RID: 312 RVA: 0x00008CB1 File Offset: 0x00007CB1
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length == 0)
|
||||
{
|
||||
this.password = null;
|
||||
return;
|
||||
}
|
||||
this.password = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000139 RID: 313 RVA: 0x00008CCD File Offset: 0x00007CCD
|
||||
protected void EncryptBlock(byte[] buffer, int offset, int length)
|
||||
{
|
||||
this.cryptoTransform_.TransformBlock(buffer, 0, length, buffer, 0);
|
||||
}
|
||||
|
||||
// Token: 0x0600013A RID: 314 RVA: 0x00008CE0 File Offset: 0x00007CE0
|
||||
protected void InitializePassword(string password)
|
||||
{
|
||||
PkzipClassicManaged pkzipClassicManaged = new PkzipClassicManaged();
|
||||
byte[] array = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));
|
||||
this.cryptoTransform_ = pkzipClassicManaged.CreateEncryptor(array, null);
|
||||
}
|
||||
|
||||
// Token: 0x0600013B RID: 315 RVA: 0x00008D10 File Offset: 0x00007D10
|
||||
protected void InitializeAESPassword(ZipEntry entry, string rawPassword, out byte[] salt, out byte[] pwdVerifier)
|
||||
{
|
||||
salt = new byte[entry.AESSaltLen];
|
||||
if (DeflaterOutputStream._aesRnd == null)
|
||||
{
|
||||
DeflaterOutputStream._aesRnd = new RNGCryptoServiceProvider();
|
||||
}
|
||||
DeflaterOutputStream._aesRnd.GetBytes(salt);
|
||||
int num = entry.AESKeySize / 8;
|
||||
this.cryptoTransform_ = new ZipAESTransform(rawPassword, salt, num, true);
|
||||
pwdVerifier = ((ZipAESTransform)this.cryptoTransform_).PwdVerifier;
|
||||
}
|
||||
|
||||
// Token: 0x0600013C RID: 316 RVA: 0x00008D74 File Offset: 0x00007D74
|
||||
protected void Deflate()
|
||||
{
|
||||
while (!this.deflater_.IsNeedingInput)
|
||||
{
|
||||
int num = this.deflater_.Deflate(this.buffer_, 0, this.buffer_.Length);
|
||||
if (num <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (this.cryptoTransform_ != null)
|
||||
{
|
||||
this.EncryptBlock(this.buffer_, 0, num);
|
||||
}
|
||||
this.baseOutputStream_.Write(this.buffer_, 0, num);
|
||||
}
|
||||
if (!this.deflater_.IsNeedingInput)
|
||||
{
|
||||
throw new SharpZipBaseException("DeflaterOutputStream can't deflate all input?");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003E RID: 62
|
||||
// (get) Token: 0x0600013D RID: 317 RVA: 0x00008DF0 File Offset: 0x00007DF0
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003F RID: 63
|
||||
// (get) Token: 0x0600013E RID: 318 RVA: 0x00008DF3 File Offset: 0x00007DF3
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000040 RID: 64
|
||||
// (get) Token: 0x0600013F RID: 319 RVA: 0x00008DF6 File Offset: 0x00007DF6
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseOutputStream_.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000041 RID: 65
|
||||
// (get) Token: 0x06000140 RID: 320 RVA: 0x00008E03 File Offset: 0x00007E03
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseOutputStream_.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000042 RID: 66
|
||||
// (get) Token: 0x06000141 RID: 321 RVA: 0x00008E10 File Offset: 0x00007E10
|
||||
// (set) Token: 0x06000142 RID: 322 RVA: 0x00008E1D File Offset: 0x00007E1D
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseOutputStream_.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException("Position property not supported");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000143 RID: 323 RVA: 0x00008E29 File Offset: 0x00007E29
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("DeflaterOutputStream Seek not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000144 RID: 324 RVA: 0x00008E35 File Offset: 0x00007E35
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException("DeflaterOutputStream SetLength not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000145 RID: 325 RVA: 0x00008E41 File Offset: 0x00007E41
|
||||
public override int ReadByte()
|
||||
{
|
||||
throw new NotSupportedException("DeflaterOutputStream ReadByte not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000146 RID: 326 RVA: 0x00008E4D File Offset: 0x00007E4D
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException("DeflaterOutputStream Read not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000147 RID: 327 RVA: 0x00008E59 File Offset: 0x00007E59
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("DeflaterOutputStream BeginRead not currently supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000148 RID: 328 RVA: 0x00008E65 File Offset: 0x00007E65
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("BeginWrite is not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000149 RID: 329 RVA: 0x00008E71 File Offset: 0x00007E71
|
||||
public override void Flush()
|
||||
{
|
||||
this.deflater_.Flush();
|
||||
this.Deflate();
|
||||
this.baseOutputStream_.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x0600014A RID: 330 RVA: 0x00008E90 File Offset: 0x00007E90
|
||||
public override void Close()
|
||||
{
|
||||
if (!this.isClosed_)
|
||||
{
|
||||
this.isClosed_ = true;
|
||||
try
|
||||
{
|
||||
this.Finish();
|
||||
if (this.cryptoTransform_ != null)
|
||||
{
|
||||
this.GetAuthCodeIfAES();
|
||||
this.cryptoTransform_.Dispose();
|
||||
this.cryptoTransform_ = null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (this.isStreamOwner_)
|
||||
{
|
||||
this.baseOutputStream_.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600014B RID: 331 RVA: 0x00008EF8 File Offset: 0x00007EF8
|
||||
private void GetAuthCodeIfAES()
|
||||
{
|
||||
if (this.cryptoTransform_ is ZipAESTransform)
|
||||
{
|
||||
this.AESAuthCode = ((ZipAESTransform)this.cryptoTransform_).GetAuthCode();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600014C RID: 332 RVA: 0x00008F20 File Offset: 0x00007F20
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
this.Write(new byte[] { value }, 0, 1);
|
||||
}
|
||||
|
||||
// Token: 0x0600014D RID: 333 RVA: 0x00008F41 File Offset: 0x00007F41
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
this.deflater_.SetInput(buffer, offset, count);
|
||||
this.Deflate();
|
||||
}
|
||||
|
||||
// Token: 0x040000AD RID: 173
|
||||
private string password;
|
||||
|
||||
// Token: 0x040000AE RID: 174
|
||||
private ICryptoTransform cryptoTransform_;
|
||||
|
||||
// Token: 0x040000AF RID: 175
|
||||
protected byte[] AESAuthCode;
|
||||
|
||||
// Token: 0x040000B0 RID: 176
|
||||
private byte[] buffer_;
|
||||
|
||||
// Token: 0x040000B1 RID: 177
|
||||
protected Deflater deflater_;
|
||||
|
||||
// Token: 0x040000B2 RID: 178
|
||||
protected Stream baseOutputStream_;
|
||||
|
||||
// Token: 0x040000B3 RID: 179
|
||||
private bool isClosed_;
|
||||
|
||||
// Token: 0x040000B4 RID: 180
|
||||
private bool isStreamOwner_ = true;
|
||||
|
||||
// Token: 0x040000B5 RID: 181
|
||||
private static RNGCryptoServiceProvider _aesRnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// Token: 0x0200003C RID: 60
|
||||
public class InflaterInputBuffer
|
||||
{
|
||||
// Token: 0x06000251 RID: 593 RVA: 0x0000C425 File Offset: 0x0000B425
|
||||
public InflaterInputBuffer(Stream stream)
|
||||
: this(stream, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000252 RID: 594 RVA: 0x0000C433 File Offset: 0x0000B433
|
||||
public InflaterInputBuffer(Stream stream, int bufferSize)
|
||||
{
|
||||
this.inputStream = stream;
|
||||
if (bufferSize < 1024)
|
||||
{
|
||||
bufferSize = 1024;
|
||||
}
|
||||
this.rawData = new byte[bufferSize];
|
||||
this.clearText = this.rawData;
|
||||
}
|
||||
|
||||
// Token: 0x17000083 RID: 131
|
||||
// (get) Token: 0x06000253 RID: 595 RVA: 0x0000C469 File Offset: 0x0000B469
|
||||
public int RawLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.rawLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000084 RID: 132
|
||||
// (get) Token: 0x06000254 RID: 596 RVA: 0x0000C471 File Offset: 0x0000B471
|
||||
public byte[] RawData
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.rawData;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000085 RID: 133
|
||||
// (get) Token: 0x06000255 RID: 597 RVA: 0x0000C479 File Offset: 0x0000B479
|
||||
public int ClearTextLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clearTextLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000086 RID: 134
|
||||
// (get) Token: 0x06000256 RID: 598 RVA: 0x0000C481 File Offset: 0x0000B481
|
||||
public byte[] ClearText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clearText;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000087 RID: 135
|
||||
// (get) Token: 0x06000257 RID: 599 RVA: 0x0000C489 File Offset: 0x0000B489
|
||||
// (set) Token: 0x06000258 RID: 600 RVA: 0x0000C491 File Offset: 0x0000B491
|
||||
public int Available
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.available;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.available = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000259 RID: 601 RVA: 0x0000C49A File Offset: 0x0000B49A
|
||||
public void SetInflaterInput(Inflater inflater)
|
||||
{
|
||||
if (this.available > 0)
|
||||
{
|
||||
inflater.SetInput(this.clearText, this.clearTextLength - this.available, this.available);
|
||||
this.available = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600025A RID: 602 RVA: 0x0000C4CC File Offset: 0x0000B4CC
|
||||
public void Fill()
|
||||
{
|
||||
this.rawLength = 0;
|
||||
int num;
|
||||
for (int i = this.rawData.Length; i > 0; i -= num)
|
||||
{
|
||||
num = this.inputStream.Read(this.rawData, this.rawLength, i);
|
||||
if (num <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.rawLength += num;
|
||||
}
|
||||
if (this.cryptoTransform != null)
|
||||
{
|
||||
this.clearTextLength = this.cryptoTransform.TransformBlock(this.rawData, 0, this.rawLength, this.clearText, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clearTextLength = this.rawLength;
|
||||
}
|
||||
this.available = this.clearTextLength;
|
||||
}
|
||||
|
||||
// Token: 0x0600025B RID: 603 RVA: 0x0000C565 File Offset: 0x0000B565
|
||||
public int ReadRawBuffer(byte[] buffer)
|
||||
{
|
||||
return this.ReadRawBuffer(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x0600025C RID: 604 RVA: 0x0000C574 File Offset: 0x0000B574
|
||||
public int ReadRawBuffer(byte[] outBuffer, int offset, int length)
|
||||
{
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
}
|
||||
int num = offset;
|
||||
int i = length;
|
||||
while (i > 0)
|
||||
{
|
||||
if (this.available <= 0)
|
||||
{
|
||||
this.Fill();
|
||||
if (this.available <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int num2 = Math.Min(i, this.available);
|
||||
Array.Copy(this.rawData, this.rawLength - this.available, outBuffer, num, num2);
|
||||
num += num2;
|
||||
i -= num2;
|
||||
this.available -= num2;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
// Token: 0x0600025D RID: 605 RVA: 0x0000C5F4 File Offset: 0x0000B5F4
|
||||
public int ReadClearTextBuffer(byte[] outBuffer, int offset, int length)
|
||||
{
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
}
|
||||
int num = offset;
|
||||
int i = length;
|
||||
while (i > 0)
|
||||
{
|
||||
if (this.available <= 0)
|
||||
{
|
||||
this.Fill();
|
||||
if (this.available <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int num2 = Math.Min(i, this.available);
|
||||
Array.Copy(this.clearText, this.clearTextLength - this.available, outBuffer, num, num2);
|
||||
num += num2;
|
||||
i -= num2;
|
||||
this.available -= num2;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
// Token: 0x0600025E RID: 606 RVA: 0x0000C674 File Offset: 0x0000B674
|
||||
public int ReadLeByte()
|
||||
{
|
||||
if (this.available <= 0)
|
||||
{
|
||||
this.Fill();
|
||||
if (this.available <= 0)
|
||||
{
|
||||
throw new ZipException("EOF in header");
|
||||
}
|
||||
}
|
||||
byte b = this.rawData[this.rawLength - this.available];
|
||||
this.available--;
|
||||
return (int)b;
|
||||
}
|
||||
|
||||
// Token: 0x0600025F RID: 607 RVA: 0x0000C6C8 File Offset: 0x0000B6C8
|
||||
public int ReadLeShort()
|
||||
{
|
||||
return this.ReadLeByte() | (this.ReadLeByte() << 8);
|
||||
}
|
||||
|
||||
// Token: 0x06000260 RID: 608 RVA: 0x0000C6D9 File Offset: 0x0000B6D9
|
||||
public int ReadLeInt()
|
||||
{
|
||||
return this.ReadLeShort() | (this.ReadLeShort() << 16);
|
||||
}
|
||||
|
||||
// Token: 0x06000261 RID: 609 RVA: 0x0000C6EB File Offset: 0x0000B6EB
|
||||
public long ReadLeLong()
|
||||
{
|
||||
return (long)((ulong)this.ReadLeInt() | (ulong)((ulong)((long)this.ReadLeInt()) << 32));
|
||||
}
|
||||
|
||||
// Token: 0x17000088 RID: 136
|
||||
// (set) Token: 0x06000262 RID: 610 RVA: 0x0000C700 File Offset: 0x0000B700
|
||||
public ICryptoTransform CryptoTransform
|
||||
{
|
||||
set
|
||||
{
|
||||
this.cryptoTransform = value;
|
||||
if (this.cryptoTransform != null)
|
||||
{
|
||||
if (this.rawData == this.clearText)
|
||||
{
|
||||
if (this.internalClearText == null)
|
||||
{
|
||||
this.internalClearText = new byte[this.rawData.Length];
|
||||
}
|
||||
this.clearText = this.internalClearText;
|
||||
}
|
||||
this.clearTextLength = this.rawLength;
|
||||
if (this.available > 0)
|
||||
{
|
||||
this.cryptoTransform.TransformBlock(this.rawData, this.rawLength - this.available, this.available, this.clearText, this.rawLength - this.available);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clearText = this.rawData;
|
||||
this.clearTextLength = this.rawLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000148 RID: 328
|
||||
private int rawLength;
|
||||
|
||||
// Token: 0x04000149 RID: 329
|
||||
private byte[] rawData;
|
||||
|
||||
// Token: 0x0400014A RID: 330
|
||||
private int clearTextLength;
|
||||
|
||||
// Token: 0x0400014B RID: 331
|
||||
private byte[] clearText;
|
||||
|
||||
// Token: 0x0400014C RID: 332
|
||||
private byte[] internalClearText;
|
||||
|
||||
// Token: 0x0400014D RID: 333
|
||||
private int available;
|
||||
|
||||
// Token: 0x0400014E RID: 334
|
||||
private ICryptoTransform cryptoTransform;
|
||||
|
||||
// Token: 0x0400014F RID: 335
|
||||
private Stream inputStream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// Token: 0x02000029 RID: 41
|
||||
public class InflaterInputStream : Stream
|
||||
{
|
||||
// Token: 0x06000114 RID: 276 RVA: 0x000083BD File Offset: 0x000073BD
|
||||
public InflaterInputStream(Stream baseInputStream)
|
||||
: this(baseInputStream, new Inflater(), 4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000115 RID: 277 RVA: 0x000083D0 File Offset: 0x000073D0
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inf)
|
||||
: this(baseInputStream, inf, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000116 RID: 278 RVA: 0x000083E0 File Offset: 0x000073E0
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inflater, int bufferSize)
|
||||
{
|
||||
if (baseInputStream == null)
|
||||
{
|
||||
throw new ArgumentNullException("baseInputStream");
|
||||
}
|
||||
if (inflater == null)
|
||||
{
|
||||
throw new ArgumentNullException("inflater");
|
||||
}
|
||||
if (bufferSize <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("bufferSize");
|
||||
}
|
||||
this.baseInputStream = baseInputStream;
|
||||
this.inf = inflater;
|
||||
this.inputBuffer = new InflaterInputBuffer(baseInputStream, bufferSize);
|
||||
}
|
||||
|
||||
// Token: 0x17000034 RID: 52
|
||||
// (get) Token: 0x06000117 RID: 279 RVA: 0x00008440 File Offset: 0x00007440
|
||||
// (set) Token: 0x06000118 RID: 280 RVA: 0x00008448 File Offset: 0x00007448
|
||||
public bool IsStreamOwner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isStreamOwner;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.isStreamOwner = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000119 RID: 281 RVA: 0x00008454 File Offset: 0x00007454
|
||||
public long Skip(long count)
|
||||
{
|
||||
if (count <= 0L)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
if (this.baseInputStream.CanSeek)
|
||||
{
|
||||
this.baseInputStream.Seek(count, SeekOrigin.Current);
|
||||
return count;
|
||||
}
|
||||
int num = 2048;
|
||||
if (count < (long)num)
|
||||
{
|
||||
num = (int)count;
|
||||
}
|
||||
byte[] array = new byte[num];
|
||||
int num2 = 1;
|
||||
long num3 = count;
|
||||
while (num3 > 0L && num2 > 0)
|
||||
{
|
||||
if (num3 < (long)num)
|
||||
{
|
||||
num = (int)num3;
|
||||
}
|
||||
num2 = this.baseInputStream.Read(array, 0, num);
|
||||
num3 -= (long)num2;
|
||||
}
|
||||
return count - num3;
|
||||
}
|
||||
|
||||
// Token: 0x0600011A RID: 282 RVA: 0x000084D1 File Offset: 0x000074D1
|
||||
protected void StopDecrypting()
|
||||
{
|
||||
this.inputBuffer.CryptoTransform = null;
|
||||
}
|
||||
|
||||
// Token: 0x17000035 RID: 53
|
||||
// (get) Token: 0x0600011B RID: 283 RVA: 0x000084DF File Offset: 0x000074DF
|
||||
public virtual int Available
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.inf.IsFinished)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600011C RID: 284 RVA: 0x000084F4 File Offset: 0x000074F4
|
||||
protected void Fill()
|
||||
{
|
||||
if (this.inputBuffer.Available <= 0)
|
||||
{
|
||||
this.inputBuffer.Fill();
|
||||
if (this.inputBuffer.Available <= 0)
|
||||
{
|
||||
throw new SharpZipBaseException("Unexpected EOF");
|
||||
}
|
||||
}
|
||||
this.inputBuffer.SetInflaterInput(this.inf);
|
||||
}
|
||||
|
||||
// Token: 0x17000036 RID: 54
|
||||
// (get) Token: 0x0600011D RID: 285 RVA: 0x00008544 File Offset: 0x00007544
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseInputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000037 RID: 55
|
||||
// (get) Token: 0x0600011E RID: 286 RVA: 0x00008551 File Offset: 0x00007551
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000038 RID: 56
|
||||
// (get) Token: 0x0600011F RID: 287 RVA: 0x00008554 File Offset: 0x00007554
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000039 RID: 57
|
||||
// (get) Token: 0x06000120 RID: 288 RVA: 0x00008557 File Offset: 0x00007557
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long)this.inputBuffer.RawLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700003A RID: 58
|
||||
// (get) Token: 0x06000121 RID: 289 RVA: 0x00008565 File Offset: 0x00007565
|
||||
// (set) Token: 0x06000122 RID: 290 RVA: 0x00008572 File Offset: 0x00007572
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.baseInputStream.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream Position not supported");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000123 RID: 291 RVA: 0x0000857E File Offset: 0x0000757E
|
||||
public override void Flush()
|
||||
{
|
||||
this.baseInputStream.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x06000124 RID: 292 RVA: 0x0000858B File Offset: 0x0000758B
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("Seek not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000125 RID: 293 RVA: 0x00008597 File Offset: 0x00007597
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream SetLength not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000126 RID: 294 RVA: 0x000085A3 File Offset: 0x000075A3
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream Write not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000127 RID: 295 RVA: 0x000085AF File Offset: 0x000075AF
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream WriteByte not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000128 RID: 296 RVA: 0x000085BB File Offset: 0x000075BB
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new NotSupportedException("InflaterInputStream BeginWrite not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000129 RID: 297 RVA: 0x000085C7 File Offset: 0x000075C7
|
||||
public override void Close()
|
||||
{
|
||||
if (!this.isClosed)
|
||||
{
|
||||
this.isClosed = true;
|
||||
if (this.isStreamOwner)
|
||||
{
|
||||
this.baseInputStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600012A RID: 298 RVA: 0x000085EC File Offset: 0x000075EC
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (this.inf.IsNeedingDictionary)
|
||||
{
|
||||
throw new SharpZipBaseException("Need a dictionary");
|
||||
}
|
||||
int num = count;
|
||||
for (;;)
|
||||
{
|
||||
int num2 = this.inf.Inflate(buffer, offset, num);
|
||||
offset += num2;
|
||||
num -= num2;
|
||||
if (num == 0 || this.inf.IsFinished)
|
||||
{
|
||||
goto IL_65;
|
||||
}
|
||||
if (this.inf.IsNeedingInput)
|
||||
{
|
||||
this.Fill();
|
||||
}
|
||||
else if (num2 == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new ZipException("Dont know what to do");
|
||||
IL_65:
|
||||
return count - num;
|
||||
}
|
||||
|
||||
// Token: 0x040000A5 RID: 165
|
||||
protected Inflater inf;
|
||||
|
||||
// Token: 0x040000A6 RID: 166
|
||||
protected InflaterInputBuffer inputBuffer;
|
||||
|
||||
// Token: 0x040000A7 RID: 167
|
||||
private Stream baseInputStream;
|
||||
|
||||
// Token: 0x040000A8 RID: 168
|
||||
protected long csize;
|
||||
|
||||
// Token: 0x040000A9 RID: 169
|
||||
private bool isClosed;
|
||||
|
||||
// Token: 0x040000AA RID: 170
|
||||
private bool isStreamOwner = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// Token: 0x0200003D RID: 61
|
||||
public class OutputWindow
|
||||
{
|
||||
// Token: 0x06000263 RID: 611 RVA: 0x0000C7BC File Offset: 0x0000B7BC
|
||||
public void Write(int value)
|
||||
{
|
||||
if (this.windowFilled++ == 32768)
|
||||
{
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
this.window[this.windowEnd++] = (byte)value;
|
||||
this.windowEnd &= 32767;
|
||||
}
|
||||
|
||||
// Token: 0x06000264 RID: 612 RVA: 0x0000C818 File Offset: 0x0000B818
|
||||
private void SlowRepeat(int repStart, int length, int distance)
|
||||
{
|
||||
while (length-- > 0)
|
||||
{
|
||||
this.window[this.windowEnd++] = this.window[repStart++];
|
||||
this.windowEnd &= 32767;
|
||||
repStart &= 32767;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000265 RID: 613 RVA: 0x0000C870 File Offset: 0x0000B870
|
||||
public void Repeat(int length, int distance)
|
||||
{
|
||||
if ((this.windowFilled += length) > 32768)
|
||||
{
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
int num = (this.windowEnd - distance) & 32767;
|
||||
int num2 = 32768 - length;
|
||||
if (num > num2 || this.windowEnd >= num2)
|
||||
{
|
||||
this.SlowRepeat(num, length, distance);
|
||||
return;
|
||||
}
|
||||
if (length <= distance)
|
||||
{
|
||||
Array.Copy(this.window, num, this.window, this.windowEnd, length);
|
||||
this.windowEnd += length;
|
||||
return;
|
||||
}
|
||||
while (length-- > 0)
|
||||
{
|
||||
this.window[this.windowEnd++] = this.window[num++];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000266 RID: 614 RVA: 0x0000C928 File Offset: 0x0000B928
|
||||
public int CopyStored(StreamManipulator input, int length)
|
||||
{
|
||||
length = Math.Min(Math.Min(length, 32768 - this.windowFilled), input.AvailableBytes);
|
||||
int num = 32768 - this.windowEnd;
|
||||
int num2;
|
||||
if (length > num)
|
||||
{
|
||||
num2 = input.CopyBytes(this.window, this.windowEnd, num);
|
||||
if (num2 == num)
|
||||
{
|
||||
num2 += input.CopyBytes(this.window, 0, length - num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = input.CopyBytes(this.window, this.windowEnd, length);
|
||||
}
|
||||
this.windowEnd = (this.windowEnd + num2) & 32767;
|
||||
this.windowFilled += num2;
|
||||
return num2;
|
||||
}
|
||||
|
||||
// Token: 0x06000267 RID: 615 RVA: 0x0000C9CC File Offset: 0x0000B9CC
|
||||
public void CopyDict(byte[] dictionary, int offset, int length)
|
||||
{
|
||||
if (dictionary == null)
|
||||
{
|
||||
throw new ArgumentNullException("dictionary");
|
||||
}
|
||||
if (this.windowFilled > 0)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
if (length > 32768)
|
||||
{
|
||||
offset += length - 32768;
|
||||
length = 32768;
|
||||
}
|
||||
Array.Copy(dictionary, offset, this.window, 0, length);
|
||||
this.windowEnd = length & 32767;
|
||||
}
|
||||
|
||||
// Token: 0x06000268 RID: 616 RVA: 0x0000CA2C File Offset: 0x0000BA2C
|
||||
public int GetFreeSpace()
|
||||
{
|
||||
return 32768 - this.windowFilled;
|
||||
}
|
||||
|
||||
// Token: 0x06000269 RID: 617 RVA: 0x0000CA3A File Offset: 0x0000BA3A
|
||||
public int GetAvailable()
|
||||
{
|
||||
return this.windowFilled;
|
||||
}
|
||||
|
||||
// Token: 0x0600026A RID: 618 RVA: 0x0000CA44 File Offset: 0x0000BA44
|
||||
public int CopyOutput(byte[] output, int offset, int len)
|
||||
{
|
||||
int num = this.windowEnd;
|
||||
if (len > this.windowFilled)
|
||||
{
|
||||
len = this.windowFilled;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = (this.windowEnd - this.windowFilled + len) & 32767;
|
||||
}
|
||||
int num2 = len;
|
||||
int num3 = len - num;
|
||||
if (num3 > 0)
|
||||
{
|
||||
Array.Copy(this.window, 32768 - num3, output, offset, num3);
|
||||
offset += num3;
|
||||
len = num;
|
||||
}
|
||||
Array.Copy(this.window, num - len, output, offset, len);
|
||||
this.windowFilled -= num2;
|
||||
if (this.windowFilled < 0)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return num2;
|
||||
}
|
||||
|
||||
// Token: 0x0600026B RID: 619 RVA: 0x0000CAD8 File Offset: 0x0000BAD8
|
||||
public void Reset()
|
||||
{
|
||||
this.windowFilled = (this.windowEnd = 0);
|
||||
}
|
||||
|
||||
// Token: 0x04000150 RID: 336
|
||||
private const int WindowSize = 32768;
|
||||
|
||||
// Token: 0x04000151 RID: 337
|
||||
private const int WindowMask = 32767;
|
||||
|
||||
// Token: 0x04000152 RID: 338
|
||||
private byte[] window = new byte[32768];
|
||||
|
||||
// Token: 0x04000153 RID: 339
|
||||
private int windowEnd;
|
||||
|
||||
// Token: 0x04000154 RID: 340
|
||||
private int windowFilled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
|
||||
{
|
||||
// Token: 0x0200003E RID: 62
|
||||
public class StreamManipulator
|
||||
{
|
||||
// Token: 0x0600026E RID: 622 RVA: 0x0000CB18 File Offset: 0x0000BB18
|
||||
public int PeekBits(int bitCount)
|
||||
{
|
||||
if (this.bitsInBuffer_ < bitCount)
|
||||
{
|
||||
if (this.windowStart_ == this.windowEnd_)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
this.buffer_ |= (uint)((uint)((int)(this.window_[this.windowStart_++] & byte.MaxValue) | ((int)(this.window_[this.windowStart_++] & byte.MaxValue) << 8)) << this.bitsInBuffer_);
|
||||
this.bitsInBuffer_ += 16;
|
||||
}
|
||||
return (int)((ulong)this.buffer_ & (ulong)((long)((1 << bitCount) - 1)));
|
||||
}
|
||||
|
||||
// Token: 0x0600026F RID: 623 RVA: 0x0000CBB5 File Offset: 0x0000BBB5
|
||||
public void DropBits(int bitCount)
|
||||
{
|
||||
this.buffer_ >>= bitCount;
|
||||
this.bitsInBuffer_ -= bitCount;
|
||||
}
|
||||
|
||||
// Token: 0x06000270 RID: 624 RVA: 0x0000CBD8 File Offset: 0x0000BBD8
|
||||
public int GetBits(int bitCount)
|
||||
{
|
||||
int num = this.PeekBits(bitCount);
|
||||
if (num >= 0)
|
||||
{
|
||||
this.DropBits(bitCount);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x17000089 RID: 137
|
||||
// (get) Token: 0x06000271 RID: 625 RVA: 0x0000CBF9 File Offset: 0x0000BBF9
|
||||
public int AvailableBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.bitsInBuffer_;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700008A RID: 138
|
||||
// (get) Token: 0x06000272 RID: 626 RVA: 0x0000CC01 File Offset: 0x0000BC01
|
||||
public int AvailableBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.windowEnd_ - this.windowStart_ + (this.bitsInBuffer_ >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000273 RID: 627 RVA: 0x0000CC19 File Offset: 0x0000BC19
|
||||
public void SkipToByteBoundary()
|
||||
{
|
||||
this.buffer_ >>= this.bitsInBuffer_ & 7;
|
||||
this.bitsInBuffer_ &= -8;
|
||||
}
|
||||
|
||||
// Token: 0x1700008B RID: 139
|
||||
// (get) Token: 0x06000274 RID: 628 RVA: 0x0000CC42 File Offset: 0x0000BC42
|
||||
public bool IsNeedingInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.windowStart_ == this.windowEnd_;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000275 RID: 629 RVA: 0x0000CC54 File Offset: 0x0000BC54
|
||||
public int CopyBytes(byte[] output, int offset, int length)
|
||||
{
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
}
|
||||
if ((this.bitsInBuffer_ & 7) != 0)
|
||||
{
|
||||
throw new InvalidOperationException("Bit buffer is not byte aligned!");
|
||||
}
|
||||
int num = 0;
|
||||
while (this.bitsInBuffer_ > 0 && length > 0)
|
||||
{
|
||||
output[offset++] = (byte)this.buffer_;
|
||||
this.buffer_ >>= 8;
|
||||
this.bitsInBuffer_ -= 8;
|
||||
length--;
|
||||
num++;
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
int num2 = this.windowEnd_ - this.windowStart_;
|
||||
if (length > num2)
|
||||
{
|
||||
length = num2;
|
||||
}
|
||||
Array.Copy(this.window_, this.windowStart_, output, offset, length);
|
||||
this.windowStart_ += length;
|
||||
if (((this.windowStart_ - this.windowEnd_) & 1) != 0)
|
||||
{
|
||||
this.buffer_ = (uint)(this.window_[this.windowStart_++] & byte.MaxValue);
|
||||
this.bitsInBuffer_ = 8;
|
||||
}
|
||||
return num + length;
|
||||
}
|
||||
|
||||
// Token: 0x06000276 RID: 630 RVA: 0x0000CD48 File Offset: 0x0000BD48
|
||||
public void Reset()
|
||||
{
|
||||
this.buffer_ = 0U;
|
||||
this.windowStart_ = (this.windowEnd_ = (this.bitsInBuffer_ = 0));
|
||||
}
|
||||
|
||||
// Token: 0x06000277 RID: 631 RVA: 0x0000CD78 File Offset: 0x0000BD78
|
||||
public void SetInput(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset", "Cannot be negative");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count", "Cannot be negative");
|
||||
}
|
||||
if (this.windowStart_ < this.windowEnd_)
|
||||
{
|
||||
throw new InvalidOperationException("Old input was not completely processed");
|
||||
}
|
||||
int num = offset + count;
|
||||
if (offset > num || num > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
if ((count & 1) != 0)
|
||||
{
|
||||
this.buffer_ |= (uint)((uint)(buffer[offset++] & byte.MaxValue) << this.bitsInBuffer_);
|
||||
this.bitsInBuffer_ += 8;
|
||||
}
|
||||
this.window_ = buffer;
|
||||
this.windowStart_ = offset;
|
||||
this.windowEnd_ = num;
|
||||
}
|
||||
|
||||
// Token: 0x04000155 RID: 341
|
||||
private byte[] window_;
|
||||
|
||||
// Token: 0x04000156 RID: 342
|
||||
private int windowStart_;
|
||||
|
||||
// Token: 0x04000157 RID: 343
|
||||
private int windowEnd_;
|
||||
|
||||
// Token: 0x04000158 RID: 344
|
||||
private uint buffer_;
|
||||
|
||||
// Token: 0x04000159 RID: 345
|
||||
private int bitsInBuffer_;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user