Class SerializedStringsStream
- Namespace
- AsmResolver.PE.DotNet.Metadata
- Assembly
- AsmResolver.PE.dll
Provides an implementation of a strings stream that obtains strings from a readable segment in a file.
public class SerializedStringsStream : StringsStream, IMetadataStream, ISegment, IOffsetProvider, IWritable
- Inheritance
-
SerializedStringsStream
- Implements
- Inherited Members
Constructors
SerializedStringsStream(byte[])
Creates a new strings stream with the provided byte array as the raw contents of the stream.
public SerializedStringsStream(byte[] rawData)
Parameters
rawData
byte[]The raw contents of the stream.
SerializedStringsStream(string, in BinaryStreamReader)
Creates a new strings stream with the provided file segment reader as the raw contents of the stream.
public SerializedStringsStream(string name, in BinaryStreamReader reader)
Parameters
name
stringThe name of the stream.
reader
BinaryStreamReaderThe raw contents of the stream.
SerializedStringsStream(string, byte[])
Creates a new strings stream with the provided byte array as the raw contents of the stream.
public SerializedStringsStream(string name, byte[] rawData)
Parameters
Properties
CanRead
Gets a value indicating whether the raw contents of the stream can be read using a binary stream reader.
public override bool CanRead { get; }
Property Value
Methods
CreateReader()
Creates a binary reader that reads the raw contents of the metadata stream.
public override BinaryStreamReader CreateReader()
Returns
- BinaryStreamReader
The reader.
Exceptions
- InvalidOperationException
Occurs when CanRead is
false
.
EnumerateStrings()
Performs a linear sweep on the stream and yields all strings that are stored.
public override IEnumerable<(uint Index, Utf8String String)> EnumerateStrings()
Returns
- IEnumerable<(uint Index, Utf8String String)>
The strings enumerator.
Remarks
As strings can be referenced at any offset within the heap, the heap is technically allowed to contain garbage data in between string entries. As such, this linear sweep enumerator may not be an accurate depiction of all strings that are used by the module.
GetPhysicalSize()
Computes the number of bytes that the structure contains.
public override uint GetPhysicalSize()
Returns
- uint
The number of bytes.
GetStringByIndex(uint)
Gets a string by its string index.
public override Utf8String? GetStringByIndex(uint index)
Parameters
index
uintThe offset into the heap to start reading.
Returns
- Utf8String
The string, or
null
if the index was invalid.
TryFindStringIndex(Utf8String?, out uint)
Searches the stream for the provided string.
public override bool TryFindStringIndex(Utf8String? value, out uint index)
Parameters
value
Utf8StringThe string to search for.
index
uintWhen the function returns
true
, contains the index at which the string was found.
Returns
- bool
true
if the string index was found,false
otherwise.
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.