Package ghidra.program.model.pcode

# Class Varnode

java.lang.Object
ghidra.program.model.pcode.Varnode

Direct Known Subclasses:
  `VarnodeAST`, `VarnodeOperation`

public class Varnode extends Object
Rawest possible Varnode. Just a variable location and size, not part of a syntax tree. A raw varnode is said to be free, it is not attached to any variable.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Varnode.Join`
  Set of Varnode pieces referred to by a single Varnode in join space as returned by Varnode.decodePieces

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Varnode(Address a, int sz)`
  `Varnode(Address a, int sz, int symbolKey)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(Address addr)`
  Determine if this varnode contains the specified address
  `static Varnode`
  `decode(Decoder decoder, PcodeFactory factory)`
  Decode a Varnode from a stream
  `static Varnode.Join`
  `decodePieces(Decoder decoder)`
  Decode a sequence of Varnodes from "piece" attributes for the current open element.
  `String`
  `encodePiece()`
  Encode details of the Varnode as a formatted string with three colon separated fields.
  `void`
  `encodeRaw(Encoder encoder)`
  Encode just the raw storage info for this Varnode to stream
  `boolean`
  `equals(Object o)`
  `Address`
  `getAddress()`
  `PcodeOp`
  `getDef()`
  `Iterator<PcodeOp>`
  `getDescendants()`
  `HighVariable`
  `getHigh()`
  `PcodeOp`
  `getLoneDescend()`
  If there is only one PcodeOp taking this varnode as input, return it.
  `short`
  `getMergeGroup()`
  `long`
  `getOffset()`
  `Address`
  `getPCAddress()`
  Get the address where this varnode is defined or NO_ADDRESS if this varnode is an input
  `int`
  `getSize()`
  `int`
  `getSpace()`
  `long`
  `getWordOffset()`
  Returns the word offset into the address space this is defined within The word size is defined in the Language's .slaspec file with the "WORDSIZE" argument when DEFINEing a memory SPACE (capitalization is for emphasis; the directives are actually lowercase).
  `int`
  `hashCode()`
  `boolean`
  `hasNoDescend()`
  `boolean`
  `intersects(AddressSetView set)`
  Determine if this varnode intersects the specified address set
  `boolean`
  `intersects(Varnode varnode)`
  Determine if this varnode intersects another varnode.
  `boolean`
  `isAddress()`
  `boolean`
  `isAddrTied()`
  `boolean`
  `isConstant()`
  `boolean`
  `isFree()`
  `boolean`
  `isHash()`
  `boolean`
  `isInput()`
  `boolean`
  `isPersistent()`
  `boolean`
  `isRegister()`
  `boolean`
  `isUnaffected()`
  `boolean`
  `isUnique()`
  `String`
  `toString()`
  `String`
  `toString(Language language)`
  Convert this varnode to an alternate String representation based on a specified language.
  `void`
  `trim()`
  Trim a varnode in a constant space to the correct starting offset.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Varnode

    public Varnode(Address a, int sz)
    Parameters:
      `a` - location varnode attached to
      `sz` - size of varnode

  - ### Varnode

    public Varnode(Address a, int sz, int symbolKey)
    Parameters:
      `a` - location varnode attached to
      `sz` - size of varnode
      `symbolKey` - associated symbol key

- ## Method Details

  - ### getSize

    public int getSize()
    Returns:
      size of the varnode in bytes

  - ### getSpace

    public int getSpace()
    Returns:
      the space this varnode belongs to (ram, register, ...)

  - ### getAddress

    public Address getAddress()
    Returns:
      the address this varnode is attached to

  - ### getPCAddress

    public Address getPCAddress()
    Get the address where this varnode is defined or NO_ADDRESS if this varnode is an input
    Returns:
      the address

  - ### getOffset

    public long getOffset()
    Returns:
      the offset into the address space varnode is defined within

  - ### getWordOffset

    public long getWordOffset()
    Returns the word offset into the address space this is defined within The word size is defined in the Language's .slaspec file with the "WORDSIZE" argument when DEFINEing a memory SPACE (capitalization is for emphasis; the directives are actually lowercase).
    Returns:
      the word offset into the address space this is defined within

  - ### isFree

    public boolean isFree()

  - ### contains

    public boolean contains(Address addr)
    Determine if this varnode contains the specified address
    Parameters:
      `addr` - the address for which to check
    Returns:
      true if this varnode contains the specified address

  - ### intersects

    public boolean intersects(Varnode varnode)
    Determine if this varnode intersects another varnode.
    Parameters:
      `varnode` - other varnode
    Returns:
      true if this varnode intersects the specified varnode

  - ### intersects

    public boolean intersects(AddressSetView set)
    Determine if this varnode intersects the specified address set
    Parameters:
      `set` - address set
    Returns:
      true if this varnode intersects the specified address set

  - ### isAddress

    public boolean isAddress()
    Returns:
      true if this varnode exists in a Memory space (vs. register etc...). Keep in mind this varnode may also correspond to a defined register if true is returned and `isRegister()` return false. Memory-based registers may be indirectly addressed which leads to the distinction with registers within the register space.

  - ### isRegister

    public boolean isRegister()
    Returns:
      true if this varnode exists in a Register type space. If false is returned, keep in mind this varnode may still correspond to a defined register within a memory space. Memory-based registers may be indirectly addressed which leads to the distinction with registers within the register space.

  - ### isConstant

    public boolean isConstant()
    Returns:
      true if this varnode is just a constant number

  - ### isUnique

    public boolean isUnique()
    Returns:
      true if this varnode doesn't exist anywhere. A temporary variable.

  - ### isHash

    public boolean isHash()

  - ### isInput

    public boolean isInput()
    Returns:
      is input to a pcode op

  - ### isPersistent

    public boolean isPersistent()
    Returns:
      is persistent

  - ### isAddrTied

    public boolean isAddrTied()
    Returns:
      is mapped to an address

  - ### isUnaffected

    public boolean isUnaffected()

  - ### getDef

    public PcodeOp getDef()
    Returns:
      get the pcode op this varnode belongs to

  - ### getDescendants

    public Iterator<PcodeOp> getDescendants()
    Returns:
      iterator to all PcodeOp s that take this as input

  - ### getLoneDescend

    public PcodeOp getLoneDescend()
    If there is only one PcodeOp taking this varnode as input, return it. Otherwise return null
    Returns:
      the lone descendant PcodeOp

  - ### hasNoDescend

    public boolean hasNoDescend()
    Returns:
      false if the Varnode has a PcodeOp reading it that is part of function data-flow

  - ### getHigh

    public HighVariable getHigh()
    Returns:
      the high level variable this varnode represents

  - ### getMergeGroup

    public short getMergeGroup()
    Returns:
      the index of the group, within the high containing this, that are forced merged with this

  - ### encodeRaw

    public void encodeRaw(Encoder encoder) throws IOException
    Encode just the raw storage info for this Varnode to stream
    Parameters:
      `encoder` - is the stream encoder
    Throws:
      `IOException` - for errors in the underlying stream

  - ### encodePiece

    public String encodePiece()
    Encode details of the Varnode as a formatted string with three colon separated fields. space:offset:size The name of the address space, the offset of the address as a hex number, and the size field as a decimal number.
    Returns:
      the formatted String

  - ### decode

    public static Varnode decode(Decoder decoder, PcodeFactory factory) throws DecoderException
    Decode a Varnode from a stream
    Parameters:
      `decoder` - is the stream decoder
      `factory` - pcode factory used to create valid pcode
    Returns:
      the new Varnode
    Throws:
      `DecoderException` - if the Varnode is improperly encoded

  - ### decodePieces

    public static Varnode.Join decodePieces(Decoder decoder) throws DecoderException
    Decode a sequence of Varnodes from "piece" attributes for the current open element. The Varnodes are normally associated with an Address in the "join" space. In this virtual space, a contiguous sequence of bytes, at a specific Address, represent a logical value that may physically be split across multiple registers or other storage locations.
    Parameters:
      `decoder` - is the stream decoder
    Returns:
      an array of decoded Varnodes and the logical size
    Throws:
      `DecoderException` - for any errors in the encoding

  - ### trim

    public void trim()
    Trim a varnode in a constant space to the correct starting offset. Constant handles may contain constants of indeterminate size. This is where the size gets fixed, i.e. we mask off the constant to its proper size. A varnode that is ends up in pcode should call this method to ensure that varnodes always contains raw data. On the other hand, varnodes in handles are allowed to have offsets that violate size restrictions.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### toString

    public String toString(Language language)
    Convert this varnode to an alternate String representation based on a specified language.
    Parameters:
      `language` - is the specified Language
    Returns:
      string representation

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`