Table of Contents

Class CustomMetadataStream

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

Represents a metadata stream with contents in a custom data format.

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

Constructors

CustomMetadataStream(string, ISegment)

Creates a new custom metadata stream.

public CustomMetadataStream(string name, ISegment contents)

Parameters

name string

The name of the stream.

contents ISegment

The raw contents of the stream.

CustomMetadataStream(string, byte[])

Creates a new custom metadata stream.

public CustomMetadataStream(string name, byte[] data)

Parameters

name string

The name of the stream.

data 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 bool CanRead { get; }

Property Value

bool

CanUpdateOffsets

Determines whether this structure can be relocated to another offset or virtual address.

public bool CanUpdateOffsets { get; }

Property Value

bool

Contents

Gets or sets the raw contents of the stream.

public ISegment Contents { get; set; }

Property Value

ISegment

Name

Gets or sets the name of the metadata stream.

public string Name { get; set; }

Property Value

string

Offset

Gets the physical starting offset of the segment.

public ulong Offset { get; }

Property Value

ulong

Rva

Gets the virtual address relative to the beginning of the section that the segment is located in.

public uint Rva { get; }

Property Value

uint

Methods

CreateReader()

Creates a binary reader that reads the raw contents of the metadata stream.

public BinaryStreamReader CreateReader()

Returns

BinaryStreamReader

The reader.

Exceptions

InvalidOperationException

Occurs when CanRead is false.

GetPhysicalSize()

Computes the number of bytes that the structure contains.

public uint GetPhysicalSize()

Returns

uint

The number of bytes.

GetVirtualSize()

Computes the number of bytes the segment will contain when it is mapped into memory.

public uint GetVirtualSize()

Returns

uint

The number of bytes.

UpdateOffsets(in RelocationParameters)

Assigns a new file and virtual offset to the segment and all its sub-components.

public void UpdateOffsets(in RelocationParameters parameters)

Parameters

parameters RelocationParameters

The parameters containing the new offset information for the segment.

Write(BinaryStreamWriter)

Serializes the structure to an output stream.

public void Write(BinaryStreamWriter writer)

Parameters

writer BinaryStreamWriter

The output stream to write the data to.