Vector35 / Vector35/binaryninja-api
Invalid register returned from clobbered register list for specific function
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Description
Binary: gentle ocean dreams gracefully
- Go to
0x401000 current_function.clobbered_regs- Observe first register is "invalid"
The edit function dialog shows no such register, presumably it filters out invalid ones. Maybe the python bindings should as well?
Discovered when I tried to add the binary to the unit tests and it failed due to:
def test_functions_attributes(bv: BinaryView):
"""Function attributes don't match"""
funcinfo = []
for func in bv.functions:
func.comment = "testcomment " + func.name
func.name = func.symbol
func.can_return = func.can_return
func.type = func.type
func.return_type = func.return_type
func.return_regs = func.return_regs
func.calling_convention = func.calling_convention
func.parameter_vars = func.parameter_vars
func.has_variable_arguments = func.has_variable_arguments
func.analysis_skipped = func.analysis_skipped
> func.clobbered_regs = func.clobbered_regs
python/test_function.py:117:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../..-../binaryninja/function.py:1524: in clobbered_regs
regs.regs[i] = self.arch.get_reg_index(value[i])
self = <arch: x86>, reg = 'invalid'
def get_reg_index(self, reg: RegisterType) -> RegisterIndex:
if isinstance(reg, str):
try:
index = self.regs[reg].index
assert index is not None
return index
except KeyError:
log_error(f"Failed to map string {reg} to register index: ")
log_error(traceback.format_exc())
elif isinstance(reg, lowlevelil.ILRegister):
return reg.index
elif isinstance(reg, int):
return RegisterIndex(reg)
> raise Exception("Attempting to get register index of non-existant register")
E Exception: Attempting to get register index of non-existant register
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with python/test_function.py:test_functions_attributes and the clobbered_regs setter in function.py:1524. Reproduce the failure using the named binary and inspect how the edit dialog treats the invalid register. Done means the function attribute test handles this register consistently without raising an exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, reverse-engineering
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100