public override ArcFile TryOpen(ArcView file) { if (0x1001 != file.View.ReadInt16(0xA)) { return(null); } int count = file.View.ReadInt32(0x10); if (!IsSaneCount(count)) { return(null); } int mode = file.View.ReadInt32(0xC); long cadr_offset; if (0 == (mode & 0xF)) { if (!file.View.AsciiEqual(0x16, "DFNM")) { return(null); } cadr_offset = file.View.ReadInt64(0x1A); } else { throw new NotSupportedException("Not supported Xuse archive version"); } int ndix_offset = 0x24; if (!file.View.AsciiEqual(ndix_offset, "NDIX")) { return(null); } if (cadr_offset > file.View.Reserve(0, (uint)cadr_offset)) { return(null); } int index_length = 8 * count; int filenames_offset = ndix_offset + 8 + 2 * index_length; if (!file.View.AsciiEqual(filenames_offset, "CTIF")) { return(null); } var dir = new List <Entry> (count); using (var cadr_view = file.CreateFrame()) { uint cadr_size = 4 + 12 * (uint)count; if (cadr_size > cadr_view.Reserve(cadr_offset, cadr_size) || !cadr_view.AsciiEqual(cadr_offset, "CADR")) { return(null); } ndix_offset += 6; cadr_offset += 6; var name_buf = new byte[0x40]; for (int i = 0; i < count; ++i) { uint entry_offset = file.View.ReadUInt32(ndix_offset); if (0x1001 != file.View.ReadUInt16(entry_offset)) { return(null); } var name_length = file.View.ReadUInt16(entry_offset + 6); if (name_length > name_buf.Length) { name_buf = new byte[name_length]; } file.View.Read(entry_offset + 0xA, name_buf, 0, name_length); for (int n = 0; n < name_length; ++n) { name_buf[n] ^= 0x56; } var name = Encodings.cp932.GetString(name_buf, 0, name_length); var entry = FormatCatalog.Instance.Create <Entry> (name); entry.Offset = cadr_view.ReadInt64(cadr_offset); if (entry.Offset >= file.MaxOffset) { return(null); } dir.Add(entry); ndix_offset += 8; cadr_offset += 12; } } foreach (var entry in dir) { if (!file.View.AsciiEqual(entry.Offset, "DATA")) { return(null); } entry.Size = file.View.ReadUInt32(entry.Offset + 0x18); entry.Offset += 0x1E; } return(new ArcFile(file, this, dir)); }
public EncryptedViewStream(ArcView mmap, byte[] key) { m_view = mmap.CreateFrame(); m_key = key; m_max_offset = mmap.MaxOffset; }
public EncryptedStream(ArcView mmap, Camellia encryption) { m_view = mmap.CreateFrame(); m_enc = encryption; m_max_offset = mmap.MaxOffset; }
public EncryptedStream(ArcView mmap, IMalieDecryptor decryptor) { m_view = mmap.CreateFrame(); m_dec = decryptor; m_max_offset = mmap.MaxOffset; }
public EncryptedViewStream(ArcView mmap, byte[] key) { m_view = mmap.CreateFrame(); m_key = key; m_max_offset = mmap.MaxOffset; }
public override ArcFile TryOpen(ArcView file) { if (0x1001 != file.View.ReadInt16 (0xA)) return null; int count = file.View.ReadInt32 (0x10); if (!IsSaneCount (count)) return null; int mode = file.View.ReadInt32 (0xC); long cadr_offset; if (0 == (mode & 0xF)) { if (!file.View.AsciiEqual (0x16, "DFNM")) return null; cadr_offset = file.View.ReadInt64 (0x1A); } else throw new NotSupportedException ("Not supported Xuse archive version"); int ndix_offset = 0x24; if (!file.View.AsciiEqual (ndix_offset, "NDIX")) return null; if (cadr_offset > file.View.Reserve (0, (uint)cadr_offset)) return null; int index_length = 8 * count; int filenames_offset = ndix_offset + 8 + 2 * index_length; if (!file.View.AsciiEqual (filenames_offset, "CTIF")) return null; var dir = new List<Entry> (count); using (var cadr_view = file.CreateFrame()) { uint cadr_size = 4 + 12 * (uint)count; if (cadr_size > cadr_view.Reserve (cadr_offset, cadr_size) || !cadr_view.AsciiEqual (cadr_offset, "CADR")) return null; ndix_offset += 6; cadr_offset += 6; var name_buf = new byte[0x40]; for (int i = 0; i < count; ++i) { uint entry_offset = file.View.ReadUInt32 (ndix_offset); if (0x1001 != file.View.ReadUInt16 (entry_offset)) return null; var name_length = file.View.ReadUInt16 (entry_offset+6); if (name_length > name_buf.Length) name_buf = new byte[name_length]; file.View.Read (entry_offset+0xA, name_buf, 0, name_length); for (int n = 0; n < name_length; ++n) name_buf[n] ^= 0x56; var name = Encodings.cp932.GetString (name_buf, 0, name_length); var entry = FormatCatalog.Instance.Create<Entry> (name); entry.Offset = cadr_view.ReadInt64 (cadr_offset); if (entry.Offset >= file.MaxOffset) return null; dir.Add (entry); ndix_offset += 8; cadr_offset += 12; } } foreach (var entry in dir) { if (!file.View.AsciiEqual (entry.Offset, "DATA")) return null; entry.Size = file.View.ReadUInt32 (entry.Offset+0x18); entry.Offset += 0x1E; } return new ArcFile (file, this, dir); }
public EncryptedStream(ArcView mmap, Camellia encryption) { m_view = mmap.CreateFrame(); m_enc = encryption; m_max_offset = mmap.MaxOffset; }
public ViewStreamBase(ArcView mmap) { m_view = mmap.CreateFrame(); m_max_offset = mmap.MaxOffset; }