Beispiel #1
0
        public override ArcFile TryOpen(ArcView file)
        {
            int count = file.View.ReadInt32(4);

            if (count <= 0)
            {
                return(null);
            }
            uint base_offset = file.View.ReadUInt32(8);
            long max_offset  = file.MaxOffset;

            if (base_offset >= max_offset)
            {
                return(null);
            }

            uint cur_offset = 16;
            var  dir        = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                if (cur_offset + 16 > base_offset)
                {
                    return(null);
                }
                uint id          = file.View.ReadUInt32(cur_offset);
                uint offset      = file.View.ReadUInt32(cur_offset + 4);
                uint size        = file.View.ReadUInt32(cur_offset + 8);
                uint packed_size = file.View.ReadUInt32(cur_offset + 12);

                var entry = new AmiEntry(id, () => {
                    uint signature = file.View.ReadUInt32(offset);
                    if (0x00524353 == signature)
                    {
                        return("scr");
                    }
                    else if (0 != packed_size || 0x00505247 == signature)
                    {
                        return("grp");
                    }
                    else
                    {
                        return("dat");
                    }
                });

                entry.Offset       = offset;
                entry.UnpackedSize = size;
                entry.IsPacked     = 0 != packed_size;
                entry.Size         = entry.IsPacked ? packed_size : size;
                if (!entry.CheckPlacement(max_offset))
                {
                    return(null);
                }
                dir.Add(entry);
                cur_offset += 16;
            }
            return(new ArcFile(file, this, dir));
        }
Beispiel #2
0
        public override ArcFile TryOpen(ArcView file)
        {
            int count = file.View.ReadInt32 (4);
            if (count <= 0)
                return null;
            uint base_offset = file.View.ReadUInt32 (8);
            long max_offset = file.MaxOffset;
            if (base_offset >= max_offset)
                return null;

            uint cur_offset = 16;
            var dir = new List<Entry> (count);
            for (int i = 0; i < count; ++i)
            {
                if (cur_offset+16 > base_offset)
                    return null;
                uint id = file.View.ReadUInt32 (cur_offset);
                uint offset = file.View.ReadUInt32 (cur_offset+4);
                uint size = file.View.ReadUInt32 (cur_offset+8);
                uint packed_size = file.View.ReadUInt32 (cur_offset+12);

                var entry = new AmiEntry (id, () => {
                    uint signature = file.View.ReadUInt32 (offset);
                    if (0x00524353 == signature)
                        return "scr";
                    else if (0 != packed_size || 0x00505247 == signature)
                        return "grp";
                    else
                        return "dat";
                });

                entry.Offset = offset;
                entry.UnpackedSize = size;
                entry.IsPacked = 0 != packed_size;
                entry.Size   = entry.IsPacked ? packed_size : size;
                if (!entry.CheckPlacement (max_offset))
                    return null;
                dir.Add (entry);
                cur_offset += 16;
            }
            return new ArcFile (file, this, dir);
        }