Class DataSegment
- Namespace
- AsmResolver
- Assembly
- AsmResolver.dll
Provides an implementation of a segment using a byte array to represent its contents.
public class DataSegment : SegmentBase, IReadableSegment, ISegment, IOffsetProvider, IWritable
- Inheritance
-
DataSegment
- Implements
- Inherited Members
- Extension Methods
Constructors
DataSegment(byte[])
Creates a new data segment using the provided byte array as contents.
public DataSegment(byte[] data)
Parameters
data
byte[]The data to store.
Properties
Data
Gets the data that is stored in the segment.
public byte[] Data { get; }
Property Value
- byte[]
Methods
CreateReader(ulong, uint)
Creates a new binary reader that reads the raw contents of the segment.
public BinaryStreamReader CreateReader(ulong fileOffset, uint size)
Parameters
Returns
- BinaryStreamReader
The created binary reader.
Exceptions
- ArgumentOutOfRangeException
Occurs when
fileOffset
is not within the range of the segment.- EndOfStreamException
Occurs when
size
indicates a too large length.
FromReader(ref BinaryStreamReader)
Puts the remaining data of the provided input stream into a new data segment.
public static DataSegment FromReader(ref BinaryStreamReader reader)
Parameters
reader
BinaryStreamReaderThe input stream to read from.
Returns
- DataSegment
The data segment containing the remaining data.
FromReader(ref BinaryStreamReader, int)
Reads a single data segment at the current position of the provided input stream.
public static DataSegment FromReader(ref BinaryStreamReader reader, int count)
Parameters
reader
BinaryStreamReaderThe input stream to read from.
count
intThe number of bytes to read.
Returns
- DataSegment
The read data segment.
GetPhysicalSize()
Computes the number of bytes that the structure contains.
public override uint GetPhysicalSize()
Returns
- uint
The number of bytes.
Write(BinaryStreamWriter)
Serializes the structure to an output stream.
public override void Write(BinaryStreamWriter writer)
Parameters
writer
BinaryStreamWriterThe output stream to write the data to.