Class ByteArrayDataSource
- Namespace
- AsmResolver.IO
- Assembly
- AsmResolver.dll
Provides a IDataSource wrapper around a raw byte array.
public sealed class ByteArrayDataSource : ISpanDataSource, IDataSource
- Inheritance
-
ByteArrayDataSource
- Implements
- Inherited Members
- Extension Methods
Constructors
ByteArrayDataSource(byte[])
Creates a new instance of the ByteArrayDataSource class.
public ByteArrayDataSource(byte[] data)
Parameters
data
byte[]The raw data to read from.
ByteArrayDataSource(byte[], ulong)
Creates a new instance of the ByteArrayDataSource class.
public ByteArrayDataSource(byte[] data, ulong baseAddress)
Parameters
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
address
ulongThe address to read from.
Property Value
Length
Gets the number of bytes accessible in the data source.
public ulong Length { get; }
Property Value
Methods
CreateReader(byte[])
Constructs a new binary stream reader on the provided byte array.
[Obsolete("Use the constructor of AsmResolver.IO.BinaryStreamReader instead.")]
public static BinaryStreamReader CreateReader(byte[] data)
Parameters
data
byte[]The byte array to read.
Returns
- BinaryStreamReader
The stream reader.
IsValidAddress(ulong)
Determines whether the provided address is a valid address in the data source.
public bool IsValidAddress(ulong address)
Parameters
address
ulongThe address to verify.
Returns
- bool
true
if the address is valid,false
otherwise.
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
address
ulongThe starting address to read from.
buffer
byte[]The buffer that receives the read bytes.
index
intThe index into the buffer to start writing at.
count
intThe 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
address
ulongThe starting address to read from.
buffer
Span<byte>The buffer that receives the read bytes.
Returns
- int
The number of bytes that were read.