Table of Contents

Interface IMetadataTable

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

Represents a metadata table stored in the tables stream of a managed executable.

public interface IMetadataTable : ICollection, IEnumerable, ISegment, IOffsetProvider, IWritable
Inherited Members

Properties

IsSorted

Gets or sets a value indicating whether the table is considered sorted.

bool IsSorted { get; set; }

Property Value

bool

this[int]

Gets or sets the row at the provided index.

IMetadataRow this[int index] { get; set; }

Parameters

index int

The index of the row to get.

Property Value

IMetadataRow

Exceptions

IndexOutOfRangeException

Occurs when the index is too small or too large for this table.

Layout

Gets the layout of the table.

TableLayout Layout { get; }

Property Value

TableLayout

Methods

GetByRid(uint)

Gets the contents of a row by its row identifier.

IMetadataRow GetByRid(uint rid)

Parameters

rid uint

The row identifier.

Returns

IMetadataRow

The row.

GetRowBounds(uint)

Calculates the offset range of a row within the table.

OffsetRange GetRowBounds(uint rid)

Parameters

rid uint

The identifier of the row to get the bounds of.

Returns

OffsetRange

The bounds.

Remarks

This method does not do any verification on whether rid is a valid row in the table.

SetByRid(uint, IMetadataRow)

Sets the contents of a row by its row identifier.

void SetByRid(uint rid, IMetadataRow row)

Parameters

rid uint

The row identifier.

row IMetadataRow

The new contents of the row.

TryGetByRid(uint, out IMetadataRow)

Attempts to get the contents of a row by its row identifier.

bool TryGetByRid(uint rid, out IMetadataRow row)

Parameters

rid uint

The row identifier.

row IMetadataRow

When successful, the read row.

Returns

bool

true if the RID existed and the row was obtained successfully, false otherwise.

TryGetCell(uint, int, out uint)

Attempts to get the contents of a cell in the table by its row identifier and column index.

bool TryGetCell(uint rid, int column, out uint value)

Parameters

rid uint

The row identifier.

column int

The column index.

value uint

When successful, the contents of the cell, converted to an unsigned integer.

Returns

bool

true if the cell existed and was obtained successfully, false otherwise.

TryGetRidByKey(int, uint, out uint)

Attempts to find a row index in a table by a key. This requires the table to be sorted.

bool TryGetRidByKey(int keyColumnIndex, uint key, out uint rid)

Parameters

keyColumnIndex int

The column number to get the key from.

key uint

The key to search.

rid uint

When this functions returns true, this parameter contains the RID of the row that contains the given key.

Returns

bool

true if the row was found, false otherwise.

TryGetRowByKey(int, uint, out IMetadataRow)

Gets a single row in a table by a key. This requires the table to be sorted.

bool TryGetRowByKey(int keyColumnIndex, uint key, out IMetadataRow row)

Parameters

keyColumnIndex int

The column number to get the key from.

key uint

The key to search.

row IMetadataRow

When this functions returns true, this parameter contains the first row that contains the given key.

Returns

bool

true if the row was found, false otherwise.

UpdateTableLayout(TableLayout)

Updates the table layout.

void UpdateTableLayout(TableLayout layout)

Parameters

layout TableLayout

The new table layout.

Remarks

This method is used to update the sizes of each column, and therefore requires the new layout to have the same names and column types as the original one.