Table of Contents

Class CodeSegment

Namespace
AsmResolver.PE.Code
Assembly
AsmResolver.PE.dll

Represents a chunk of native code in a portable executable.

[Obsolete("This class has been superseded by AsmResolver.Patching.PatchedSegment.")]
public class CodeSegment : SegmentBase, ISegment, IOffsetProvider, IWritable
Inheritance
CodeSegment
Implements
Inherited Members

Constructors

CodeSegment(byte[])

Creates a new segment of native code.

public CodeSegment(byte[] code)

Parameters

code byte[]

The raw native code stream.

CodeSegment(ulong, byte[])

Creates a new segment of native code.

public CodeSegment(ulong imageBase, byte[] code)

Parameters

imageBase ulong

The base address of the image the segment is going to be stored in.

code byte[]

The raw native code stream.

Properties

AddressFixups

Gets a collection of fixups that need to be applied upon writing the code to the output stream. This includes addresses to imported symbols and global fields stored in data sections.

public IList<AddressFixup> AddressFixups { get; }

Property Value

IList<AddressFixup>

Code

Gets or sets the raw native code stream.

public byte[] Code { get; set; }

Property Value

byte[]

ImageBase

Gets the base address of the image the segment is stored in.

public ulong ImageBase { get; set; }

Property Value

ulong

Methods

GetPhysicalSize()

Computes the number of bytes that the structure contains.

public override uint GetPhysicalSize()

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 override 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 override void Write(BinaryStreamWriter writer)

Parameters

writer BinaryStreamWriter

The output stream to write the data to.