Beispiel #1
0
        protected IEnumerable <TagBinaryInfo> GetTagFullBinariesFromSwfResource(string resourceName)
        {
            var             file   = new SwfFile();
            var             stream = OpenEmbeddedResource(resourceName);
            SwfStreamReader reader = new SwfStreamReader(stream);

            file.FileInfo = reader.ReadSwfFileInfo();
            stream        = DecompressIfNeeded(file.FileInfo, stream);
            stream.Seek(8, SeekOrigin.Begin);
            reader      = new SwfStreamReader(stream);
            file.Header = reader.ReadSwfHeader();

            while (stream.Position < stream.Length)
            {
                var position = stream.Position;

                ushort     typeAndSize = reader.ReadUInt16();
                SwfTagType type        = (SwfTagType)(typeAndSize >> 6);
                int        shortSize   = typeAndSize & 0x3f;
                int        size        = shortSize < 0x3f ? shortSize : reader.ReadInt32();

                var length = stream.Position - position + size;

                stream.Seek(position, SeekOrigin.Begin);
                yield return(new TagBinaryInfo {
                    Type = type, Binary = reader.ReadBytes((int)length)
                });
            }
        }
Beispiel #2
0
        public static EnableTelemetryTag Create(SwfStreamReader reader)
        {
            reader.ReadUInt16();             // reserved
            var sha256 = reader.IsEOF
                                ? new byte[0]
                                : reader.ReadBytes(32);

            return(new EnableTelemetryTag {
                SHA256PasswordHash = sha256
            });
        }
Beispiel #3
0
        public static SwfTagBase Read(SwfStreamReader reader)
        {
            var type_and_size = reader.ReadUInt16();
            var tag_id        = type_and_size >> 6;
            var short_size    = type_and_size & 0x3f;
            var size          = short_size < 0x3f ? (uint)short_size : reader.ReadUInt32();
            var tag_data      = reader.ReadBytes(size);

            return(Create(new SwfTagData {
                TagId = tag_id,
                TagData = tag_data
            }));
        }
Beispiel #4
0
        public override byte[] ReadBytes(int count)
        {
            var a = _first.ReadBytes(count);
            var b = _second.ReadBytes(count);

            if (a.Length != b.Length)
            {
                throw new InvalidOperationException();
            }
            for (var i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    throw new InvalidOperationException();
                }
            }
            return(a);
        }
        protected IEnumerable<SwfTagData> GetTagBinariesFromSwfResource(string resourceName)
        {
            var file = new SwfFile();
            var stream = OpenEmbeddedResource(resourceName);
            SwfStreamReader reader = new SwfStreamReader(stream);
            file.FileInfo = reader.ReadSwfFileInfo();
            stream = DecompressIfNeeded(file.FileInfo, stream);
            stream.Seek(8, SeekOrigin.Begin);
            reader = new SwfStreamReader(stream);
            file.Header = reader.ReadSwfHeader();

            while (stream.Position < stream.Length) {
                ushort typeAndSize = reader.ReadUInt16();
                SwfTagType type = (SwfTagType)(typeAndSize >> 6);
                int shortSize = typeAndSize & 0x3f;
                int size = shortSize < 0x3f ? shortSize : reader.ReadInt32();
                yield return new SwfTagData { Type = type, Data = reader.ReadBytes(size) };
            }
        }