Vector35 / Vector35/binaryninja-api

DataRenderer.perform_is_valid_for_data can't be properly applied when dealing with typedefs

Open
#5,485 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Version and Platform (required):

  • Binary Ninja Version: 4.1.5396-dev Personal (716d21f3)
  • OS: MacOS
  • OS Version: 14.1

Bug Description:
Currently i can't tweak data rendering for types which is aliased (typedefd) to integer types (for example typedef uint32_t rva_t;) as in DataRenderer.perform_is_valid_for_data callback for such types i got only Type.IntegerType instead of Type.NamedTypeReference, thus this type can't be distinguished from regular int types. Also registered_name for such type would be None so i can't use approach demonstrated in this example

Steps To Reproduce:

  1. Create any typedef (for example typedef uint32_t rva32_t;)
  2. Try to customise data rendering for it. Here is my testing snippet:
class TestDataRender(DataRenderer):
    def __init__(self):
        super(TestDataRender, self).__init__()

    def perform_is_valid_for_data(self, ctx, view, addr, _type, context):
        # Equivalent of checking the platform
        if not view.platform:
            return False

        # print(context)
        print(_type.type_class)
        return False

    def perform_get_lines_for_data(self, ctx, view, addr, type, prefix, width, context):
        return []


TestDataRender().register_type_specific()

Expected Behavior:
I expect that typedefd type should be NamedTypeReference or at least should have its registered_name or any other way to be able to distinguish it from regular types (not structures).

Additional Information:
Actually i think that if it's not duplicate of #4552, then at least related to it, however Peter (plafosse) said that i should open separate issue, so here we go.

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 DataRenderer.perform_is_valid_for_data and reproduce the typedef case using the provided TestDataRender snippet, then compare the related discussion in #4552 and the custom data display example. Done means typedef-backed integer types remain distinguishable from regular integer types through NamedTypeReference, registered_name, or another exposed identifier.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.