Vector35 / Vector35/binaryninja-api

`bv.get_code_refs_for_type_field` does not retrieve refs for a type field if the variable type is a `typedef someStruct* variableType`

Open
#3,659 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Description:
bv.get_code_refs_for_type_field does not retrieve refs for a type field if the variable type is a typedef someStruct* variableType

This also impacts xrefs in UI. This appears to be unintentional as changing the type to the base struct and back to the Typedef computes the type references.

This impacts type references for all Objective-C Ivars.

Steps To Reproduce:
Please provide all steps required to reproduce the behavior:

  1. Open a Binary using Objective-C w/ the objective-C workflow enabled
  2. Select a class, double click the type of the first argument and navigate to it in the types view
  3. Pick an ivar to target
  4. list(bv.get_code_refs_for_type_field('class_<CLASSNAMEHERE>', [i for i in bv.get_type_by_name('class_<CLASSNAMEHERE>').members if i.name == '<IVARNAMEHERE>'][0].offset))
  5. The list will be empty. Change the type for the first argument in the function to struct class_<CLASSNAMEHERE>*
  6. Run the command again, type refs will be computed for that structure.
  7. Change the type for self back to <CLASSNAMEHERE>.
  8. Run the command again. The type ref is still there.

Expected Behavior:
Code references for type fields should propagate through Typedefs

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

Start with the bv.get_code_refs_for_type_field entry point and reproduce the Objective-C ivar case using the listed Binary Ninja workflow and commands. Trace how typedef pointer types are handled and verify that type references propagate through the typedef and appear in UI cross-references without first changing the type to its base struct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, objective-c, python
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.