예제 #1
0
파일: ArcDRS.cs 프로젝트: zxc120/GARbro
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            var isf = arc as IsfArchive;

            if (null == isf || entry.Type != "script" || entry.Size <= 0x10)
            {
                return(arc.File.CreateStream(entry.Offset, entry.Size));
            }
            bool encoded    = arc.File.View.AsciiEqual(entry.Offset + entry.Size - 0x10, "SECRETFILTER100a");
            uint entry_size = entry.Size;

            if (encoded)
            {
                entry_size -= 0x10;
                if (null == isf.Secret)
                {
                    isf.Secret = QuerySecret();
                }
                if (null == isf.Secret || 0 == isf.Secret.Length)
                {
                    return(arc.File.CreateStream(entry.Offset, entry.Size));
                }
            }
            var data = new byte[entry_size];

            arc.File.View.Read(entry.Offset, data, 0, entry_size);
            if (encoded)
            {
                var decoder = new IsfDecoder(isf.Secret);
                decoder.Decode(data);
            }
            int signature = LittleEndian.ToUInt16(data, 4);

            if (0x9795 == signature)
            {
                ApplyTransformation(data, 8, x => x >> 2 | x << 6);
            }
            else if (0xd197 == signature)
            {
                ApplyTransformation(data, 8, x => ~x);
            }
            else if (0xce89 == signature && 0 != data[6])
            {
                byte key = data[6];
                ApplyTransformation(data, 8, x => x ^ key);
            }
            return(new BinMemoryStream(data, entry.Name));
        }
예제 #2
0
파일: ArcDRS.cs 프로젝트: Casidi/GARbro
 public override Stream OpenEntry(ArcFile arc, Entry entry)
 {
     var isf = arc as IsfArchive;
     if (null == isf || entry.Type != "script" || entry.Size <= 0x10)
         return arc.File.CreateStream (entry.Offset, entry.Size);
     bool encoded = arc.File.View.AsciiEqual (entry.Offset+entry.Size-0x10, "SECRETFILTER100a");
     uint entry_size = entry.Size;
     if (encoded)
     {
         entry_size -= 0x10;
         if (null == isf.Secret)
             isf.Secret = QuerySecret();
         if (null == isf.Secret || 0 == isf.Secret.Length)
             return arc.File.CreateStream (entry.Offset, entry.Size);
     }
     var data = new byte[entry_size];
     arc.File.View.Read (entry.Offset, data, 0, entry_size);
     if (encoded)
     {
         var decoder = new IsfDecoder (isf.Secret);
         decoder.Decode (data);
     }
     int signature = LittleEndian.ToUInt16 (data, 4);
     if (0x9795 == signature)
     {
         ApplyTransformation (data, 8, x => x >> 2 | x << 6);
     }
     else if (0xd197 == signature)
     {
         ApplyTransformation (data, 8, x => ~x);
     }
     else if (0xce89 == signature && 0 != data[6])
     {
         byte key = data[6];
         ApplyTransformation (data, 8, x => x ^ key);
     }
     return new MemoryStream (data);
 }