Class AbstractMemoryIO

java.lang.Object
jnr.ffi.Pointer
jnr.ffi.provider.AbstractMemoryIO
Direct Known Subclasses:
AbstractArrayMemoryIO, AbstractBufferMemoryIO, BoundedMemoryIO, DirectMemoryIO, InAccessibleMemoryIO, ShareMemoryIO

public abstract class AbstractMemoryIO extends Pointer
Base implementations of some MemoryIO operations.
  • Constructor Details

    • AbstractMemoryIO

      protected AbstractMemoryIO(Runtime runtime, long address, boolean isDirect)
  • Method Details

    • checkBounds

      protected static void checkBounds(long size, long off, long len)
    • indexOf

      public int indexOf(long offset, byte value)
      Description copied from class: Pointer
      Returns the location of a byte value within the memory area represented by this Pointer.
      Specified by:
      indexOf in class Pointer
      Parameters:
      offset - the offset from the start of the memory location this Pointer represents to begin searching.
      value - the byte value to locate.
      Returns:
      the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
    • getAddress

      public long getAddress(long offset)
      Description copied from class: Pointer
      Reads a native memory address value at the given offset.

      A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

      Specified by:
      getAddress in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be read.
      Returns:
      the native address value contained in the memory at the offset
      See Also:
    • putAddress

      public void putAddress(long offset, long value)
      Description copied from class: Pointer
      Writes a native memory address value at the given offset.

      A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

      Specified by:
      putAddress in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be written.
      value - The native address value to be written.
      See Also:
    • checkBounds

      public void checkBounds(long offset, long size)
      Description copied from class: Pointer
      Checks that the memory region is within the bounds of this memory object
      Specified by:
      checkBounds in class Pointer
      Parameters:
      offset - the starting point within this memory region.
      size - the length of the memory region in bytes
    • putAddress

      public void putAddress(long offset, Address value)
      Description copied from class: Pointer
      Writes a native memory address value at the given offset.

      A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

      Specified by:
      putAddress in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be written.
      value - The native address value to be written.
      See Also:
    • getNativeLong

      public final long getNativeLong(long offset)
      Description copied from class: Pointer
      Reads a native long value at the given offset.

      A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

      For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

      Specified by:
      getNativeLong in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be read.
      Returns:
      the native long value at the offset.
      See Also:
    • putNativeLong

      public void putNativeLong(long offset, long value)
      Description copied from class: Pointer
      Writes a native long value at the given offset.

      A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

      For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

      Specified by:
      putNativeLong in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be written.
      value - the native long value to be written.
    • getLong

      public long getLong(long offset)
      Description copied from class: Pointer
      Reads a long (64 bit) value at the given offset.
      Specified by:
      getLong in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be read.
      Returns:
      the long value at the offset.
    • putLong

      public void putLong(long offset, long value)
      Description copied from class: Pointer
      Writes a native long value at the given offset.
      Specified by:
      putLong in class Pointer
      Parameters:
      offset - The offset from the start of the memory this Pointer represents at which the value will be written.
      value - the long value to be written.
    • putInt

      public void putInt(Type type, long offset, long value)
      Description copied from class: Pointer
      Writes an integer of a specific type, at the given offset.
      Specified by:
      putInt in class Pointer
      Parameters:
      type - The integer type.
      offset - The offset from the start of the memory this Pointer represents at which the value will be written.
      value - the int value to be written.
    • getInt

      public long getInt(Type type, long offset)
      Description copied from class: Pointer
      Reads an integer value of the given type, at the given offset.
      Specified by:
      getInt in class Pointer
      Parameters:
      type - Type of integer to read.
      offset - The offset from the start of the memory this Pointer represents at which the value will be read.
      Returns:
      the int value contained in the memory at the offset.
    • slice

      public AbstractMemoryIO slice(long offset)
      Description copied from class: Pointer
      Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
      Specified by:
      slice in class Pointer
      Parameters:
      offset - the offset from the start of the memory this Pointer represents at which the new Pointer will start.
      Returns:
      a Pointer instance representing the new sub-region.
    • slice

      public AbstractMemoryIO slice(long offset, long size)
      Description copied from class: Pointer
      Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
      Specified by:
      slice in class Pointer
      Parameters:
      offset - the offset from the start of the memory this Pointer represents at which the new Pointer will start.
      size - the maximum size of the memory sub-region.
      Returns:
      a Pointer instance representing the new sub-region.
    • transferTo

      public void transferTo(long offset, Pointer other, long otherOffset, long count)
      Description copied from class: Pointer
      Bulk data transfer from one memory location to another.
      Specified by:
      transferTo in class Pointer
      Parameters:
      offset - the offset from the start of the memory location this Pointer represents to begin copying from.
      other - the destination memory location to transfer data to.
      otherOffset - the offset from the start of the memory location the destination Pointer represents to begin copying to.
      count - the number of bytes to transfer.
    • transferFrom

      public void transferFrom(long offset, Pointer other, long otherOffset, long count)
      Description copied from class: Pointer
      Bulk data transfer from one memory location to another.
      Specified by:
      transferFrom in class Pointer
      Parameters:
      offset - the offset from the start of the memory location this Pointer represents to begin copying to.
      other - the destination memory location to transfer data from.
      otherOffset - the offset from the start of the memory location the destination Pointer represents to begin copying from.
      count - the number of bytes to transfer.