Table of Contents

Class BlobStream

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

Represents the metadata stream containing blob signatures referenced by entries in the tables stream.

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

Remarks

Like most metadata streams, the blob stream does not necessarily contain just valid blobs. It can contain (garbage) data that is never referenced by any of the tables in the tables stream. The only guarantee that the blob heap provides, is that any blob index in the tables stream is the start address (relative to the start of the blob stream) of a blob signature that is prefixed by a length.

Constructors

BlobStream()

Initializes the blob stream with its default name.

protected BlobStream()

BlobStream(string)

Initializes the blob stream with a custom name.

protected BlobStream(string name)

Parameters

name string

The name of the stream.

Fields

DefaultName

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

public const string DefaultName = "#Blob"

Field Value

string

Methods

EnumerateBlobs()

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

public abstract IEnumerable<(uint Index, byte[] Blob)> EnumerateBlobs()

Returns

IEnumerable<(uint Index, byte[] Blob)>

The blob enumerator.

Remarks

As blobs can be referenced at any offset within the heap, the heap is technically allowed to contain garbage data in between blob entries. As such, this linear sweep enumerator may not be an accurate depiction of all blobs that are used by the module.

GetBlobByIndex(uint)

Gets a blob by its blob index.

public abstract byte[]? GetBlobByIndex(uint index)

Parameters

index uint

The offset into the heap to start reading.

Returns

byte[]

The blob, excluding the bytes encoding the length of the blob, or null if the index was invalid.

TryFindBlobIndex(byte[]?, out uint)

Searches the stream for the provided blob.

public abstract bool TryFindBlobIndex(byte[]? blob, out uint index)

Parameters

blob byte[]

The blob to search for.

index uint

When the function returns true, contains the index at which the blob was found.

Returns

bool

true if the blob index was found, false otherwise.

TryGetBlobReaderByIndex(uint, out BinaryStreamReader)

Gets a blob binary reader by its blob index.

public abstract bool TryGetBlobReaderByIndex(uint index, out BinaryStreamReader reader)

Parameters

index uint

The offset into the heap to start reading.

reader BinaryStreamReader

When this method returns true, this parameter contains the created binary reader.

Returns

bool

true if a blob reader could be created at the provided index, false otherwise.