Class VariableDB

    • Method Detail

      • isValid

        public boolean isValid()
        Description copied from interface: Variable
        Verify that the variable is valid (i.e., storage is valid and size matches variable data type size)
        Specified by:
        isValid in interface Variable
        Returns:
        true if variable is valid
      • getProgram

        public Program getProgram()
        Description copied from interface: Variable
        Returns the program that contains this variable or is the intended target
        Specified by:
        getProgram in interface Variable
        Returns:
        the program.
      • getDataType

        public DataType getDataType()
        Description copied from interface: Variable
        Get the Data Type of this variable
        Specified by:
        getDataType in interface Variable
        Returns:
        the data type of the variable
      • setDataType

        public void setDataType​(DataType type,
                                VariableStorage newStorage,
                                boolean force,
                                SourceType source)
                         throws InvalidInputException,
                                VariableSizeException
        Description copied from interface: Variable
        Set the Data Type of this variable and the associated storage whose size matches the data type length.

        NOTE: The storage and source are ignored if the function does not have custom storage enabled.

        Specified by:
        setDataType in interface Variable
        Parameters:
        type - the data type
        newStorage - properly sized storage for the new data type
        force - overwrite conflicting variables
        source - variable storage source (used only for function parameters and return)
        Throws:
        InvalidInputException - if data type is not a fixed length or violates storage constraints.
        VariableSizeException - if force is false and data type size causes a conflict with other variables
      • setDataType

        public void setDataType​(DataType type,
                                boolean alignStack,
                                boolean force,
                                SourceType source)
                         throws InvalidInputException
        Description copied from interface: Variable
        Set the Data Type of this variable. The given dataType must have a fixed length.
        Specified by:
        setDataType in interface Variable
        Parameters:
        type - the data type
        force - overwrite conflicting variables
        source - signature source
        Throws:
        InvalidInputException - if data type is not a fixed length or violates storage constraints.
        VariableSizeException - if force is false and data type size causes a conflict with other variables
      • setDataType

        public void setDataType​(DataType type,
                                SourceType source)
                         throws InvalidInputException
        Description copied from interface: Variable
        Set the Data Type of this variable using the default alignment behavior (implementation specific). The given dataType must have a fixed length. If contained within a stack-frame, data-type size will be constrained by existing variables (e.g., equivalent to force=false) Note: stack offset will be maintained for stack variables.
        Specified by:
        setDataType in interface Variable
        Parameters:
        type - the data type
        source - signature source
        Throws:
        InvalidInputException - if data type is not a fixed length or violates storage constraints.
        VariableSizeException - if data type size causes a conflict with other variables
        See Also:
        #setDataType(DataType, boolean)
      • getName

        public java.lang.String getName()
        Description copied from interface: Variable
        Get the Name of this variable or null if not assigned or not-applicable
        Specified by:
        getName in interface Variable
        Returns:
        the name of the variable
      • getLength

        public int getLength()
        Description copied from interface: Variable
        Get the length of this variable
        Specified by:
        getLength in interface Variable
        Returns:
        the length of the variable
      • getComment

        public java.lang.String getComment()
        Description copied from interface: Variable
        Get the Comment for this variable
        Specified by:
        getComment in interface Variable
        Returns:
        the comment
      • setComment

        public void setComment​(java.lang.String comment)
        Description copied from interface: Variable
        Set the comment for this variable
        Specified by:
        setComment in interface Variable
        Parameters:
        comment - the comment
      • getFunction

        public Function getFunction()
        Description copied from interface: Variable
        Returns the function that contains this Variable. May be null if the variable is not in a function.
        Specified by:
        getFunction in interface Variable
      • getSymbol

        public Symbol getSymbol()
        Specified by:
        getSymbol in interface Variable
        Returns:
        the symbol associated with this variable or null if no symbol associated. Certain dynamic variables such as auto-parameters do not have a symbol.
      • toString

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

        public SourceType getSource()
        Description copied from interface: Variable
        Get the source of this variable
        Specified by:
        getSource in interface Variable
        Returns:
        the source of this variable
      • getVariableStorage

        public VariableStorage getVariableStorage()
        Description copied from interface: Variable
        Get the variable storage associated with this variable.
        Specified by:
        getVariableStorage in interface Variable
        Returns:
        the variable storage for this variable
      • getFirstStorageVarnode

        public Varnode getFirstStorageVarnode()
        Description copied from interface: Variable
        Get the first storage varnode for this variable
        Specified by:
        getFirstStorageVarnode in interface Variable
        Returns:
        the first storage varnode associated with this variable
        See Also:
        #getStorageElements()
      • getLastStorageVarnode

        public Varnode getLastStorageVarnode()
        Description copied from interface: Variable
        Get the last storage varnode for this variable
        Specified by:
        getLastStorageVarnode in interface Variable
        Returns:
        the last storage varnode associated with this variable
        See Also:
        #getStorageElements()
      • hasStackStorage

        public boolean hasStackStorage()
        Specified by:
        hasStackStorage in interface Variable
        Returns:
        true if this variable uses simple or compound storage which contains a stack element. If true, the last storage varnode will always be the stack element.
        See Also:
        Variable.getLastStorageVarnode()
      • getRegister

        public Register getRegister()
        Specified by:
        getRegister in interface Variable
        Returns:
        first storage register associated with this variable, else null is returned. A variable with compound storage may have more than one register or other storage in addition to the register returned by this method.
        See Also:
        Variable.isRegisterVariable()
      • getRegisters

        public java.util.List<Register> getRegisters()
        Specified by:
        getRegisters in interface Variable
        Returns:
        all storage register(s) associated with this variable, else null is returned if no registers are used. A variable with compound storage may have more than one register or other storage in addition to the register(s) returned by this method.
        See Also:
        Variable.isRegisterVariable(), Variable.isCompoundVariable()
      • getMinAddress

        public Address getMinAddress()
        Specified by:
        getMinAddress in interface Variable
        Returns:
        the minimum address corresponding to the first varnode of this storage or null if this is a special empty storage: #BAD_STORAGE, #UNASSIGNED_STORAGE, #VOID_STORAGE
      • isMemoryVariable

        public boolean isMemoryVariable()
        Specified by:
        isMemoryVariable in interface Variable
        Returns:
        true if this is a simple variable consisting of a single storage memory element which will be returned by either the Variable.getFirstStorageVarnode() or getStorageElements() methods.
      • isUniqueVariable

        public boolean isUniqueVariable()
        Specified by:
        isUniqueVariable in interface Variable
        Returns:
        true if this is a simple variable consisting of a single storage unique/hash element which will be returned by either the Variable.getFirstStorageVarnode() or getStorageElements() methods. The unique hash can be obtained from the storage address offset corresponding to the single storage element.
      • isCompoundVariable

        public boolean isCompoundVariable()
        Specified by:
        isCompoundVariable in interface Variable
        Returns:
        true if this variable uses compound storage consisting of two or more storage elements which will be returned by the getStorageElements() method. Compound variables will always use a register(s) optionally followed by other storage (i.e., stack).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Variable otherVar)
        Specified by:
        compareTo in interface java.lang.Comparable<Variable>
      • isEquivalent

        public boolean isEquivalent​(Variable otherVar)
        Specified by:
        isEquivalent in interface Variable
        Returns:
        true if the specified variable is equivalent to this variable