Пример #1
0
        public ExportAssetsTag(HeaderRecord header, FlashReader input)
            : base(header)
        {
            ushort assetCount = input.ReadUInt16();

            Ids   = new List <ushort>(assetCount);
            Names = new List <string>(assetCount);
            for (int i = 0; i < assetCount; i++)
            {
                Ids.Add(input.ReadUInt16());
                Names.Add(input.ReadNullString());
            }
        }
Пример #2
0
        public SymbolClassTag(HeaderRecord header, FlashReader input)
            : base(header)
        {
            ushort symbolCount = input.ReadUInt16();

            Ids   = new List <ushort>(symbolCount);
            Names = new List <string>(symbolCount);

            for (int i = 0; i < symbolCount; i++)
            {
                Ids.Add(input.ReadUInt16());
                Names.Add(input.ReadNullString());
            }
        }
Пример #3
0
        public SymbolClassTag(HeaderRecord header, FlashReader input)
            : base(header)
        {
            var symbolCount = input.ReadUInt16();

            Entries = new List <Tuple <ushort, string> >();

            for (var i = 0; i < symbolCount; i++)
            {
                var id   = input.ReadUInt16();
                var name = input.ReadNullString();

                Entries.Add(new Tuple <ushort, string>(id, name));
            }
        }
Пример #4
0
 public DefineFontNameTag(FlashReader reader, TagRecord header) :
     base(reader, header)
 {
     FontId        = reader.ReadUInt16();
     FontName      = reader.ReadNullTerminatedString();
     FontCopyright = reader.ReadNullTerminatedString();
 }
        public DefineBitsLossless2Tag(HeaderRecord header, FlashReader input) : base(header)
        {
            Id     = input.ReadUInt16();
            Format = input.ReadByte();
            Width  = input.ReadUInt16();
            Height = input.ReadUInt16();

            if (Format == Format8BitColormapped)
            {
                ColorTableSize = input.ReadByte();
            }

            var readSize = 7 + (Format == Format8BitColormapped ? 1 : 0);

            _zlibData = input.ReadBytes(header.Length - readSize);
        }
 public DefineBinaryDataTag(HeaderRecord header, FlashReader input)
     : base(header)
 {
     Id = input.ReadUInt16();
     input.ReadUInt32(); // Reserved | Must equal '0'.
     Data = input.ReadBytes(header.Length - 6);
 }
 public DefineFontNameTag(HeaderRecord header, FlashReader input)
     : base(header)
 {
     Id        = input.ReadUInt16();
     Name      = input.ReadNullString();
     Copyright = input.ReadNullString();
 }
Пример #8
0
        public ABCFile(FlashReader reader)
        {
            _reader = reader;

            MinorVersion = _reader.ReadUInt16();
            MajorVersion = _reader.ReadUInt16();

            Constants = new ASConstants(this, _reader);
            Constants.ReadConstants();

            Methods = new List <ASMethod>(_reader.Read7BitEncodedInt());
            for (int i = 0; i < Methods.Capacity; i++)
            {
                Methods.Add(new ASMethod(this, _reader));
            }

            Metadata = new List <ASMetadata>(_reader.Read7BitEncodedInt());
            for (int i = 0; i < Metadata.Capacity; i++)
            {
                Metadata.Add(new ASMetadata(this, _reader));
            }

            Instances = new List <ASInstance>(_reader.Read7BitEncodedInt());
            for (int i = 0; i < Instances.Capacity; i++)
            {
                Instances.Add(new ASInstance(this, _reader));
            }

            Classes = new List <ASClass>(Instances.Capacity);
            for (int i = 0; i < Classes.Capacity; i++)
            {
                Classes.Add(new ASClass(this, _reader));
                Classes[i].Instance = Instances[i];
            }

            Scripts = new List <ASScript>(_reader.Read7BitEncodedInt());
            for (int i = 0; i < Scripts.Capacity; i++)
            {
                Scripts.Add(new ASScript(this, _reader));
            }

            MethodBodies = new List <ASMethodBody>(_reader.Read7BitEncodedInt());
            for (int i = 0; i < MethodBodies.Capacity; i++)
            {
                MethodBodies.Add(new ASMethodBody(this, _reader));
            }
        }
Пример #9
0
        public DefineBinaryDataTag(FlashReader reader, TagRecord header)
            : base(reader, header)
        {
            CharacterId = reader.ReadUInt16();
            reader.ReadUInt32();

            BinaryData = reader.ReadBytes(header.Body.Length - 6);
        }
Пример #10
0
        public ABCFile(FlashReader input)
            : this()
        {
            _input = input;

            ushort minor = input.ReadUInt16();
            ushort major = input.ReadUInt16();

            Version = new Version(major, minor);
            Pool    = new ASConstantPool(this, input);

            PopulateList(Methods, ReadMethod);
            PopulateList(Metadata, ReadMetadata);
            PopulateList(Instances, ReadInstance);
            PopulateList(Classes, ReadClass, Instances.Count);
            PopulateList(Scripts, ReadScript);
            PopulateList(MethodBodies, ReadMethodBody);
        }
Пример #11
0
        public DefineBitsLossless2Tag(HeaderRecord header, FlashReader input)
            : base(header)
        {
            Id      = input.ReadUInt16();
            _format = input.ReadByte();

            _width  = input.ReadUInt16();
            _height = input.ReadUInt16();

            if (_format == 3)
            {
                _colorTableSize = input.ReadByte();
            }

            int partialLength = (7 + (_format == 3 ? 1 : 0));

            _compressedBitmapData = input.ReadBytes(header.Length - partialLength);
        }
Пример #12
0
        public ABCFile(byte[] data)
            : this()
        {
            _initialLength = data.Length;
            _input         = new FlashReader(data);

            ushort minor = _input.ReadUInt16();
            ushort major = _input.ReadUInt16();

            Version = new Version(major, minor);
            Pool    = new ASConstantPool(this, _input);

            PopulateList(Methods, ReadMethod);
            PopulateList(Metadata, ReadMetadata);
            PopulateList(Instances, ReadInstance);
            PopulateList(Classes, ReadClass, Instances.Count);
            PopulateList(Scripts, ReadScript);
            PopulateList(MethodBodies, ReadMethodBody);
        }
Пример #13
0
        public ExportAssetsTag(FlashReader reader, TagRecord header) :
            base(reader, header)
        {
            int count = reader.ReadUInt16();

            Assets = new Dictionary <ushort, string>(count);

            for (int i = 0; i < count; i++)
            {
                ushort tag  = reader.ReadUInt16();
                string name = reader.ReadNullTerminatedString();

                if (Assets.ContainsKey(tag))
                {
                    throw new Exception(
                              "Duplicate tag id: " + tag);
                }
                Assets[tag] = name;
            }
        }
Пример #14
0
 public DefineSoundTag(HeaderRecord header, FlashReader input)
     : base(header)
 {
     Id               = input.ReadUInt16();
     Format           = input.ReadUB(4);
     Rate             = input.ReadUB(2);
     Size             = input.ReadUB(1);
     SoundType        = input.ReadUB(1);
     SoundSampleCount = input.ReadUInt32();
     SoundData        = input.ReadBytes(header.Length - 7);
 }
Пример #15
0
        public DefineBitsLossless2Tag(HeaderRecord header, FlashReader input)
            : base(header)
        {
            Id      = input.ReadUInt16();
            _format = input.ReadByte();

            ushort width  = input.ReadUInt16();
            ushort height = input.ReadUInt16();

            _argbMap = new Color[width, height];

            if (_format == 3)
            {
                _colorTableSize = input.ReadByte();
            }

            int partialLength = (7 + (_format == 3 ? 1 : 0));

            _compressedData = input.ReadBytes(header.Length - partialLength);
        }
Пример #16
0
        public SymbolClassTag(FlashReader reader, TagRecord header) :
            base(reader, header)
        {
            int symbolCount = reader.ReadUInt16();

            Symbols = new Dictionary <ushort, string>(symbolCount);

            for (int i = 0; i < symbolCount; i++)
            {
                ushort characterId = reader.ReadUInt16();
                string symbolName  = reader.ReadNullTerminatedString();

                if (Symbols.ContainsKey(characterId))
                {
                    symbolName =
                        $"{Symbols[characterId]},{symbolName}";
                }
                Symbols[characterId] = symbolName;
            }
        }
Пример #17
0
        public HeaderRecord(FlashReader input)
        {
            ushort header = header = input.ReadUInt16();

            Kind = (TagKind)(header >> 6);

            Length = (header & 63);
            if (Length > MAX_SHORT_LENGTH)
            {
                Length     = input.ReadInt32();
                _isLongTag = (Length <= MAX_SHORT_LENGTH);
            }
        }
Пример #18
0
        public DefineBitsLossless2Tag(FlashReader reader, TagRecord header) :
            base(reader, header)
        {
            CharacterId  = reader.ReadUInt16();
            BitmapFormat = reader.ReadByte();
            BitmapWidth  = reader.ReadUInt16();
            BitmapHeight = reader.ReadUInt16();

            _isCompressed = true;
            switch (BitmapFormat - 3)
            {
            case 0: break;

            case 1:
            case 2:
            {
                _compressedBitmapData =
                    reader.ReadBytes(header.Body.Length - 7);

                break;
            }
            }
        }
Пример #19
0
        public DefineBitsJPEG3(HeaderRecord header, FlashReader input)
            : base(header)
        {
            Id = input.ReadUInt16();

            int alphaDataOffset = input.ReadInt32();

            Data = input.ReadBytes(alphaDataOffset);

            Format = GetFormat(Data);
            if (Format == ImageFormat.JPEG)
            {
                int partialLength = (2 + 4 + alphaDataOffset);
                AlphaData = input.ReadBytes(Header.Length - partialLength);
            }
        }
Пример #20
0
        public DefineBitsJPEG3(HeaderRecord header, FlashReader input) : base(header)
        {
            Id = input.ReadUInt16();

            var alphaDataOffset = input.ReadInt32();

            Data   = input.ReadBytes(alphaDataOffset);
            Format = GetFormat(Data);

            if (Format == ImageFormat.JPEG)
            {
                var partialLength = 2 + 4 + alphaDataOffset;
                AlphaData = input.ReadBytes(Header.Length - partialLength);
            }
            else
            {
                // Minimum Compressed Empty Data Length
                AlphaData = input.ReadBytes(8);
            }
        }
Пример #21
0
        public TagRecord(FlashReader reader)
        {
            Start = reader.Position;

            ushort header = reader.ReadUInt16();

            TagType = (FlashTagType)(header >> 6);

            int length = (header & 63);

            if (length >= 63)
            {
                length        = reader.ReadInt32();
                IsSpecialLong = (length < 63);
            }
            BodyStart = reader.Position;

            Body            = reader.ReadBytes(length);
            reader.Position = BodyStart;
        }
Пример #22
0
 public FrameRecord(FlashReader input)
 {
     Area  = new RectangeRecord(input);
     Rate  = (ushort)(input.ReadUInt16() >> 8);
     Count = input.ReadUInt16();
 }
Пример #23
0
 public ScriptLimitsTag(FlashReader reader, TagRecord header) :
     base(reader, header)
 {
     MaxRecursionDepth    = reader.ReadUInt16();
     ScriptTimeoutSeconds = reader.ReadUInt16();
 }
Пример #24
0
 public ScriptLimitsTag(HeaderRecord header, FlashReader input)
     : base(header)
 {
     MaxRecursionDepth    = input.ReadUInt16();
     ScriptTimeoutSeconds = input.ReadUInt16();
 }