Skip to content

Commit

Permalink
fix handling of temp register while looking for pointer (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarak authored Feb 11, 2021
1 parent 4930805 commit c88f20a
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions python/anvill/binja.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,25 @@ def _extract_types(
elif isinstance(item_or_list, llinst):
results.extend(self._extract_types(bv, item_or_list.operands, initial_inst))
elif isinstance(item_or_list, bn.lowlevelil.ILRegister):
# For every register, is it a pointer?
possible_pointer: bn.function.RegisterValue = initial_inst.get_reg_value(
item_or_list.name
)
if (
possible_pointer.type
== bn.function.RegisterValueType.ConstantPointerValue
or possible_pointer.type
== bn.function.RegisterValueType.ExternalPointerValue
): # or
# possible_pointer.type == bn.function.RegisterValueType.ConstantValue:
# Is there a scenario where a register has a ConstantValue type thats used as a pointer?
val_type = _convert_bn_llil_type(
possible_pointer, item_or_list.info.size
# Check if the register is not temp. Need to check if the temp register is
# associated to pointer?? Look into MLIL to get more information
if not bn.LLIL_REG_IS_TEMP(item_or_list.index):
# For every register, is it a pointer?
possible_pointer: bn.function.RegisterValue = initial_inst.get_reg_value(
item_or_list.name
)
results.append((item_or_list.name, val_type, possible_pointer.value))
if (
possible_pointer.type
== bn.function.RegisterValueType.ConstantPointerValue
or possible_pointer.type
== bn.function.RegisterValueType.ExternalPointerValue
): # or
# possible_pointer.type == bn.function.RegisterValueType.ConstantValue:
# Is there a scenario where a register has a ConstantValue type thats used as a pointer?
val_type = _convert_bn_llil_type(
possible_pointer, item_or_list.info.size
)
results.append((item_or_list.name, val_type, possible_pointer.value))

if initial_inst.mlil is not None:
mlil_results = self._extract_types_mlil(
Expand Down

0 comments on commit c88f20a

Please sign in to comment.