UnmanagedMemoryAccessor Class

Provides random access to unmanaged blocks of memory from managed code.

Syntax

Declaration

public class UnmanagedMemoryAccessor : IDisposable

Inheritance Hierarchy

Inherited Members

System.Object

, , , , , ,

Constructors summary

Initializes a new instance of the UnmanagedMemoryAccessor class.

Initializes a new instance of the UnmanagedMemoryAccessor class with a specified buffer, offset, and capacity.

Initializes a new instance of the UnmanagedMemoryAccessor class with a specified buffer, offset, capacity, and access right.

Properties summary

Determines whether the accessor is readable.

Determines whether the accessory is writable.

Gets the capacity of the accessor.

Determines whether the accessor is currently open by a process.

Methods summary

Releases all resources used by the UnmanagedMemoryAccessor.

Releases the unmanaged resources used by the UnmanagedMemoryAccessor and optionally releases the managed resources.

Sets the initial values for the accessor.

Reads a Boolean value from the accessor.

Reads a byte value from the accessor.

Reads a character from the accessor.

Reads a decimal value from the accessor.

Reads a double-precision floating-point value from the accessor.

Reads a 16-bit integer from the accessor.

Reads a 32-bit integer from the accessor.

Reads a 64-bit integer from the accessor.

Reads an 8-bit signed integer from the accessor.

Reads a single-precision floating-point value from the accessor.

Reads an unsigned 16-bit integer from the accessor.

Reads an unsigned 32-bit integer from the accessor.

Reads an unsigned 64-bit integer from the accessor.

Writes a Boolean value into the accessor.

Writes a byte value into the accessor.

Writes a character into the accessor.

Writes a decimal value into the accessor.

Writes a Double value into the accessor.

Writes a 16-bit integer into the accessor.

Writes a 32-bit integer into the accessor.

Writes a 64-bit integer into the accessor.

Writes an 8-bit integer into the accessor.

Writes a Single into the accessor.

Writes an unsigned 16-bit integer into the accessor.

Writes an unsigned 32-bit integer into the accessor.

Writes an unsigned 64-bit integer into the accessor.

Constructors

  • UnmanagedMemoryAccessor()

    Initializes a new instance of the UnmanagedMemoryAccessor class.

    protected UnmanagedMemoryAccessor()
  • UnmanagedMemoryAccessor(SafeBuffer, Int64, Int64)

    Initializes a new instance of the UnmanagedMemoryAccessor class with a specified buffer, offset, and capacity.

    public UnmanagedMemoryAccessor(SafeBuffer buffer, long offset, long capacity)

    Parameters

    • buffer

      The buffer to contain the accessor.

    • offset

      The byte at which to start the accessor.

    • capacity

      The size, in bytes, of memory to allocate.

    Exceptions

  • UnmanagedMemoryAccessor(SafeBuffer, Int64, Int64, FileAccess)

    Initializes a new instance of the UnmanagedMemoryAccessor class with a specified buffer, offset, capacity, and access right.

    public UnmanagedMemoryAccessor(SafeBuffer buffer, long offset, long capacity, FileAccess access)

    Parameters

    • buffer

      The buffer to contain the accessor.

    • offset

      The byte at which to start the accessor.

    • capacity

      The size, in bytes, of memory to allocate.

    • access

      The type of access allowed to the memory. The default is ReadWrite.

    Exceptions

Properties

  • CanRead

    Determines whether the accessor is readable.

    public bool CanRead { get; }

    Property Value

    • true if the accessor is readable; otherwise, false.

  • CanWrite

    Determines whether the accessory is writable.

    public bool CanWrite { get; }

    Property Value

    • true if the accessor is writable; otherwise, false.

  • Capacity

    Gets the capacity of the accessor.

    public long Capacity { get; }

    Property Value

    • The capacity of the accessor.

  • IsOpen

    Determines whether the accessor is currently open by a process.

    protected bool IsOpen { get; }

    Property Value

    • true if the accessor is open; otherwise, false.

Methods

  • Dispose()

    Releases all resources used by the UnmanagedMemoryAccessor.

    public void Dispose()
  • Dispose(Boolean)

    Releases the unmanaged resources used by the UnmanagedMemoryAccessor and optionally releases the managed resources.

    protected virtual void Dispose(bool disposing)

    Parameters

    • disposing

      true to release both managed and unmanaged resources; false to release only unmanaged resources.

  • Initialize(SafeBuffer, Int64, Int64, FileAccess)

    Sets the initial values for the accessor.

    [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
    protected void Initialize(SafeBuffer buffer, long offset, long capacity, FileAccess access)

    Parameters

    • buffer

      The buffer to contain the accessor.

    • offset

      The byte at which to start the accessor.

    • capacity

      The size, in bytes, of memory to allocate.

    • access

      The type of access allowed to the memory. The default is ReadWrite.

    Exceptions

  • ReadBoolean(Int64)

    Reads a Boolean value from the accessor.

    public bool ReadBoolean(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    Exceptions

  • ReadByte(Int64)

    Reads a byte value from the accessor.

    public byte ReadByte(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadChar(Int64)

    Reads a character from the accessor.

    public char ReadChar(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadDecimal(Int64)

    Reads a decimal value from the accessor.

    public decimal ReadDecimal(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    Exceptions

  • ReadDouble(Int64)

    Reads a double-precision floating-point value from the accessor.

    public double ReadDouble(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadInt16(Int64)

    Reads a 16-bit integer from the accessor.

    public short ReadInt16(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadInt32(Int64)

    Reads a 32-bit integer from the accessor.

    public int ReadInt32(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadInt64(Int64)

    Reads a 64-bit integer from the accessor.

    public long ReadInt64(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadSByte(Int64)

    Reads an 8-bit signed integer from the accessor.

    [CLSCompliant(false)]
    public sbyte ReadSByte(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadSingle(Int64)

    Reads a single-precision floating-point value from the accessor.

    public float ReadSingle(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadUInt16(Int64)

    Reads an unsigned 16-bit integer from the accessor.

    [CLSCompliant(false)]
    public ushort ReadUInt16(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadUInt32(Int64)

    Reads an unsigned 32-bit integer from the accessor.

    [CLSCompliant(false)]
    public uint ReadUInt32(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • ReadUInt64(Int64)

    Reads an unsigned 64-bit integer from the accessor.

    [CLSCompliant(false)]
    public ulong ReadUInt64(long position)

    Parameters

    • position

      The number of bytes into the accessor at which to begin reading.

    Returns

    • The value that was read.

    Exceptions

  • Write(Int64, Boolean)

    Writes a Boolean value into the accessor.

    public void Write(long position, bool value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Byte)

    Writes a byte value into the accessor.

    public void Write(long position, byte value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Char)

    Writes a character into the accessor.

    public void Write(long position, char value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Decimal)

    Writes a decimal value into the accessor.

    public void Write(long position, decimal value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Double)

    Writes a Double value into the accessor.

    public void Write(long position, double value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Int16)

    Writes a 16-bit integer into the accessor.

    public void Write(long position, short value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Int32)

    Writes a 32-bit integer into the accessor.

    public void Write(long position, int value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Int64)

    Writes a 64-bit integer into the accessor.

    public void Write(long position, long value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, SByte)

    Writes an 8-bit integer into the accessor.

    [CLSCompliant(false)]
    public void Write(long position, sbyte value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, Single)

    Writes a Single into the accessor.

    public void Write(long position, float value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, UInt16)

    Writes an unsigned 16-bit integer into the accessor.

    [CLSCompliant(false)]
    public void Write(long position, ushort value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, UInt32)

    Writes an unsigned 32-bit integer into the accessor.

    [CLSCompliant(false)]
    public void Write(long position, uint value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

  • Write(Int64, UInt64)

    Writes an unsigned 64-bit integer into the accessor.

    [CLSCompliant(false)]
    public void Write(long position, ulong value)

    Parameters

    • position

      The number of bytes into the accessor at which to begin writing.

    • value

      The value to write.

    Exceptions

Details

Namespace

System.IO

Assembly

System.IO.UnmanagedMemoryStream.dll