Table of Contents

Class TypeMemoryLayout

Namespace
AsmResolver.DotNet.Memory
Assembly
AsmResolver.DotNet.dll

Provides information about the memory layout of a type.

public class TypeMemoryLayout
Inheritance
TypeMemoryLayout
Inherited Members

Constructors

TypeMemoryLayout(ITypeDescriptor, uint, MemoryLayoutAttributes)

Creates a new instance of the TypeMemoryLayout class.

public TypeMemoryLayout(ITypeDescriptor type, uint size, MemoryLayoutAttributes attributes)

Parameters

type ITypeDescriptor

The type for which the memory layout is determined.

size uint

The size of the type.

attributes MemoryLayoutAttributes

The attributes

Properties

Attributes

Gets additional attributes associated to this memory layout.

public MemoryLayoutAttributes Attributes { get; }

Property Value

MemoryLayoutAttributes

Is32Bit

Gets a value indicating whether the type layout was determined assuming a 32-bit environment.

public bool Is32Bit { get; }

Property Value

bool

Is64Bit

Gets a value indicating whether the type layout was determined assuming a 64-bit environment.

public bool Is64Bit { get; }

Property Value

bool

IsPlatformDependent

Gets a value indicating whether the type layout is dependent on the bitness of the environment.

public bool IsPlatformDependent { get; }

Property Value

bool

IsReferenceOrContainsReferences

Gets a value indicating whether the type is a managed reference or contains managed references that are tracked by the garbage collector.

public bool IsReferenceOrContainsReferences { get; }

Property Value

bool

Remarks

This is an equivalent to RuntimeHelpers.IsReferenceOrContainsReferences.

this[FieldDefinition]

Gets the implied memory layout for the provided field.

public FieldMemoryLayout this[FieldDefinition field] { get; }

Parameters

field FieldDefinition

The field.

Property Value

FieldMemoryLayout

Size

Gets the total number of bytes this structure requires.

public uint Size { get; }

Property Value

uint

Type

Gets the type for which the memory layout was determined.

public ITypeDescriptor Type { get; }

Property Value

ITypeDescriptor

Methods

GetFields()

Gets all fields stored in the type.

public IEnumerable<FieldDefinition> GetFields()

Returns

IEnumerable<FieldDefinition>

TryGetFieldAtOffset(uint, out FieldMemoryLayout?)

Finds a field within this type memory layout by its offset.

public bool TryGetFieldAtOffset(uint offset, out FieldMemoryLayout? field)

Parameters

offset uint

The offset of the field to find.

field FieldMemoryLayout

When the method returns true, contains the field with the provided offset..

Returns

bool

true if the field with the provided offset existed, false, otherwise.

TryGetFieldPath(uint, out IList<FieldMemoryLayout>)

Traverses the type memory layout tree and finds a field within this type memory layout by its offset.

public bool TryGetFieldPath(uint offset, out IList<FieldMemoryLayout> path)

Parameters

offset uint

The offset of the field to find.

path IList<FieldMemoryLayout>

The (incomplete) path of fields to traverse to reach the provided field offset.

Returns

bool

true if the offset points to the start of a field, false otherwise.