Vector35 / Vector35/binaryninja-api

`interaction.InteractionHandler` seems to have gone stale

Aperta
#4,700 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Component: API Component: Plugin Effort: Low Impact: Low
Lingua principale
C++
Stelle
1.3k
Fork
298
Merge medio
5g 5h
PR unite (30g)
19

Descrizione

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:

  1. https://github.com/Vector35/binaryninja-api/blob/84c782175a002a0a62ba1b00234de6b89380c9fc/python/interaction.py#L670 : choiceDefault isn't a thing. I believe it needs to be indexDefault
  2. (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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
reverse-engineering
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.