public ZipEntry GetNextEntry() { if (_crc == null) { throw new InvalidOperationException("Closed."); } if (_entry != null) { CloseEntry(); } var num = InputBuffer.ReadLeInt(); switch (num) { case ZipConstants.CentralHeaderSignature: case ZipConstants.EndOfCentralDirectorySignature: case ZipConstants.CentralHeaderDigitalSignature: case ZipConstants.ArchiveExtraDataSignature: case 0x6064b50: Close(); return(null); case 0x30304b50: case ZipConstants.SpanningSignature: num = InputBuffer.ReadLeInt(); break; } if (num != ZipConstants.LocalHeaderSignature) { throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}"); } var versionRequiredToExtract = (short)InputBuffer.ReadLeShort(); _flags = InputBuffer.ReadLeShort(); _method = InputBuffer.ReadLeShort(); var num3 = (uint)InputBuffer.ReadLeInt(); var num4 = InputBuffer.ReadLeInt(); Csize = InputBuffer.ReadLeInt(); _size = InputBuffer.ReadLeInt(); var num5 = InputBuffer.ReadLeShort(); var num6 = InputBuffer.ReadLeShort(); var flag = (_flags & 1) == 1; var buffer = new byte[num5]; InputBuffer.ReadRawBuffer(buffer); var name = ZipConstants.ConvertToStringExt(_flags, buffer); _entry = new ZipEntry(name, versionRequiredToExtract) { Flags = _flags, CompressionMethod = (CompressionMethod)_method }; if ((_flags & 8) == 0) { _entry.Crc = num4 & 0xffffffffL; _entry.Size = _size & 0xffffffffL; _entry.CompressedSize = Csize & 0xffffffffL; _entry.CryptoCheckValue = (byte)((num4 >> 0x18) & 0xff); } else { if (num4 != 0) { _entry.Crc = num4 & 0xffffffffL; } if (_size != 0L) { _entry.Size = _size & 0xffffffffL; } if (Csize != 0L) { _entry.CompressedSize = Csize & 0xffffffffL; } _entry.CryptoCheckValue = (byte)((num3 >> 8) & 0xff); } _entry.DosTime = num3; if (num6 > 0) { var buffer2 = new byte[num6]; InputBuffer.ReadRawBuffer(buffer2); _entry.ExtraData = buffer2; } _entry.ProcessExtraData(true); if (_entry.CompressedSize >= 0L) { Csize = _entry.CompressedSize; } if (_entry.Size >= 0L) { _size = _entry.Size; } if ((_method == 0) && ((!flag && (Csize != _size)) || (flag && ((Csize - 12L) != _size)))) { throw new ZipException("Stored, but compressed != uncompressed"); } if (_entry.IsCompressionMethodSupported()) { _internalReader = InitialRead; } else { _internalReader = ReadingNotSupported; } return(_entry); }
public ZipEntry GetNextEntry() { if (this.crc == null) { throw new InvalidOperationException("Closed."); } if (this.entry != null) { this.CloseEntry(); } int num = this.inputBuffer.ReadLeInt(); if (num == 33639248 || num == 101010256 || num == 84233040 || num == 117853008 || num == 101075792) { this.Close(); return(null); } if (num == 808471376 || num == 134695760) { num = this.inputBuffer.ReadLeInt(); } if (num != 67324752) { throw new ZipException("Wrong Local header signature: 0x" + string.Format("{0:X}", num)); } short versionRequiredToExtract = (short)this.inputBuffer.ReadLeShort(); this.flags = this.inputBuffer.ReadLeShort(); this.method = this.inputBuffer.ReadLeShort(); uint num2 = (uint)this.inputBuffer.ReadLeInt(); int num3 = this.inputBuffer.ReadLeInt(); this.csize = (long)this.inputBuffer.ReadLeInt(); this.size = (long)this.inputBuffer.ReadLeInt(); int num4 = this.inputBuffer.ReadLeShort(); int num5 = this.inputBuffer.ReadLeShort(); bool flag = (this.flags & 1) == 1; byte[] array = new byte[num4]; this.inputBuffer.ReadRawBuffer(array); string name = ZipConstants.ConvertToStringExt(this.flags, array); this.entry = new ZipEntry(name, (int)versionRequiredToExtract); this.entry.Flags = this.flags; this.entry.CompressionMethod = (CompressionMethod)this.method; if ((this.flags & 8) == 0) { this.entry.Crc = ((long)num3 & unchecked ((long)((ulong)-1))); this.entry.Size = (this.size & unchecked ((long)((ulong)-1))); this.entry.CompressedSize = (this.csize & unchecked ((long)((ulong)-1))); this.entry.CryptoCheckValue = (byte)(num3 >> 24); } else { if (num3 != 0) { this.entry.Crc = ((long)num3 & unchecked ((long)((ulong)-1))); } if (this.size != 0L) { this.entry.Size = (this.size & unchecked ((long)((ulong)-1))); } if (this.csize != 0L) { this.entry.CompressedSize = (this.csize & unchecked ((long)((ulong)-1))); } this.entry.CryptoCheckValue = (byte)(num2 >> 8 & 255U); } this.entry.DosTime = (long)((ulong)num2); if (num5 > 0) { byte[] array2 = new byte[num5]; this.inputBuffer.ReadRawBuffer(array2); this.entry.ExtraData = array2; } this.entry.ProcessExtraData(true); if (this.entry.CompressedSize >= 0L) { this.csize = this.entry.CompressedSize; } if (this.entry.Size >= 0L) { this.size = this.entry.Size; } if (this.method == 0 && ((!flag && this.csize != this.size) || (flag && this.csize - 12L != this.size))) { throw new ZipException("Stored, but compressed != uncompressed"); } if (this.entry.IsCompressionMethodSupported()) { this.internalReader = new ZipInputStream.ReaderDelegate(this.InitialRead); } else { this.internalReader = new ZipInputStream.ReaderDelegate(this.ReadingNotSupported); } return(this.entry); }