Exemplo n.º 1
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;
            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            if (len < 0)
                throw new LoadDataException("Blob size " + len + " is negative");
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize = decodedSizeExpr != null ? decodedSizeExpr.EvaluateInt(instance) : -1;
            string encoding = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell cell = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);
            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");
            if (structDef != null)
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
        }
Exemplo n.º 2
0
 private void SaveBlobCell(BlobCell blobCell, string name)
 {
     string outName = Path.Combine(_outDir, name);
     Directory.CreateDirectory(Path.GetDirectoryName(outName));
     Stream ms = blobCell.DataStream;
     using(var fs = new FileStream(outName, FileMode.CreateNew))
     {
         while(true)
         {
             int bytes = ms.Read(_buffer, 0, 64000);
             if (bytes == 0) break;
             fs.Write(_buffer, 0, bytes);
         }
     }
 }
Exemplo n.º 3
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;

            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
            {
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            }
            if (len < 0)
            {
                throw new LoadDataException("Blob size " + len + " is negative");
            }
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize     = decodedSizeExpr != null?decodedSizeExpr.EvaluateInt(instance) : -1;

            string      encoding    = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell    cell        = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);

            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");

            if (structDef != null)
            {
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
            }
        }
Exemplo n.º 4
0
 public BlobCellUI(BlobCell cell)
 {
     _cell = cell;
 }
Exemplo n.º 5
0
 public BlobChildSeed(StructDef def, BlobCell cell)
 {
     _def  = def;
     _cell = cell;
 }
Exemplo n.º 6
0
 public BlobChildSeed(StructDef def, BlobCell cell)
 {
     _def = def;
     _cell = cell;
 }