Table of Contents

Class VirtualSegment

Namespace
AsmResolver
Assembly
AsmResolver.dll

Represents a segment of code or data that might be resized at runtime.

public class VirtualSegment : IReadableSegment, ISegment, IOffsetProvider, IWritable
Inheritance
VirtualSegment
Implements
Inherited Members
Extension Methods

Constructors

VirtualSegment(ISegment?, uint)

Creates a new segment that is expanded at runtime to the provided virtual size.

public VirtualSegment(ISegment? physicalContents, uint virtualSize)

Parameters

physicalContents ISegment

The physical contents of the segment.

virtualSize uint

The new size at runtime.

Properties

CanUpdateOffsets

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

public bool CanUpdateOffsets { get; }

Property Value

bool

IsReadable

Gets a value indicating whether the physical contents of this segment is readable by a binary reader.

public bool IsReadable { get; }

Property Value

bool

Offset

Gets the physical starting offset of the segment.

public ulong Offset { get; }

Property Value

ulong

PhysicalContents

Gets or sets the physical contents of the segment as it is stored on the disk.

public ISegment? PhysicalContents { get; set; }

Property Value

ISegment

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

VirtualSize

Gets or sets the size of the segment after it is mapped into memory at runtime.

public uint VirtualSize { get; set; }

Property Value

uint

Methods

CreateReader(ulong, uint)

Creates a new binary reader that reads the raw contents of the segment.

public BinaryStreamReader CreateReader(ulong fileOffset, uint size)

Parameters

fileOffset ulong

The starting file offset of the reader.

size uint

The number of bytes to read.

Returns

BinaryStreamReader

The created binary reader.

Exceptions

ArgumentOutOfRangeException

Occurs when fileOffset is not within the range of the segment.

EndOfStreamException

Occurs when size indicates a too large length.

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.