Class ArithmeticVarnodeEvaluator<T>

java.lang.Object
ghidra.pcode.eval.AbstractVarnodeEvaluator<T>
ghidra.pcode.eval.ArithmeticVarnodeEvaluator<T>
Type Parameters:
T - the type of values resulting from evaluation
All Implemented Interfaces:
VarnodeEvaluator<T>

public abstract class ArithmeticVarnodeEvaluator<T> extends AbstractVarnodeEvaluator<T>
An abstract implementation of VarnodeEvaluator that evaluates ops using a bound PcodeArithmetic.
  • Constructor Details

    • ArithmeticVarnodeEvaluator

      public ArithmeticVarnodeEvaluator(PcodeArithmetic<T> arithmetic)
      Construct an evaluator
      Parameters:
      arithmetic - the arithmetic for computing p-code op outputs
  • Method Details

    • catenate

      public static <T> T catenate(PcodeArithmetic<T> arithmetic, int sizeTotal, T upper, T lower, int sizeLower)
      A convenience for concatenating two varnodes

      There is no p-code op for catenation, but it is easily achieved as one might do in C or SLEIGH: shift the left piece then or it with the right piece.

      Type Parameters:
      T - the type of values
      Parameters:
      arithmetic - the p-code arithmetic for values of type T
      sizeTotal - the expected output size in bytes
      upper - the value of the left (more significant) piece
      lower - the value of the right (less significant) piece
      sizeLower - the size of the lower piece
      Returns:
      the result of concatenation
    • catenate

      protected T catenate(int sizeTotal, T upper, T lower, int sizeLower)
      Description copied from class: AbstractVarnodeEvaluator
      Concatenate the given values
      Specified by:
      catenate in class AbstractVarnodeEvaluator<T>
      Parameters:
      sizeTotal - the expected output size in bytes
      upper - the value of the left (more significant) piece
      lower - the value of the right (less significant) piece
      sizeLower - the size of the lower piece
      Returns:
      the result of concatenation
    • evaluateStorage

      public T evaluateStorage(Program program, VariableStorage storage)
      Description copied from interface: VarnodeEvaluator
      Evaluate variable storage

      Each varnode is evaluated as in VarnodeEvaluator.evaluateStorage(Program, VariableStorage) and then concatenated. The lower-indexed varnodes in storage are the more significant pieces, similar to big endian.

      Parameters:
      program - the program containing the variable storage
      storage - the storage
      Returns:
      the value of the storage
    • evaluateConstant

      protected T evaluateConstant(long value, int size)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a constant
      Specified by:
      evaluateConstant in class AbstractVarnodeEvaluator<T>
      Parameters:
      value - the constant value
      size - the size of the value in bytes
      Returns:
      the value as a AbstractVarnodeEvaluator
    • evaluateAbstract

      protected T evaluateAbstract(Program program, AddressSpace space, T offset, int size, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a variable whose offset is of type AbstractVarnodeEvaluator

      The three parameters space, offset, and size imitate the varnode triple, except that the offset is abstract. This is typically invoked for a PcodeOp.LOAD, i.e., a dereference.

      Specified by:
      evaluateAbstract in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      space - the address space of the variable
      offset - the offset of the variable
      size - the size of the variable in bytes
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the value
    • evaluateUnaryOp

      protected T evaluateUnaryOp(Program program, PcodeOp op, UnaryOpBehavior unOp, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a unary op

      This evaluates the input varnode then computes the output value.

      Specified by:
      evaluateUnaryOp in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      op - the op whose output to evaluate
      unOp - the concrete behavior of the op
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the output value
    • evaluateBinaryOp

      protected T evaluateBinaryOp(Program program, PcodeOp op, BinaryOpBehavior binOp, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a binary op

      This evaluates the input varnodes then computes the output value.

      Specified by:
      evaluateBinaryOp in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      op - the op whose output to evaluate
      binOp - the concrete behavior of the op
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the output value
    • evaluatePtrAdd

      protected T evaluatePtrAdd(Program program, PcodeOp op, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a PcodeOp.PTRADD op
      Specified by:
      evaluatePtrAdd in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      op - the op whose output to evaluate
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the output value
    • evaluatePtrSub

      protected T evaluatePtrSub(Program program, PcodeOp op, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a PcodeOp.PTRSUB op
      Specified by:
      evaluatePtrSub in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      op - the op whose output to evaluate
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the output value
    • evaluateLoad

      protected T evaluateLoad(Program program, PcodeOp op, Map<Varnode,T> already)
      Description copied from class: AbstractVarnodeEvaluator
      Evaluate a PcodeOp.LOAD op
      Specified by:
      evaluateLoad in class AbstractVarnodeEvaluator<T>
      Parameters:
      program - the program defining the static context
      op - the op whose output to evaluate
      already - a cache of already-evaluated varnodes and their values
      Returns:
      the output value