Ejemplo n.º 1
0
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            var data   = arc.File.View.ReadBytes(entry.Offset, entry.Size);
            var cipher = new AzIsaacEncryption(entry.Size);

            cipher.Decrypt(data, 0, data.Length, 0);
            if (data.Length > 0x14 && Binary.AsciiEqual(data, 0, "ASB\0") && DecryptAsb(data))
            {
                var header = new byte[0x10];
                Buffer.BlockCopy(data, 0, header, 0, 0x10);
                Stream input = new MemoryStream(data, 0x10, data.Length - 0x10);
                input = new ZLibStream(input, CompressionMode.Decompress);
                return(new PrefixStream(header, input));
            }
            return(new MemoryStream(data));
        }
Ejemplo n.º 2
0
        public override ArcFile TryOpen(ArcView file)
        {
            byte[] header_encrypted = file.View.ReadBytes(0, 0x30);
            if (header_encrypted.Length < 0x30)
            {
                return(null);
            }
            byte[] header = new byte[header_encrypted.Length];
            Buffer.BlockCopy(header_encrypted, 0, header, 0, header.Length);

            var cipher = new AzIsaacEncryption((uint)file.MaxOffset);

            cipher.Decrypt(header, 0, header.Length, 0);
            if (!Binary.AsciiEqual(header, 0, "ARC\0"))
            {
                return(null);
            }

            int  ext_count    = LittleEndian.ToInt32(header, 4);
            int  count        = LittleEndian.ToInt32(header, 8);
            uint index_length = LittleEndian.ToUInt32(header, 12);

            if (ext_count < 1 || ext_count > 8 || !IsSaneCount(count) || index_length >= file.MaxOffset)
            {
                return(null);
            }

            var packed_index = file.View.ReadBytes(0x30, index_length);

            if (packed_index.Length != index_length)
            {
                return(null);
            }
            cipher.Decrypt(packed_index, 0, packed_index.Length, 0x30);

            using (var input = new MemoryStream(packed_index))
            {
                var dir = ParseIndex(input, count, header.Length + index_length, file.MaxOffset);
                if (null == dir)
                {
                    return(null);
                }
                return(new ArcFile(file, this, dir));
            }
        }
Ejemplo n.º 3
0
        public override ArcFile TryOpen(ArcView file)
        {
            byte[] header_encrypted = file.View.ReadBytes (0, 0x30);
            if (header_encrypted.Length < 0x30)
                return null;
            byte[] header = new byte[header_encrypted.Length];
            Buffer.BlockCopy (header_encrypted, 0, header, 0, header.Length);

            var cipher = new AzIsaacEncryption ((uint)file.MaxOffset);
            cipher.Decrypt (header, 0, header.Length, 0);
            if (!Binary.AsciiEqual (header, 0, "ARC\0"))
                return null;

            int ext_count = LittleEndian.ToInt32 (header, 4);
            int count = LittleEndian.ToInt32 (header, 8);
            uint index_length = LittleEndian.ToUInt32 (header, 12);
            if (ext_count < 1 || ext_count > 8 || !IsSaneCount (count) || index_length >= file.MaxOffset)
                return null;

            var packed_index = file.View.ReadBytes (0x30, index_length);
            if (packed_index.Length != index_length)
                return null;
            cipher.Decrypt (packed_index, 0, packed_index.Length, 0x30);

            using (var input = new MemoryStream (packed_index))
            {
                var dir = ParseIndex (input, count, header.Length + index_length, file.MaxOffset);
                if (null == dir)
                    return null;
                return new ArcFile (file, this, dir);
            }
        }
Ejemplo n.º 4
0
 public override Stream OpenEntry(ArcFile arc, Entry entry)
 {
     var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
     var cipher = new AzIsaacEncryption (entry.Size);
     cipher.Decrypt (data, 0, data.Length, 0);
     if (data.Length > 0x14 && Binary.AsciiEqual (data, 0, "ASB\0") && DecryptAsb (data))
     {
         var header = new byte[0x10];
         Buffer.BlockCopy (data, 0, header, 0, 0x10);
         Stream input = new MemoryStream (data, 0x10, data.Length-0x10);
         input = new ZLibStream (input, CompressionMode.Decompress);
         return new PrefixStream (header, input);
     }
     return new MemoryStream (data);
 }