Vector35 / Vector35/binaryninja-api

Templatized types (in some form) in BN's type system

Open
#3,305 3 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When reverse engineering large C++ binaries, I end up defining a lot of structures like:

struct TArray_FString __packed
{
    struct FString* elements;
    int32_t count;
    uint32_t capacity;
};

struct TArray_HANDLE __packed
{
    HANDLE* elements;
    int32_t count;
    uint32_t capacity;
};

struct TArray_TArray_S1StringDBEntry __packed
{
    struct TArray_S1StringDBEntry* elements;
    int32_t count;
    uint32_t capacity;
};

struct TArray_S1StringDBEntry __packed
{
    struct S1StringDBEntry* elements;
    int32_t count;
    uint32_t capacity;
};

It gets even worse when more complex data structures are in play, such as hash tables. I end up manually doing all the template expansion that the C++ compiler did. And if I make a mistake in my understanding of the data structure, I then have to go back and fix every single instance.

It would be nice if there was a way to do templatized types in BN's type system. Due to the frankly insane complexity of implementing C++ templates (or even just representing them while using Clang for parsing/analysis), I really don't think it has to take the shape of actual C++ templates, but something that achieves the same end result without all the repetition would certainly make life a lot easier. Even just a significantly reduced version of templates that only allows passing complete types as template arguments (so no constants or any other such complexity) would go a very long way.

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 by reviewing Binary Ninja's existing type-system representation and how C++ types are imported or analyzed. Define a reduced form of templatized types that supports complete type arguments, then verify that repeated structures can be represented without manual expansion. The issue does not name specific files or tests, so locating the relevant type-system entry points is part of the work.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.