Esempio n. 1
0
        private List <Entry> OpenNexton(ArcView lst, long max_offset)
        {
            uint key = lst.View.ReadByte(3);  // guess xor key

            if (0 == key)
            {
                return(null);
            }
            key |= key << 8;
            key |= key << 16;
            int count = (int)(lst.View.ReadUInt32(0) ^ key);

            if (count <= 0 || (4 + count * 0x4c) > lst.MaxOffset)
            {
                return(null);
            }
            var  cp932        = Encodings.cp932.WithFatalFallback();
            var  dir          = new List <Entry> (count);
            uint index_offset = 4;

            for (int i = 0; i < count; ++i)
            {
                string name = ReadName(lst, index_offset + 8, 0x40, key, cp932);
                if (0 == name.Length)
                {
                    return(null);
                }
                var entry = new NextonEntry {
                    Name   = name,
                    Offset = lst.View.ReadUInt32(index_offset) ^ key,
                    Size   = lst.View.ReadUInt32(index_offset + 4) ^ key,
                };
                if (!entry.CheckPlacement(max_offset))
                {
                    return(null);
                }
                int type = lst.View.ReadInt32(index_offset + 0x48);
                if (type >= 0 && type < TypeExt.Length)
                {
                    entry.Name = Path.ChangeExtension(name, TypeExt[type]);
                    if (2 == type || 3 == type)
                    {
                        entry.Type = "image";
                    }
                    else if (4 == type || 5 == type)
                    {
                        entry.Type = "audio";
                    }
                    else if (1 == type)
                    {
                        entry.Type = "script";
                        entry.Key  = (byte)(key + 1);
                    }
                }
                dir.Add(entry);
                index_offset += 0x4c;
            }
            return(dir);
        }
Esempio n. 2
0
 private List<Entry> OpenNexton(ArcView lst, long max_offset)
 {
     uint key = lst.View.ReadByte (3); // guess xor key
     if (0 == key)
         return null;
     key |= key << 8;
     key |= key << 16;
     int count = (int)(lst.View.ReadUInt32 (0) ^ key);
     if (count <= 0 || (4 + count*0x4c) > lst.MaxOffset)
         return null;
     var cp932 = Encodings.cp932.WithFatalFallback();
     var dir = new List<Entry> (count);
     uint index_offset = 4;
     for (int i = 0; i < count; ++i)
     {
         string name = ReadName (lst, index_offset+8, 0x40, key, cp932);
         if (0 == name.Length)
             return null;
         var entry = new NextonEntry {
             Name = name,
             Offset = lst.View.ReadUInt32 (index_offset) ^ key,
             Size   = lst.View.ReadUInt32 (index_offset+4) ^ key,
         };
         if (!entry.CheckPlacement (max_offset))
             return null;
         int type = lst.View.ReadInt32 (index_offset+0x48);
         if (type >= 0 && type < TypeExt.Length)
         {
             entry.Name = Path.ChangeExtension (name, TypeExt[type]);
             if (2 == type || 3 == type)
                 entry.Type = "image";
             else if (4 == type || 5 == type)
                 entry.Type = "audio";
             else if (1 == type)
             {
                 entry.Type = "script";
                 entry.Key = (byte)(key + 1);
             }
         }
         dir.Add (entry);
         index_offset += 0x4c;
     }
     return dir;
 }