private void PrepareNextPacket() { byte num = (byte)this.baseStream.ReadByte(); byte num2 = (byte)this.baseStream.ReadByte(); byte num3 = (byte)this.baseStream.ReadByte(); int len = (num + (num2 << 8)) + (num3 << 0x10); this.baseStream.ReadByte(); int num5 = (this.baseStream.ReadByte() + (this.baseStream.ReadByte() << 8)) + (this.baseStream.ReadByte() << 0x10); if (num5 == 0) { num5 = len; this.zInStream = null; } else { this.ReadNextPacket(len); MemoryStream stream = new MemoryStream(this.inBuffer); this.zInStream = new ZInputStream(stream); this.zInStream.maxInput = len; } this.inPos = 0; this.maxInPos = num5; }
public override int Read(byte[] buffer, int offset, int count) { int num2; if (buffer == null) { throw new ArgumentNullException("buffer", Resources.BufferCannotBeNull); } if ((offset < 0) || (offset >= buffer.Length)) { throw new ArgumentOutOfRangeException("offset", Resources.OffsetMustBeValid); } if ((offset + count) > buffer.Length) { throw new ArgumentException(Resources.BufferNotLargeEnough, "buffer"); } if (this.inPos == this.maxInPos) { this.PrepareNextPacket(); } int len = Math.Min(count, this.maxInPos - this.inPos); if (this.zInStream != null) { num2 = this.zInStream.read(buffer, offset, len); } else { num2 = this.baseStream.Read(buffer, offset, len); } this.inPos += num2; if (this.inPos == this.maxInPos) { this.zInStream = null; this.inBufferRef.Target = this.inBuffer; this.inBuffer = null; } return num2; }