Vector35 / Vector35/binaryninja-api

Analysis->Export Header File can order typedefs after their first use with inheritance.

Open
#4,297 0 comments 0 reactions 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: [e.g. 3.2.4000-dev] (if version is stable, please also test the latest development build via the "Update Channel" option)
  • OS: Windows 10
  • OS Version: 3.5.4275-dev Personal (63933426)
  • CPU Architecture: x64

Bug Description:
If you have a struct that inherits a member whose type is a typedef, the typedef may be declared after the struct definition and therefore cannot be imported again.

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

  1. Load any binary
  2. Use the following code to define types
    typedef int zzzz;
    
    struct base
    {
        zzzz field;
    };
    
    struct __base(base, 0) concrete
    {
        __inherited zzzz `base::field`;
    };
    
  3. Go to Analysis -> Export Header File... and save the file somewhere.
  4. Try to import the file via Analysis -> Import Header File... or check the file output in the editor of your choice.

Import fails with error: <some folder>/Test.h:994:14 unknown type name 'zzzz'

And if I check the generated header file typedef int32_t zzzz; is on line 1416 while the first use is within the definition of class concrete on line 992.

Expected Behavior:
Successful import in step 6.

Screenshots:
The first use of zzzz within the header file:
image

The typedef within the header file:
image

Error when importing:
image

Additional Information:
I only noticed it happening for typedefs, I have not explicitly checked if it's can happen for non-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

Reproduce the issue from Analysis → Export Header File... using the typedef, inherited member, and concrete struct shown in the report, then inspect the generated header before importing it via Analysis → Import Header File.... Done means the exported header places typedef int32_t zzzz before its first use and imports successfully without the unknown type name error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
reverse-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.