Vector35 / Vector35/binaryninja-api
`interaction.InteractionHandler` seems to have gone stale
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Description
I'm trying to write a round trip test with DWARF Export and DWARF Import. They're both plugins, and DWARF Export pops up a form asking where to save the file and what the architecture of the file is. I tried to write the following InteractionHandler to intercept that dialogue and submit the correct information:
import binaryninja as bn
bv = load("/bin/cat")
def handle_form(fields, title):
for field in fields:
if isinstance(field, bn.ChoiceField):
field.result = 4
elif isinstance(field, bn.SaveFileNameField):
field.result = "~/dwarf_export_file"
return True
interaction_handler = bn.interaction.InteractionHandler()
interaction_handler.get_form_input = handle_form
interaction_handler.register()
for plugin_command in bn.plugin.PluginCommand:
if plugin_command.name == "Export as DWARF":
plugin_command.execute(bn.plugin.PluginCommandContext(bv))
break
There were two problems I encountered:
- https://github.com/Vector35/binaryninja-api/blob/84c782175a002a0a62ba1b00234de6b89380c9fc/python/interaction.py#L670 :
choiceDefaultisn't a thing. I believe it needs to beindexDefault - (and the reason I'm filing this as a bug instead of fixing it myself) I needed to change _binaryninjacore.py:583 from:
@stringResult.setter
def stringResult(self, value):
self._stringResult = cstr(value)
to
@stringResult.setter
def stringResult(self, value):
self._stringResult = value
I think that all the form inputs (class *Fields in interaction.py) that call BNAllocString don't work at the moment because of this, possibly since our move to Python 3. It is possible that I'm just "holding it wrong" though, since there are no examples on that API.
This is blocking me from closing #3206, which is blocking me from closing #3643
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
Read python/interaction.py around the referenced InteractionHandler fields and _binaryninjacore.py around the stringResult setter. Reproduce the DWARF export form interaction with the shown round-trip script, then verify that the field defaults and string results are accepted and the DWARF export/import workflow completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- reverse-engineering
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100