Class DataSourceSlice
- Namespace
- AsmResolver.IO
- Assembly
- AsmResolver.dll
Represents a data source that only exposes a part (slice) of another data source.
public class DataSourceSlice : ISpanDataSource, IDataSource
- Inheritance
-
DataSourceSlice
- Implements
- Inherited Members
- Extension Methods
Constructors
DataSourceSlice(IDataSource, ulong, ulong)
Creates a new data source slice.
public DataSourceSlice(IDataSource source, ulong start, ulong length)
Parameters
sourceIDataSourceThe original data source to slice.
startulongThe starting address.
lengthulongThe number of bytes.
Exceptions
- ArgumentOutOfRangeException
Occurs when
startand/orlengthresult in addresses that are invalid in the original data source.
Properties
BaseAddress
Gets the first byte address of the data source that is accessible.
public ulong BaseAddress { get; }
Property Value
this[ulong]
Reads a single byte at the provided address.
public byte this[ulong address] { get; }
Parameters
addressulongThe address to read from.
Property Value
Length
Gets the number of bytes accessible in the data source.
public ulong Length { get; }
Property Value
Methods
IsValidAddress(ulong)
Determines whether the provided address is a valid address in the data source.
public bool IsValidAddress(ulong address)
Parameters
addressulongThe address to verify.
Returns
- bool
trueif the address is valid,falseotherwise.
ReadBytes(ulong, byte[], int, int)
Reads a block of data from the data source.
public int ReadBytes(ulong address, byte[] buffer, int index, int count)
Parameters
addressulongThe starting address to read from.
bufferbyte[]The buffer that receives the read bytes.
indexintThe index into the buffer to start writing at.
countintThe number of bytes to read.
Returns
- int
The number of bytes that were read.
ReadBytes(ulong, Span<byte>)
Reads a block of data from the data source.
public int ReadBytes(ulong address, Span<byte> buffer)
Parameters
addressulongThe starting address to read from.
bufferSpan<byte>The buffer that receives the read bytes.
Returns
- int
The number of bytes that were read.