Esempio n. 1
0
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            Stream input  = arc.File.CreateStream(entry.Offset, entry.Size);
            var    dx_arc = arc as DxArchive;

            if (null == dx_arc)
            {
                return(input);
            }
            var  dx_ent     = (PackedEntry)entry;
            long dec_offset = entry.Offset;

            if (dx_arc.Version > 5)
            {
                dec_offset = dx_ent.UnpackedSize;
            }
            input = new EncryptedStream(input, dec_offset, dx_arc.Key);
            if (!dx_ent.IsPacked)
            {
                return(input);
            }
            using (input)
            {
                var data = Unpack(input);
                return(new BinMemoryStream(data, entry.Name));
            }
        }
Esempio n. 2
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());
                    }
        }
Esempio n. 3
0
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            Stream input  = arc.File.CreateStream(entry.Offset, entry.Size);
            var    dx_arc = arc as DxArchive;

            if (null == dx_arc)
            {
                return(input);
            }
            input = new EncryptedStream(input, entry.Offset, dx_arc.Key);
            var dx_ent = entry as PackedEntry;

            if (null == dx_ent || !dx_ent.IsPacked)
            {
                return(input);
            }
            using (input)
            {
                var data = Unpack(input);
                return(new MemoryStream(data));
            }
        }
Esempio n. 4
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());
                    }
        }
Esempio n. 5
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();
     }
 }
Esempio n. 6
0
 public override Stream OpenEntry(ArcFile arc, Entry entry)
 {
     Stream input = arc.File.CreateStream (entry.Offset, entry.Size);
     var dx_arc = arc as DxArchive;
     if (null == dx_arc)
         return input;
     input = new EncryptedStream (input, entry.Offset, dx_arc.Key);
     var dx_ent = entry as PackedEntry;
     if (null == dx_ent || !dx_ent.IsPacked)
         return input;
     using (input)
     {
         var data = Unpack (input);
         return new MemoryStream (data);
     }
 }