public override Stream OpenEntry(ArcFile arc, Entry entry) { var parc = arc as PcfArchive; var pent = entry as PcfEntry; if (null == pent || null == parc) { return(base.OpenEntry(arc, entry)); } Stream input = arc.File.CreateStream(entry.Offset, entry.Size); try { input = parc.Scheme.TransformStream(input, pent.Key, pent.Flags); if (pent.IsPacked) { input = new LimitStream(input, pent.UnpackedSize); } return(input); } catch { input.Dispose(); throw; } }
IBinaryStream OpenBitmapStream(IBinaryStream file, uint unpacked_size) { file.Position = 4; Stream input = new LzssStream(file.AsStream, LzssMode.Decompress, true); input = new LimitStream(input, unpacked_size); return(new BinaryStream(input, file.Name)); }
public override Stream OpenEntry(ArcFile arc, Entry entry) { Stream input = arc.File.CreateStream(entry.Offset, entry.Size); var pent = entry as PackedEntry; if (null == pent || !pent.IsPacked) { return(input); } input = new PackedStream <LzBitsDecompressor> (input); input = new LimitStream(input, pent.UnpackedSize); if (entry.Name.HasExtension(".gpa")) { input = new XoredStream(input, 0xFF); } return(input); }
public override Stream OpenEntry(ArcFile arc, Entry entry) { var parc = (PckArchive)arc; var pent = (PackedEntry)entry; byte data_type = arc.File.View.ReadByte(pent.Offset); Stream input = arc.File.CreateStream(pent.Offset + 1, pent.Size); if (data_type != 0) { input = new InputCryptoStream(input, parc.Encryption.CreateDecryptor()); if (data_type != 3) { input = new LimitStream(input, pent.UnpackedSize); } else { input = new BZip2InputStream(input); } } return(input); }
public override Stream OpenEntry(ArcFile arc, Entry entry) { var parc = arc as PazArchiveBase; var pent = entry as PazEntry; if (null == parc || null == pent) { return(base.OpenEntry(arc, entry)); } Stream input = parc.OpenStream(entry); try { if (parc.XorKey != 0) { input = new XoredStream(input, parc.XorKey); } input = parc.DecryptEntry(input, pent); if (pent.Size < pent.AlignedSize) { input = new LimitStream(input, pent.Size); } if (pent.IsPacked) { input = new ZLibStream(input, CompressionMode.Decompress); } return(input); } catch { if (input != null) { input.Dispose(); } throw; } }
public override Stream OpenEntry(ArcFile arc, Entry entry) { var parc = arc as PazArchiveBase; var pent = entry as PazEntry; if (null == parc || null == pent) { return(base.OpenEntry(arc, entry)); } Stream input = null; try { long part_offset = 0; long entry_start = pent.Offset; long entry_end = pent.Offset + pent.AlignedSize; foreach (var part in parc.Parts) { long part_end_offset = part_offset + part.MaxOffset; if (entry_start < part_end_offset) { uint part_size = (uint)Math.Min(entry_end - entry_start, part_end_offset - entry_start); var entry_part = part.CreateStream(entry_start - part_offset, part_size); if (input != null) { input = new ConcatStream(input, entry_part); } else { input = entry_part; } entry_start += part_size; if (entry_start >= entry_end) { break; } } part_offset = part_end_offset; } if (null == input) { return(Stream.Null); } if (parc.XorKey != 0) { input = new XoredStream(input, parc.XorKey); } input = parc.DecryptEntry(input, pent); if (pent.Size < pent.AlignedSize) { input = new LimitStream(input, pent.Size); } if (pent.IsPacked) { input = new ZLibStream(input, CompressionMode.Decompress); } return(input); } catch { if (input != null) { input.Dispose(); } throw; } }