summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/function.py10
-rw-r--r--python/highlevelil.py32
2 files changed, 39 insertions, 3 deletions
diff --git a/python/function.py b/python/function.py
index dfb83e34..97f832d1 100644
--- a/python/function.py
+++ b/python/function.py
@@ -278,10 +278,16 @@ class ValueRange(object):
class PossibleValueSet(object):
- def __init__(self, arch, value):
+ def __init__(self, arch = None, value = None):
+ if value is None:
+ self._type = RegisterValueType.UndeterminedValue
+ return
self._type = RegisterValueType(value.state)
if value.state == RegisterValueType.EntryValue:
- self._reg = arch.get_reg_name(value.value)
+ if arch is None:
+ self._reg = value.value
+ else:
+ self._reg = arch.get_reg_name(value.value)
elif value.state == RegisterValueType.ConstantValue:
self._value = value.value
elif value.state == RegisterValueType.ConstantPointerValue:
diff --git a/python/highlevelil.py b/python/highlevelil.py
index a5d0b661..feac146b 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -85,7 +85,7 @@ class HighLevelILInstruction(object):
HighLevelILOperation.HLIL_DO_WHILE: [("body", "expr"), ("condition", "expr")],
HighLevelILOperation.HLIL_FOR: [("init", "expr"), ("condition", "expr"), ("update", "expr"), ("body", "expr")],
HighLevelILOperation.HLIL_SWITCH: [("condition", "expr"), ("default", "expr"), ("cases", "expr_list")],
- HighLevelILOperation.HLIL_CASE: [("condition", "expr"), ("body", "expr")],
+ HighLevelILOperation.HLIL_CASE: [("values", "expr_list"), ("body", "expr")],
HighLevelILOperation.HLIL_BREAK: [],
HighLevelILOperation.HLIL_CONTINUE: [],
HighLevelILOperation.HLIL_JUMP: [("dest", "expr")],
@@ -448,6 +448,36 @@ class HighLevelILInstruction(object):
"""IL basic block object containing this expression (read-only) (only available on finalized functions)"""
return HighLevelILBasicBlock(self._function.source_function.view, core.BNGetHighLevelILBasicBlockForInstruction(self._function.handle, self._instr_index), self._function)
+ @property
+ def value(self):
+ """Value of expression if constant or a known value (read-only)"""
+ mlil = self.mlil
+ if mlil is None:
+ return function.RegisterValue()
+ return mlil.value
+
+ @property
+ def possible_values(self):
+ """Possible values of expression using path-sensitive static data flow analysis (read-only)"""
+ mlil = self.mlil
+ if mlil is None:
+ return function.PossibleValueSet()
+ return mlil.possible_values
+
+ @property
+ def expr_type(self):
+ """Type of expression"""
+ mlil = self.mlil
+ if mlil is None:
+ return None
+ return mlil.expr_type
+
+ def get_possible_values(self, options = []):
+ mlil = self.mlil
+ if mlil is None:
+ return function.RegisterValue()
+ return mlil.get_possible_values(options)
+
class HighLevelILExpr(object):
"""