Class VarnodeContext

    • Method Detail

      • setDebug

        public void setDebug​(boolean debugOn)
      • getDebug

        public boolean getDebug()
      • setCurrentInstruction

        public void setCurrentInstruction​(Instruction instr)
      • flowEnd

        public void flowEnd​(Address address)
      • flowToAddress

        public void flowToAddress​(Address fromAddr,
                                  Address toAddr)
      • getKnownFlowToAddresses

        public Address[] getKnownFlowToAddresses​(Address toAddr)
      • flowStart

        public void flowStart​(Address fromAddr,
                              Address toAddr)
      • copyToFutureFlowState

        public void copyToFutureFlowState​(Address fromAddr,
                                          Address toAddr)
      • mergeToFutureFlowState

        public boolean mergeToFutureFlowState​(Address fromAddr,
                                              Address toAddr)
      • setFutureRegisterValue

        public void setFutureRegisterValue​(Address address,
                                           RegisterValue regVal)
      • getReturnVarnode

        public Varnode[] getReturnVarnode​(Function targetFunc)
        Parameters:
        targetFunc - function to get a returning varnode for NOTE: this only gets one, unless there is custom storage on the called function there may be bonded ones in the default convention!
        Returns:
        varnode that represents where functions place their return value
      • getStackVarnode

        public Varnode getStackVarnode()
        Returns:
        Varnode that represents the stack register
      • isStackSymbolicSpace

        public boolean isStackSymbolicSpace​(Varnode varnode)
        Return true if this varnode is stored in the symbolic stack space
      • getStackRegister

        public Register getStackRegister()
        Returns:
        Register that represents the stack register
      • isReadOnly

        protected boolean isReadOnly​(Address addr)
        Check if a symbol is read_only.
        Parameters:
        sym - - symbol to check
        addr - - address of the symbol
        Returns:
        true if the block is read_only, and there are no write references.
      • createVarnode

        public Varnode createVarnode​(long value,
                                     int spaceID,
                                     int size)
      • createConstantVarnode

        public Varnode createConstantVarnode​(long value,
                                             int size)
      • createBadVarnode

        public Varnode createBadVarnode()
      • createVarnode

        public Varnode createVarnode​(java.math.BigInteger bigVal,
                                     java.math.BigInteger spaceVal,
                                     int size)
      • putValue

        public void putValue​(Varnode out,
                             Varnode result,
                             boolean mustClear)
      • readExecutableCode

        public boolean readExecutableCode()
      • setReadExecutableCode

        public void setReadExecutableCode()
      • clearReadExecutableCode

        public void clearReadExecutableCode()
      • propogateResults

        public void propogateResults​(boolean clearContext)
        Propogate any results that are in the value cache.
        Parameters:
        clearContext - true if the cache should be cleared. The propogation could be for flow purposes, and the processing of the instruction is finished, so it's effects should be kept.
      • getLastSetLocation

        public Address getLastSetLocation​(Register reg,
                                          java.math.BigInteger bval)
        return the location that this register was last set This is a transient thing, so it should only be used as a particular flow is being processed...
        Parameters:
        reg - register to find last set location
        bval - value to look for to differentiate set locations, null if don't care
        Returns:
        address that the register was set.
      • getLastSetLocation

        public Address getLastSetLocation​(Varnode rvar,
                                          java.math.BigInteger bval)
        return the location that this varnode was last set This is a transient thing, so it should only be used as a particular flow is being processed...
        Parameters:
        reg -
        Returns:
        address that the register was set.
      • getVarnode

        public Varnode getVarnode​(int spaceID,
                                  long offset,
                                  int size)
      • getRegisterVarnodeValue

        public Varnode getRegisterVarnodeValue​(Register reg,
                                               Address fromAddr,
                                               Address toAddr,
                                               boolean signed)
        get the value of a register as a varnode (value, space, size)
        Parameters:
        reg - register to get value for
        address - location for value
        signed - true if signed
        Returns:
        null if the register has no value
      • print

        protected java.lang.String print​(Varnode rvnode)
      • hasValueOverRange

        public boolean hasValueOverRange​(Register reg,
                                         java.math.BigInteger bval,
                                         AddressSet set)
      • copy

        public void copy​(Varnode out,
                         Varnode in,
                         boolean mustClearAll,
                         ContextEvaluator evaluator)
                  throws NotFoundException
        Copy the varnode with as little manipulation as possible. Try to keep whatever partical state there is intact if a real value isn't required.
        Parameters:
        out - varnode to put it in
        in - varnode to copy from.
        evaluator -
        Throws:
        NotFoundException
      • add

        public Varnode add​(Varnode val1,
                           Varnode val2,
                           ContextEvaluator evaluator)
                    throws NotFoundException
        Add two varnodes together to get a new value This could create a new space and return a varnode pointed into that space
        Parameters:
        val1 - first value
        val2 - second value
        Returns:
        varnode that could be a constant, or an offset into a space
        Throws:
        NotFoundException - if any constant is needed not known
      • isRegister

        protected boolean isRegister​(Varnode varnode)
      • getAddressSpace

        public int getAddressSpace​(java.lang.String name)
      • subtract

        public Varnode subtract​(Varnode val1,
                                Varnode val2,
                                ContextEvaluator evaluator)
                         throws NotFoundException
        Subtract two varnodes to get a new value This could create a new space and return a varnode pointed into that space
        Parameters:
        val1 - first value
        val2 - second value
        Returns:
        varnode that could be a constant, or an offset into a space
        Throws:
        NotFoundException - if any constant is needed not known
      • getRegister

        public Register getRegister​(java.lang.String name)
        Description copied from interface: ProcessorContextView
        Get a Register given the name of a register
        Specified by:
        getRegister in interface ProcessorContextView
        Parameters:
        name - the name of the register.
        Returns:
        The register with the given name.
      • getRegisterValue

        public RegisterValue getRegisterValue​(Register register)
        Description copied from interface: ProcessorContextView
        Get the RegisterValue for the given register.
        Specified by:
        getRegisterValue in interface ProcessorContextView
        Parameters:
        register - register to get the value for
        Returns:
        RegisterValue object containing the value of the register if a value exists, otherwise null.
      • getRegisterVarnodeValue

        public Varnode getRegisterVarnodeValue​(Register register)
      • getRegisterVarnode

        public Varnode getRegisterVarnode​(Register register)
      • getRegister

        public Register getRegister​(Varnode vnode)
        Return a register given a varnode
      • getValue

        public java.math.BigInteger getValue​(Register register,
                                             boolean signed)
        Description copied from interface: ProcessorContextView
        Get the contents of a processor register as a BigInteger object
        Specified by:
        getValue in interface ProcessorContextView
        Parameters:
        register - register to get the value for
        Returns:
        a BigInteger object containing the value of the register if a value exists, otherwise null.
      • hasValue

        public boolean hasValue​(Register register)
        Description copied from interface: ProcessorContextView
        Returns true if a value is defined for the given register.
        Specified by:
        hasValue in interface ProcessorContextView
        Parameters:
        register - the register to check for a value.
        Returns:
        true if the given register has a value.
      • setValue

        public void setValue​(Register register,
                             java.math.BigInteger value)
        Description copied from interface: ProcessorContext
        Sets the value for a Register.
        Specified by:
        setValue in interface ProcessorContext
        Parameters:
        register - the register to have its value set
        value - the value for the register (null is not permitted).
      • isSymbol

        public boolean isSymbol​(Varnode node)
      • isSymbolicSpace

        public boolean isSymbolicSpace​(AddressSpace space)
      • isSymbolicSpace

        public boolean isSymbolicSpace​(int spaceID)