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)); }
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); } } }
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)); } }
public BlobCellUI(BlobCell cell) { _cell = cell; }
public BlobChildSeed(StructDef def, BlobCell cell) { _def = def; _cell = cell; }