Table of Contents

Class MemoryBlock

Namespace
Extism
Assembly
Extism.Pdk.dll

A block of allocated memory.

public class MemoryBlock : IDisposable
Inheritance
MemoryBlock
Implements
Inherited Members

Constructors

MemoryBlock(ulong, ulong)

public MemoryBlock(ulong offset, ulong length)

Parameters

offset ulong
length ulong

Properties

Empty

An Empty memory block.

public static MemoryBlock Empty { get; }

Property Value

MemoryBlock

IsEmpty

Is block empty.

public bool IsEmpty { get; }

Property Value

bool

Length

Length of block in bytes

public ulong Length { get; }

Property Value

ulong

Offset

Starts address of block

public ulong Offset { get; }

Property Value

ulong

Methods

CopyTo(Span<byte>)

Copies the contents of a memory block into a buffer.

public void CopyTo(Span<byte> buffer)

Parameters

buffer Span<byte>

Exceptions

InvalidOperationException

Dispose()

Frees the current memory block.

public void Dispose()

Find(ulong)

Finds a memory block based on its start address.

public static MemoryBlock Find(ulong offset)

Parameters

offset ulong

Returns

MemoryBlock

ReadBytes()

Reads the current memory block as a byte array.

public byte[] ReadBytes()

Returns

byte[]

ReadString()

Reads the current memory block as a UTF8 encoded string.

public string ReadString()

Returns

string

WriteBytes(ReadOnlySpan<byte>)

Writes a byte buffer to this memory block.

public void WriteBytes(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

Exceptions

IndexOutOfRangeException

WriteString(string)

Writes a string to the current memory block.

public void WriteString(string text)

Parameters

text string