Package ghidra.program.model.pcode
Class DynamicHash
- java.lang.Object
-
- ghidra.program.model.pcode.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 Summary
Fields Modifier and Type Field Description static int[]
transtable
-
Constructor Summary
Constructors Constructor Description 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 PcodeSyntaxTreeDynamicHash(Varnode root, int method)
Construct a hash of the given Varnode with a specific hash method.DynamicHash(Varnode root, PcodeSyntaxTree fd)
Construct a unique hash for the given Varnode, which must be in a syntax tree.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 varnodestatic long
clearTotalPosition(long h)
static Varnode
findVarnode(PcodeSyntaxTree fd, Address addr, long h)
static void
gatherFirstLevelVars(java.util.ArrayList<Varnode> varlist, PcodeSyntaxTree fd, Address addr, long h)
Address
getAddress()
long
getHash()
static boolean
getIsNotAttached(long h)
static int
getMethodFromHash(long h)
static int
getOpCodeFromHash(long h)
static int
getPositionFromHash(long h)
static int
getSlotFromHash(long h)
static int
getTotalFromHash(long h)
-
-
-
Constructor Detail
-
DynamicHash
public DynamicHash(Varnode root, int method)
Construct a hash of the given Varnode with a specific hash method.- Parameters:
root
- is the given Varnodemethod
- 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.- Parameters:
root
- is the given Varnodefd
- 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- Parameters:
op
- is the given PcodeOpinputIndex
- is the index of the input Varnode to hash
-
-
Method Detail
-
getHash
public long getHash()
-
getAddress
public Address getAddress()
-
findVarnode
public static Varnode findVarnode(PcodeSyntaxTree fd, Address addr, long h)
-
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- Parameters:
instr
- is the instruction referencing the constantvalue
- of the constant- Returns:
- array of hash values (may be zero length)
-
-