Class DynamicHash

  • public class DynamicHash
    extends java.lang.Object
    A hash utility to uniquely identify a temporary Varnode in data-flow Most Varnodes can be identified within the data-flow graph by their storage address and the address of the PcodeOp that defines them. For temporary registers, this does not work because the storage address is ephemeral. This class allows Varnodes like temporary registers (and constants) to be robustly identified by hashing details of the local data-flow. This class, when presented with a Varnode (via constructor), calculates a hash (getHash()) and an address (getAddress()) of the PcodeOp most closely associated with the Varnode, either the defining op or the op directly reading the Varnode. There are actually four hash variants that can be calculated, labeled 0, 1, 2, or 3, which incrementally hash in a larger portion of data-flow.
    • Field Detail

      • transtable

        public static final int[] transtable
    • Constructor Detail

      • DynamicHash

        public DynamicHash​(Varnode root,
                           int method)
        Construct a hash of the given Varnode with a specific hash method.
        root - is the given Varnode
        method - is the method (0, 1, 2, 3)
      • DynamicHash

        public DynamicHash​(Varnode root,
                           PcodeSyntaxTree fd)
        Construct a unique hash for the given Varnode, which must be in a syntax tree. The hash method is cycled into a uniquely identifying one is found.
        root - is the given Varnode
        fd - is the PcodeSyntaxTree containing the Varnode
      • DynamicHash

        public DynamicHash​(PcodeOp op,
                           int inputIndex)
        Construct a level 0 hash on the input Varnode to the given PcodeOp The PcodeOp can be raw, no linked into a PcodeSyntaxTree
        op - is the given PcodeOp
        inputIndex - is the index of the input Varnode to hash
    • Method Detail

      • getHash

        public long getHash()
      • getAddress

        public Address getAddress()
      • gatherFirstLevelVars

        public static void gatherFirstLevelVars​(java.util.ArrayList<Varnode> varlist,
                                                PcodeSyntaxTree fd,
                                                Address addr,
                                                long h)
      • getSlotFromHash

        public static int getSlotFromHash​(long h)
      • getMethodFromHash

        public static int getMethodFromHash​(long h)
      • getOpCodeFromHash

        public static int getOpCodeFromHash​(long h)
      • getPositionFromHash

        public static int getPositionFromHash​(long h)
      • getTotalFromHash

        public static int getTotalFromHash​(long h)
      • getIsNotAttached

        public static boolean getIsNotAttached​(long h)
      • clearTotalPosition

        public static long clearTotalPosition​(long h)
      • calcConstantHash

        public static long[] calcConstantHash​(Instruction instr,
                                              long value)
        Given a constant value accessed as an operand by a particular instruction, calculate a (level 0) hash for (any) corresponding constant varnode
        instr - is the instruction referencing the constant
        value - of the constant
        array of hash values (may be zero length)