Exemplo n.º 1
0
 public override void Init(ArcFile arc)
 {
     if (null == KnownNames)
     {
         ReadNames();
     }
     foreach (var entry in arc.Dir)
     {
         string name;
         if (KnownNames.TryGetValue(entry.Name, out name))
         {
             entry.Name = name;
             entry.Type = FormatCatalog.Instance.GetTypeFromName(name);
         }
     }
 }
Exemplo n.º 2
0
        public override string ReadName(BinaryReader header)
        {
            if (null == KnownNames)
            {
                ReadNames();
            }
            var    hash = base.ReadName(header);
            string name;

            if (null == hash || !KnownNames.TryGetValue(hash, out name))
            {
                return(hash);
            }
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }
            return(name);
        }
Exemplo n.º 3
0
        public override string ReadName(BinaryReader header)
        {
            if (null == KnownNames)
            {
                ReadNames();
            }
            uint   key       = header.ReadUInt32();
            uint   name_hash = header.ReadUInt32() ^ key;
            string name;

            if (KnownNames.TryGetValue(name_hash, out name))
            {
                return(name);
            }
            uint ext_hash = header.ReadUInt32() ^ key;

            name = name_hash.ToString("X8");
            switch (ext_hash)
            {
            case 0x01854675: name += ".png"; break; // GetNameHash (".png")

            case 0x03D435DE: name += ".map"; break; // GetNameHash (".map")

            case 0x2D1F13E0: name += ".asd"; break; // GetNameHash (".asd")

            case 0x482F4319: name += ".tjs"; break; // GetNameHash (".tjs")

            case 0x58924012: name += ".txt"; break; // GetNameHash (".txt")

            case 0xB01C48CA: name += ".ks";  break; // GetNameHash (".ks")

            case 0xC0F7DFB2: name += ".wav"; break; // GetNameHash (".wav")

            case 0xE3A31D19: name += ".jpg"; break; // GetNameHash (".jpg")

            case 0xE7F3FEEB: name += ".ogg"; break; // GetNameHash (".ogg")

            default: name += ext_hash.ToString("X8"); break;
            }
            return(name);
        }
Exemplo n.º 4
0
        static unsafe void DecryptData(byte[] data, int pos, int length, uint key, uint seed)
        {
            if (pos < 0 || pos + length > data.Length)
            {
                throw new ArgumentOutOfRangeException("pos", "Invalid byte array index.");
                fixed(byte *data8 = &data[pos])
                {
                    uint *data32 = (uint *)data8;

                    for (int count = length / 4; count > 0; --count)
                    {
                        *data32 ^= key;
                        key += Binary.RotL(*data32, 16) ^ seed;
                        data32++;
                    }
                }
        }

        RepiEntry EntryFromMd5(byte[] data, int pos, StringBuilder builder)
        {
            var    key = new CowArray <byte> (data, pos, 16).ToArray();
            string name;

            if (KnownNames.TryGetValue(key, out name))
            {
                var entry = FormatCatalog.Instance.Create <RepiEntry> (name);
                entry.HasEncryptionKey = true;
                return(entry);
            }
            builder.Clear();
            for (int i = 0; i < 16; ++i)
            {
                builder.AppendFormat("{0:x2}", key[i]);
            }
            return(new RepiEntry {
                Name = builder.ToString()
            });
        }
Exemplo n.º 5
0
 public static Boolean TryGetRecordName(DbRecordId recordId, out String name)
 {
     return(KnownNames.TryGetValue(recordId.Value, out name));
 }