Table of Contents

Class StringsStream

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

Represents the metadata stream containing the logical strings heap of a managed executable file.

public abstract class StringsStream : MetadataHeap, IMetadataStream, ISegment, IOffsetProvider, IWritable
Inheritance
StringsStream
Implements
Derived
Inherited Members

Remarks

Like most metadata streams, the strings stream does not necessarily contain just valid strings. It can contain (garbage) data that is never referenced by any of the tables in the tables stream. The only guarantee that the strings heap provides, is that any string index in the tables stream is the start address (relative to the start of the strings stream) of a UTF-8 string that is zero terminated.

Constructors

StringsStream()

Initializes the strings stream with its default name.

protected StringsStream()

StringsStream(string)

Initializes the strings stream with a custom name.

protected StringsStream(string name)

Parameters

name string

Fields

DefaultName

The default name of a strings stream, as described in the specification provided by ECMA-335.

public const string DefaultName = "#Strings"

Field Value

string

Methods

EnumerateStrings()

Performs a linear sweep on the stream and yields all strings that are stored.

public abstract 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.

GetStringByIndex(uint)

Gets a string by its string index.

public abstract Utf8String? GetStringByIndex(uint index)

Parameters

index uint

The 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 abstract bool TryFindStringIndex(Utf8String? value, out uint index)

Parameters

value Utf8String

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.