Package jnr.ffi

Class Pointer

  • Direct Known Subclasses:
    AbstractMemoryIO

    public abstract class Pointer
    extends java.lang.Object
    A native memory address. This class provides operations on a native memory address. Most Pointerinstances will represent direct memory (that is, a fixed address in the process address space, directly accessible by native code), however, it is possible to wrap a java byte array in a Pointerinstance to pass to a native function as a memory address. See isDirect() for more information.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Pointer​(Runtime runtime, long address, boolean direct)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      long address()
      Gets the native address of this memory object (optional operation).
      abstract java.lang.Object array()
      Returns the array that backs this pointer.
      abstract int arrayLength()
      Returns the length of this pointer's backing array that is used by this pointer.
      abstract int arrayOffset()
      Returns the offset within this pointer's backing array of the first element.
      abstract void checkBounds​(long offset, long length)
      Checks that the memory region is within the bounds of this memory object
      abstract void get​(long offset, byte[] dst, int idx, int len)
      Bulk get method for multiple byte values.
      abstract void get​(long offset, double[] dst, int idx, int len)
      Bulk get method for multiple double values.
      abstract void get​(long offset, float[] dst, int idx, int len)
      Bulk get method for multiple float values.
      abstract void get​(long offset, int[] dst, int idx, int len)
      Bulk get method for multiple int values.
      abstract void get​(long offset, long[] dst, int idx, int len)
      Bulk get method for multiple long values.
      abstract void get​(long offset, short[] dst, int idx, int len)
      Bulk get method for multiple short values.
      void get​(long offset, Pointer[] dst, int idx, int len)
      Bulk get method for multiple Pointer values.
      abstract long getAddress​(long offset)
      Reads a native memory address value at the given offset.
      abstract byte getByte​(long offset)
      Reads an byte (8 bit) value at the given offset.
      abstract double getDouble​(long offset)
      Reads a double (64 bit) value at the given offset.
      abstract float getFloat​(long offset)
      Reads a float (32 bit) value at the given offset.
      abstract int getInt​(long offset)
      Reads an int (32 bit) value at the given offset.
      abstract long getInt​(Type type, long offset)
      Reads an integer value of the given type, at the given offset.
      abstract long getLong​(long offset)
      Reads a long (64 bit) value at the given offset.
      abstract long getLongLong​(long offset)
      Reads a long (64 bit) value at the given offset.
      abstract long getNativeLong​(long offset)
      Reads a native long value at the given offset.
      Pointer[] getNullTerminatedPointerArray​(long offset)  
      java.lang.String[] getNullTerminatedStringArray​(long offset)  
      abstract Pointer getPointer​(long offset)
      Reads an Pointer value at the given offset.
      abstract Pointer getPointer​(long offset, long size)
      Reads an Pointer value at the given offset.
      Runtime getRuntime()
      Gets the Runtime this Pointer instance belongs to.
      abstract short getShort​(long offset)
      Reads a short (16 bit) value at the given offset.
      abstract java.lang.String getString​(long offset)
      Reads an String value at the given offset.
      abstract java.lang.String getString​(long offset, int maxLength, java.nio.charset.Charset cs)
      Reads a String value at the given offset, using a specific Charset
      abstract boolean hasArray()
      Indicates whether this Pointer instance is backed by an array.
      abstract int indexOf​(long offset, byte value)
      Returns the location of a byte value within the memory area represented by this Pointer.
      abstract int indexOf​(long offset, byte value, int maxlen)
      Returns the location of a byte value within the memory area represented by this Pointer.
      boolean isDirect()
      Indicates whether or not this memory object represents a native memory address.
      static Pointer newIntPointer​(Runtime runtime, long address)
      Wraps an integer value in an opaque Pointer instance.
      abstract void put​(long offset, byte[] src, int idx, int len)
      Bulk put method for multiple byte values.
      abstract void put​(long offset, double[] src, int idx, int len)
      Bulk put method for multiple double values.
      abstract void put​(long offset, float[] src, int idx, int len)
      Bulk put method for multiple float values.
      abstract void put​(long offset, int[] src, int idx, int len)
      Bulk put method for multiple int values.
      abstract void put​(long offset, long[] src, int idx, int len)
      Bulk put method for multiple long values.
      abstract void put​(long offset, short[] src, int idx, int len)
      Bulk put method for multiple short values.
      void put​(long offset, Pointer[] src, int idx, int len)
      Bulk put method for multiple Pointer values.
      abstract void putAddress​(long offset, long value)
      Writes a native memory address value at the given offset.
      abstract void putAddress​(long offset, Address value)
      Writes a native memory address value at the given offset.
      abstract void putByte​(long offset, byte value)
      Writes a byte (8 bit) value at the given offset.
      abstract void putDouble​(long offset, double value)
      Writes a double (64 bit, double precision) value at the given offset.
      abstract void putFloat​(long offset, float value)
      Writes a float (32 bit, single precision) value at the given offset.
      abstract void putInt​(long offset, int value)
      Writes an int (32 bit) value at the given offset.
      abstract void putInt​(Type type, long offset, long value)
      Writes an integer of a specific type, at the given offset.
      abstract void putLong​(long offset, long value)
      Writes a native long value at the given offset.
      abstract void putLongLong​(long offset, long value)
      Writes a long (64 bit) value at the given offset.
      abstract void putNativeLong​(long offset, long value)
      Writes a native long value at the given offset.
      abstract void putPointer​(long offset, Pointer value)
      Writes a Pointer value at the given offset.
      abstract void putShort​(long offset, short value)
      Writes a short (16 bit) value at the given offset.
      abstract void putString​(long offset, java.lang.String string, int maxLength, java.nio.charset.Charset cs)
      Writes a String value at the given offset, using a specific Charset
      abstract void setMemory​(long offset, long size, byte value)
      Sets the value of each byte in the memory area represented by this Pointer.
      abstract long size()
      Gets the size of this memory object in bytes (optional operation).
      abstract Pointer slice​(long offset)
      Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
      abstract Pointer slice​(long offset, long size)
      Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
      java.lang.String toString()  
      abstract void transferFrom​(long offset, Pointer src, long srcOffset, long count)
      Bulk data transfer from one memory location to another.
      abstract void transferTo​(long offset, Pointer dst, long dstOffset, long count)
      Bulk data transfer from one memory location to another.
      static Pointer wrap​(Runtime runtime, long address)
      Wraps a native address in a Pointer instance.
      static Pointer wrap​(Runtime runtime, long address, long size)
      Wraps a native address in a Pointer instance.
      static Pointer wrap​(Runtime runtime, java.nio.ByteBuffer buffer)
      Wraps an existing ByteBuffer in a Pointer implementation so it can be used as a parameter to native functions.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Pointer

        protected Pointer​(Runtime runtime,
                          long address,
                          boolean direct)
    • Method Detail

      • wrap

        public static Pointer wrap​(Runtime runtime,
                                   long address)
        Wraps a native address in a Pointer instance.
        Parameters:
        runtime - the Runtime of the pointer.
        address - the address to wrap in a Pointer instance.
        Returns:
        a Pointer instance.
      • wrap

        public static Pointer wrap​(Runtime runtime,
                                   long address,
                                   long size)
        Wraps a native address in a Pointer instance.
        Parameters:
        runtime - the Runtime of the pointer.
        address - the address to wrap in a Pointer instance.
        size - the size of the native memory region.
        Returns:
        a Pointer instance.
      • wrap

        public static Pointer wrap​(Runtime runtime,
                                   java.nio.ByteBuffer buffer)
        Wraps an existing ByteBuffer in a Pointer implementation so it can be used as a parameter to native functions.

        Wrapping a ByteBuffer is only neccessary if the native function parameter was declared as a Pointer. The if the method will always be used with ByteBuffer parameters, then the parameter type can just be declared as ByteBuffer and the conversion will be performed automatically.

        Parameters:
        runtime - the Runtime the wrapped ByteBuffer will be used with.
        buffer - the ByteBuffer to wrap.
        Returns:
        a Pointer instance that will proxy all accesses to the ByteBuffer contents.
      • newIntPointer

        public static Pointer newIntPointer​(Runtime runtime,
                                            long address)
        Wraps an integer value in an opaque Pointer instance. This is a Pointer instance that throws errors when any of the memory access methods are used, but can be otherwise used interchangeably with a real Pointer.
        Parameters:
        runtime - the Runtime of the pointer.
        address - the address to wrap in a Pointer instance.
        Returns:
        a Pointer instance.
      • isDirect

        public final boolean isDirect()
        Indicates whether or not this memory object represents a native memory address.

        Memory objects can be either direct (representing native memory), or non-direct (representing java heap memory).

        Non-direct memory objects can still be passed to native functions as pointer (void *, char *, etc) parameters, but the java memory will first be copied to a temporary native memory area. The temporary memory area will then be used as the parameter value for the call. If needed, the java memory will be automatically reloaded from the temporary native memory after the native function returns.

        Note: the transient nature of the temporary memory allocated for non-direct memory means native functions which store the address value passed to them will fail in unpredictable ways when using non-direct memory. You will need to explicitly allocate direct memory to use those types of functions.

        Returns:
        true if, and only if, this memory object represents a native address.
      • address

        public final long address()
        Gets the native address of this memory object (optional operation).
        Returns:
        the native address of this memory object. If this object is not a native memory address, an address of zero is returned.
      • getRuntime

        public final Runtime getRuntime()
        Gets the Runtime this Pointer instance belongs to.
        Returns:
        the Runtime instance of this Pointer.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • size

        public abstract long size()
        Gets the size of this memory object in bytes (optional operation).
        Returns:
        the size of the memory area this Pointer points to. If the size is unknown, Long.MAX_VALUE is returned}.
      • hasArray

        public abstract boolean hasArray()
        Indicates whether this Pointer instance is backed by an array.
        Returns:
        true if, and only if, this memory object is backed by an array
      • array

        public abstract java.lang.Object array()
        Returns the array that backs this pointer.
        Returns:
        The array that backs this pointer.
        Throws:
        java.lang.UnsupportedOperationException - if this pointer does not have a backing array.
      • arrayOffset

        public abstract int arrayOffset()
        Returns the offset within this pointer's backing array of the first element.
        Returns:
        The offset of the first element on the backing array
        Throws:
        java.lang.UnsupportedOperationException - if this pointer does not have a backing array
      • arrayLength

        public abstract int arrayLength()
        Returns the length of this pointer's backing array that is used by this pointer.
        Returns:
        The length of the backing array used
        Throws:
        java.lang.UnsupportedOperationException - if this pointer does not have a backing array
      • getByte

        public abstract byte getByte​(long offset)
        Reads an byte (8 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the byte value at the offset.
      • getShort

        public abstract short getShort​(long offset)
        Reads a short (16 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the short value at the offset.
      • getInt

        public abstract int getInt​(long offset)
        Reads an int (32 bit) value at the given offset.
        Parameters:
        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.
      • getLong

        public abstract long getLong​(long offset)
        Reads a long (64 bit) value at the given offset.
        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.
      • getLongLong

        public abstract long getLongLong​(long offset)
        Reads a long (64 bit) value at the given offset.
        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.
      • getFloat

        public abstract float getFloat​(long offset)
        Reads a float (32 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the float value at the offset.
      • getDouble

        public abstract double getDouble​(long offset)
        Reads a double (64 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the double value at the offset.
      • getNativeLong

        public abstract long getNativeLong​(long offset)
        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.

        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:
        NativeLong
      • getInt

        public abstract long getInt​(Type type,
                                    long offset)
        Reads an integer value of the given type, at the given offset.
        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.
      • putByte

        public abstract void putByte​(long offset,
                                     byte value)
        Writes a byte (8 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be written.
        value - the byte value to be written.
      • putShort

        public abstract void putShort​(long offset,
                                      short value)
        Writes a short (16 bit) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be written.
        value - the short value to be written.
      • putInt

        public abstract void putInt​(long offset,
                                    int value)
        Writes an int (32 bit) value at the given offset.
        Parameters:
        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.
      • putLong

        public abstract void putLong​(long offset,
                                     long value)
        Writes a native long value at the given offset.
        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.
      • putLongLong

        public abstract void putLongLong​(long offset,
                                         long value)
        Writes a long (64 bit) value at the given offset.
        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.
      • putFloat

        public abstract void putFloat​(long offset,
                                      float value)
        Writes a float (32 bit, single precision) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be written.
        value - the float value to be written.
      • putDouble

        public abstract void putDouble​(long offset,
                                       double value)
        Writes a double (64 bit, double precision) value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be written.
        value - the double value to be written.
      • putNativeLong

        public abstract void putNativeLong​(long offset,
                                           long value)
        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.

        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.
      • putInt

        public abstract void putInt​(Type type,
                                    long offset,
                                    long value)
        Writes an integer of a specific type, at the given offset.
        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.
      • getAddress

        public abstract long getAddress​(long offset)
        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.

        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:
        Address
      • putAddress

        public abstract void putAddress​(long offset,
                                        long value)
        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.

        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:
        Address
      • putAddress

        public abstract void putAddress​(long offset,
                                        Address value)
        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.

        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:
        Address
      • get

        public abstract void get​(long offset,
                                 byte[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple byte values. This method reads multiple byte values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - the array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 byte[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple byte values. This method writes multiple byte values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • get

        public abstract void get​(long offset,
                                 short[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple short values. This method reads multiple short values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 short[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple short values. This method writes multiple short values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • get

        public abstract void get​(long offset,
                                 int[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple int values. This method reads multiple int values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 int[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple int values. This method writes multiple int values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • get

        public abstract void get​(long offset,
                                 long[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple long values. This method reads multiple long values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 long[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple long values. This method writes multiple long values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • get

        public abstract void get​(long offset,
                                 float[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple float values. This method reads multiple float values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 float[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple float values. This method writes multiple float values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • get

        public abstract void get​(long offset,
                                 double[] dst,
                                 int idx,
                                 int len)
        Bulk get method for multiple double values. This method reads multiple double values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public abstract void put​(long offset,
                                 double[] src,
                                 int idx,
                                 int len)
        Bulk put method for multiple double values. This method writes multiple double values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the dst array to begin reading values.
        len - the number of values to be written.
      • getPointer

        public abstract Pointer getPointer​(long offset)
        Reads an Pointer value at the given offset.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the Pointer value read from memory.
      • getPointer

        public abstract Pointer getPointer​(long offset,
                                           long size)
        Reads an Pointer value at the given offset.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the value will be read.
        size - the maximum size of the memory location the returned Pointer represents.
        Returns:
        the Pointer value read from memory.
      • putPointer

        public abstract void putPointer​(long offset,
                                        Pointer value)
        Writes a Pointer value at the given offset.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the value will be written.
        value - the Pointer value to be written to memory.
      • getString

        public abstract java.lang.String getString​(long offset)
        Reads an String value at the given offset.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the value will be read.
        Returns:
        the String value read from memory.
      • getString

        public abstract java.lang.String getString​(long offset,
                                                   int maxLength,
                                                   java.nio.charset.Charset cs)
        Reads a String value at the given offset, using a specific Charset
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the value will be read.
        maxLength - the maximum size of memory to search for a NUL byte.
        cs - the Charset to use to decode the string.
        Returns:
        the String value read from memory.
      • putString

        public abstract void putString​(long offset,
                                       java.lang.String string,
                                       int maxLength,
                                       java.nio.charset.Charset cs)
        Writes a String value at the given offset, using a specific Charset
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the value will be written.
        string - the string to be written.
        maxLength - the maximum size of memory to use to store the string.
        cs - the Charset to use to decode the string.
      • slice

        public abstract Pointer slice​(long offset)
        Creates a new Pointer representing a sub-region of the memory referred to by this 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 abstract Pointer slice​(long offset,
                                      long size)
        Creates a new Pointer representing a sub-region of the memory referred to by this 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 abstract void transferTo​(long offset,
                                        Pointer dst,
                                        long dstOffset,
                                        long count)
        Bulk data transfer from one memory location to another.
        Parameters:
        offset - the offset from the start of the memory location this Pointer represents to begin copying from.
        dst - the destination memory location to transfer data to.
        dstOffset - 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 abstract void transferFrom​(long offset,
                                          Pointer src,
                                          long srcOffset,
                                          long count)
        Bulk data transfer from one memory location to another.
        Parameters:
        offset - the offset from the start of the memory location this Pointer represents to begin copying to.
        src - the destination memory location to transfer data from.
        srcOffset - the offset from the start of the memory location the destination Pointer represents to begin copying from.
        count - the number of bytes to transfer.
      • checkBounds

        public abstract void checkBounds​(long offset,
                                         long length)
        Checks that the memory region is within the bounds of this memory object
        Parameters:
        offset - the starting point within this memory region.
        length - the length of the memory region in bytes
        Throws:
        java.lang.IndexOutOfBoundsException - if the memory region is not within the bounds.
      • setMemory

        public abstract void setMemory​(long offset,
                                       long size,
                                       byte value)
        Sets the value of each byte in the memory area represented by this Pointer. to a specified value.
        Parameters:
        offset - the offset from the start of the memory location this Pointer represents to begin writing to.
        size - the number of bytes to set to the value.
        value - the value to set each byte to.
      • indexOf

        public abstract int indexOf​(long offset,
                                    byte value)
        Returns the location of a byte value within the memory area represented by this 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.
      • indexOf

        public abstract int indexOf​(long offset,
                                    byte value,
                                    int maxlen)
        Returns the location of a byte value within the memory area represented by this Pointer.
        Parameters:
        offset - the offset from the start of the memory location this Pointer represents to begin searching.
        value - the byte value to locate.
        maxlen - the maximum number of bytes to search for the desired value.
        Returns:
        the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
      • get

        public void get​(long offset,
                        Pointer[] dst,
                        int idx,
                        int len)
        Bulk get method for multiple Pointer values. This method reads multiple Pointer values from consecutive addresses, beginning at the given offset, and stores them in an array.
        Parameters:
        offset - The offset from the start of the memory this Pointer represents at which the first value will be read.
        dst - The array into which values are to be stored.
        idx - the start index in the dst array to begin storing the values.
        len - the number of values to be read.
      • put

        public void put​(long offset,
                        Pointer[] src,
                        int idx,
                        int len)
        Bulk put method for multiple Pointer values. This method writes multiple Pointer values to consecutive addresses, beginning at the given offset, from an array.
        Parameters:
        offset - the offset from the start of the memory this Pointer represents at which the first value will be written.
        src - the array to get values from.
        idx - the start index in the src array to begin reading values.
        len - the number of values to be written.
      • getNullTerminatedStringArray

        public java.lang.String[] getNullTerminatedStringArray​(long offset)
      • getNullTerminatedPointerArray

        public Pointer[] getNullTerminatedPointerArray​(long offset)