Table of Contents

Class SerializedUserStringsStream

Namespace
AsmResolver.PE.DotNet.Metadata
Assembly
AsmResolver.PE.dll

Provides an implementation of a user-strings stream that obtains strings from a readable segment in a file.

public class SerializedUserStringsStream : UserStringsStream, IMetadataStream, ISegment, IOffsetProvider, IWritable
Inheritance
SerializedUserStringsStream
Implements
Inherited Members

Constructors

SerializedUserStringsStream(byte[])

Creates a new user-strings stream with the provided byte array as the raw contents of the stream.

public SerializedUserStringsStream(byte[] rawData)

Parameters

rawData byte[]

The raw contents of the stream.

SerializedUserStringsStream(string, BinaryStreamReader)

Creates a new user-strings stream with the provided file segment reader as the raw contents of the stream.

public SerializedUserStringsStream(string name, BinaryStreamReader reader)

Parameters

name string

The name of the stream.

reader BinaryStreamReader

The raw contents of the stream.

SerializedUserStringsStream(string, byte[])

Creates a new user-strings stream with the provided byte array as the raw contents of the stream.

public SerializedUserStringsStream(string name, byte[] rawData)

Parameters

name string

The name of the stream.

rawData byte[]

The raw contents of the stream.

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

bool

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, string String)> EnumerateStrings()

Returns

IEnumerable<(uint Index, string 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 string? GetStringByIndex(uint index)

Parameters

index uint

The offset into the heap to start reading.

Returns

string

The string, or null if the index was invalid.

TryFindStringIndex(string, out uint)

Searches the stream for the provided string.

public override bool TryFindStringIndex(string value, out uint index)

Parameters

value string

The string to search for.

index uint

When 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 BinaryStreamWriter

The output stream to write the data to.