scripts
This commit is contained in:
@@ -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