Class ValueLocation
This is an analog to VariableStorage
, except that this records the actual storage
location of the evaluated variable or expression. This does not incorporate storage of
intermediate dereferenced values. For example, suppose R0 = 0xdeadbeef
, and we want to
evaluate *:4 R0
. The storage would be ram:deadbeef:4
, not
R0,ram:deadbeef:4
.
-
Constructor Summary
ConstructorDescriptionValueLocation
(Varnode... nodes) Construct a location from a list of varnodesValueLocation
(List<Varnode> nodes) Construct a location from a list of varnodes -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueLocation
fromConst
(long value, int size) Generate the "location" of a constantstatic ValueLocation
fromVarnode
(Address address, int size) Generate a location from a varnodeGet the address of the first varnodegetConst()
If the location represents a constant, get its valueintOr
(ValueLocation that) Apply aPcodeOp.INT_OR
operatorboolean
isEmpty()
Check if this location includes any varnodesint
Get the number of varnodes for this locationshiftLeft
(int amount) Apply aPcodeOp.INT_LEFT
operatorint
size()
Get the total size of this location in bytestoString()
Render this location as a string, substituting registers where applicablestatic String
vnToString
(Varnode vn, Language language)
-
Constructor Details
-
ValueLocation
Construct a location from a list of varnodesAny leading varnodes which are constant 0s are removed.
- Parameters:
nodes
- the varnodes
-
ValueLocation
Construct a location from a list of varnodesAny leading varnodes which are constant 0s are removed.
- Parameters:
nodes
- the varnodes
-
-
Method Details
-
vnToString
-
fromConst
Generate the "location" of a constant- Parameters:
value
- the valuesize
- the size of the constant in bytes- Returns:
- the "location"
-
fromVarnode
Generate a location from a varnode- Parameters:
address
- the dynamic address of the variablesize
- the size of the variable in bytes- Returns:
- the location
-
nodeCount
public int nodeCount()Get the number of varnodes for this location- Returns:
- the count
-
getAddress
Get the address of the first varnode- Returns:
- the address, or null if this location has no varnodes
-
toString
Render this location as a string, substituting registers where applicable- Parameters:
language
- the optional language for register substitution- Returns:
- the string
-
toString
-
intOr
Apply aPcodeOp.INT_OR
operatorThere is a very restrictive set of constraints for which this yields a non-null location. If either this or that is empty, the other is returned. Otherwise, the varnodes are arranged in pairs by taking one from each storage starting at the right, or least-significant varnode. Each pair must match in length, and one of the pair must be a constant zero. The non-zero varnode is taken. The unpaired varnodes to the left, if any, are all taken. If any pair does not match in length, or if neither is zero, the resulting location is null. This logic is to ensure location information is accrued during concatenation.
- Parameters:
that
- the other location- Returns:
- the location
-
getConst
If the location represents a constant, get its value- Returns:
- the constant value
-
shiftLeft
Apply aPcodeOp.INT_LEFT
operatorThis requires the shift amount to represent an integral number of bytes. Otherwise, the result is null. This simply inserts a constant zero to the right, having the number of bytes indicated by the shift amount. This logic is to ensure location information is accrued during concatenation.
- Parameters:
amount
- the number of bits to shift- Returns:
- the location.
-
size
public int size()Get the total size of this location in bytes- Returns:
- the size in bytes
-
isEmpty
public boolean isEmpty()Check if this location includes any varnodesNote that a location cannot consist entirely of constant zeros and be non-empty. The constructor will have removed them all.
- Returns:
- true if empty
-