public Stream GetResourceStream(int offset) { if (_resourceOrigin < 0) { int pos = _image.ResolveVirtualAddress(_image.Resources.VirtualAddress); _resourceOrigin = pos; } if (offset >= _image.Resources.Size) { throw new BadMetadataException(); } var oldPos = _reader.Position; try { _reader.Position = _resourceOrigin + offset; var size = _reader.ReadInt32(); return(_reader.Slice(_reader.Position, size)); } finally { _reader.Position = oldPos; } }
public BufferedBinaryReader Fetch(uint offset) { if (offset >= _heap.Length) { throw new BadMetadataException("Invalid #Blob heap offset."); } _heap.Seek(offset, SeekOrigin.Begin); int length = _heap.ReadPackedInt(); if (length <= 0) { return(Zero); } //TODO: implement slice without need to know that _heap is another slice return(_heap.Slice(0, length)); }