Vector35 / Vector35/binaryninja-api

component data variable notifications raise AttributeError

Open Beginner friendly
#8,444 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

_component_data_variable_added passes the raw BNDataVariable pointer to
DataVariable.from_core_struct, which expects a dereferenced struct.

  File "binaryninja/binaryview.py", line 1481, in _component_data_variable_added
    self._notify.component_data_var_added(self._view, result,
        DataVariable.from_core_struct(var, self._view))
  File "binaryninja/binaryview.py", line 12255, in from_core_struct
    core.BNNewTypeReference(var.type), platform=view.platform,
                            ^^^^^^^^
  AttributeError: 'LP_BNDataVariable' object has no attribute 'type'

The three non-component callbacks dereference correctly; the two component ones
do not:

  1171  data_var_added              from_core_struct(var[0], ...)   ok
  1177  data_var_removed            from_core_struct(var[0], ...)   ok
  1183  data_var_updated            from_core_struct(var[0], ...)   ok
  1481  component_data_var_added    from_core_struct(var,    ...)   throws
  1491  component_data_var_removed  from_core_struct(var,    ...)   throws

The type annotations on the component callbacks are also wrong: declared
var: core.BNDataVariable, actually receive LP_BNDataVariable. The working ones
correctly declare core.BNDataVariableHandle.

FIX: var -> var[0] at lines 1481 and 1491; correct the annotations.

REPRODUCE (no plugin needed):
load any binary, register a BinaryDataNotification implementing
component_data_var_added, then bv.create_component() and
component.add_data_variable(dv).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open binaryninja/binaryview.py and compare the component callbacks around lines 1481 and 1491 with the working data-variable callbacks around lines 1171-1183. Reproduce with a BinaryDataNotification, bv.create_component(), and component.add_data_variable(dv); done means both component callbacks handle the pointer correctly and their annotations match the received handle type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
reverse-engineering
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.