Ejemplo n.º 1
0
 protected IndexReader(DxHeader header, int version, Stream input)
 {
     m_header   = header;
     m_version  = version;
     m_input    = new BinaryStream(input, "");
     m_encoding = Encoding.GetEncoding(header.CodePage);
 }
Ejemplo n.º 2
0
 public IndexReader(DxHeader header, int version, Stream input)
 {
     m_version    = version;
     m_entry_size = m_version >= 2 ? 0x2C : 0x28;
     m_header     = header;
     m_input      = new ArcView.Reader(input);
 }
Ejemplo n.º 3
0
        List <Entry> ReadIndex(ArcView file, int version, byte[] key)
        {
            var header = file.View.ReadBytes(4, 0x18);

            if (0x18 != header.Length)
            {
                return(null);
            }
            Decrypt(header, 0, header.Length, 4, key);
            var dx = new DxHeader {
                IndexSize   = LittleEndian.ToUInt32(header, 0),
                BaseOffset  = LittleEndian.ToUInt32(header, 4),
                IndexOffset = LittleEndian.ToUInt32(header, 8),
                FileTable   = LittleEndian.ToUInt32(header, 0x0c),
                DirTable    = LittleEndian.ToUInt32(header, 0x10),
            };

            if (dx.DirTable >= dx.IndexSize || dx.FileTable >= dx.IndexSize)
            {
                return(null);
            }
            using (var encrypted = file.CreateStream(dx.IndexOffset, dx.IndexSize))
                using (var index = new EncryptedStream(encrypted, dx.IndexOffset, key))
                    using (var reader = new IndexReader(dx, version, index))
                    {
                        return(reader.Read());
                    }
        }
Ejemplo n.º 4
0
 public static IndexReader Create(DxHeader header, int version, Stream input)
 {
     if (version <= 4)
     {
         return(new IndexReaderV2(header, version, input));
     }
     else if (6 == version)
     {
         return(new IndexReaderV6(header, version, input));
     }
     else
     {
         throw new InvalidFormatException("Not supported DX archive version.");
     }
 }
Ejemplo n.º 5
0
        List <Entry> ReadIndex(ArcView file, int version, byte[] key)
        {
            DxHeader dx = null;

            if (version <= 4)
            {
                dx = ReadArcHeaderV4(file, version, key);
            }
            else if (6 == version)
            {
                dx = ReadArcHeaderV6(file, version, key);
            }
            if (null == dx || dx.DirTable >= dx.IndexSize || dx.FileTable >= dx.IndexSize)
            {
                return(null);
            }
            using (var encrypted = file.CreateStream(dx.IndexOffset, dx.IndexSize))
                using (var index = new EncryptedStream(encrypted, 6 == version ? 0 : dx.IndexOffset, key))
                    using (var reader = IndexReader.Create(dx, version, index))
                    {
                        return(reader.Read());
                    }
        }
Ejemplo n.º 6
0
 public IndexReaderV6(DxHeader header, int version, Stream input) : base(header, version, input)
 {
     m_entry_size = 0x40;
 }
Ejemplo n.º 7
0
 public IndexReaderV2(DxHeader header, int version, Stream input) : base(header, version, input)
 {
     m_entry_size = m_version >= 2 ? 0x2C : 0x28;
 }
Ejemplo n.º 8
0
 public IndexReader(DxHeader header, int version, Stream input)
 {
     m_version = version;
     m_entry_size = m_version >= 2 ? 0x2C : 0x28;
     m_header = header;
     m_input = new ArcView.Reader (input);
 }
Ejemplo n.º 9
0
 List<Entry> ReadIndex(ArcView file, int version, byte[] key)
 {
     var header = file.View.ReadBytes (4, 0x18);
     if (0x18 != header.Length)
         return null;
     Decrypt (header, 0, header.Length, 4, key);
     var dx = new DxHeader {
         IndexSize  = LittleEndian.ToUInt32 (header, 0),
         BaseOffset = LittleEndian.ToUInt32 (header, 4),
         IndexOffset = LittleEndian.ToUInt32 (header, 8),
         FileTable  = LittleEndian.ToUInt32 (header, 0x0c),
         DirTable   = LittleEndian.ToUInt32 (header, 0x10),
     };
     if (dx.DirTable >= dx.IndexSize || dx.FileTable >= dx.IndexSize)
         return null;
     using (var encrypted = file.CreateStream (dx.IndexOffset, dx.IndexSize))
     using (var index = new EncryptedStream (encrypted, dx.IndexOffset, key))
     using (var reader = new IndexReader (dx, version, index))
     {
         return reader.Read();
     }
 }