コード例 #1
0
        public override ImageMetaData ReadMetaData(IBinaryStream stream)
        {
            var key = new byte[0x10];

            stream.Position = 4;
            if (key.Length != stream.Read(key, 0, key.Length))
            {
                return(null);
            }
            using (var enc = new InputProxyStream(stream.AsStream, true))
                using (var crypto = new InputCryptoStream(enc, new GaxTransform(key)))
                    using (var input = new BinaryStream(crypto, stream.Name))
                    {
                        var info = Png.ReadMetaData(input);
                        if (null == info)
                        {
                            return(null);
                        }
                        return(new GaxMetaData
                        {
                            OffsetX = info.OffsetX,
                            OffsetY = info.OffsetY,
                            Width = info.Width,
                            Height = info.Height,
                            BPP = info.BPP,
                            Key = key,
                        });
                    }
        }
コード例 #2
0
ファイル: ImageRSA.cs プロジェクト: zxc120/GARbro
 public override ImageMetaData ReadMetaData(IBinaryStream stream)
 {
     using (var sha = SHA1.Create())
     {
         var key = sha.ComputeHash(KnownKey).Take(16).ToArray();
         using (var proxy = new InputProxyStream(stream.AsStream, true))
             using (var crypto = new InputCryptoStream(proxy, new Rc4Transform(key)))
                 using (var input = new BinaryStream(crypto, stream.Name))
                 {
                     var info = base.ReadMetaData(input);
                     if (null == info)
                     {
                         return(null);
                     }
                     return(new Rc4PngMetaData
                     {
                         Width = info.Width,
                         Height = info.Height,
                         OffsetX = info.OffsetX,
                         OffsetY = info.OffsetY,
                         BPP = info.BPP,
                         Key = key,
                     });
                 }
     }
 }
コード例 #3
0
ファイル: ImageRSA.cs プロジェクト: zxc120/GARbro
        public override ImageData Read(IBinaryStream stream, ImageMetaData info)
        {
            var rc4 = (Rc4PngMetaData)info;

            using (var sha = SHA1.Create())
                using (var proxy = new InputProxyStream(stream.AsStream, true))
                    using (var crypto = new InputCryptoStream(proxy, new Rc4Transform(rc4.Key)))
                        using (var input = new BinaryStream(crypto, stream.Name))
                            return(base.Read(input, info));
        }
コード例 #4
0
ファイル: ArcTactics.cs プロジェクト: zxc120/GARbro
            bool ReadV1(Stream input, int entry_size)
            {
                // NOTE CryptoStream will close an input stream
                using (var proxy = new InputProxyStream(input, true))
                    using (var xored = new InputCryptoStream(proxy, new NotTransform()))
                        using (var lzss = new LzssStream(xored))
                            if (m_index.Length != lzss.Read(m_index, 0, m_index.Length))
                            {
                                return(false);
                            }

                int index_offset = Array.IndexOf <byte> (m_index, 0);

                if (-1 == index_offset || 0 == index_offset)
                {
                    return(false);
                }
                Password = m_index.Take(index_offset++).ToArray();
                long base_offset = 0x20 + m_packed_size;

                for (int i = 0; i < m_count; ++i)
                {
                    var entry = new PackedEntry();
                    entry.Offset = LittleEndian.ToUInt32(m_index, index_offset) + base_offset;
                    entry.Size   = LittleEndian.ToUInt32(m_index, index_offset + 4);
                    if (!entry.CheckPlacement(m_file.MaxOffset))
                    {
                        return(false);
                    }
                    entry.UnpackedSize = LittleEndian.ToUInt32(m_index, index_offset + 8);
                    entry.IsPacked     = entry.UnpackedSize != 0;
                    if (!entry.IsPacked)
                    {
                        entry.UnpackedSize = entry.Size;
                    }
                    int name_len = LittleEndian.ToInt32(m_index, index_offset + 0xC);
                    if (name_len <= 0 || name_len > 0x100)
                    {
                        return(false);
                    }
                    entry.Name = Encodings.cp932.GetString(m_index, index_offset + entry_size, name_len);
                    entry.Type = FormatCatalog.Instance.GetTypeFromName(entry.Name);
                    m_dir.Value.Add(entry);
                    index_offset += entry_size + name_len;
                }
                return(true);
            }