Expose the unique identifier from Type objects

Open
#7,928 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, python

Research direction

Start with the TypeContainer module documentation and the existing TypeContainer.get_type_id(name) entry point, then inspect how Type objects represent unnamed types. Done means an unnamed Type exposes a stable unique identifier that can be used to match it outside its original TypeContainer; clarify the supported hashing behavior as part of the API design.

Written by the indexing model from the issue text.

Description

What is the feature you'd like to have?
TypeContainer module documentation says:

Types are stored with both a unique id and a unique name.

This phrasing is inaccurate, as

  • some types have no names
  • I can't see a way to get the ID of a Type if it has no name.

I'd expect Type to expose an ID but it doesn't, instead I think I'm supposed to use TypeContainer.get_type_id(name). But I can't do that, because I can't provide a name for unnamed types.

I think Types should simply expose their unique ID so unnamed types can be tracked outside their TypeContainer.

Is your feature request related to a problem?

Suppose I preprocess Types from a TypeContainer without modifying TypeContainer. Then I want to match a preprocessed, unnamed type to a symbol of the original unnamed type. Since the type has no name, I can't look it up by that property and I can't get its ID. The only solution I found is to map the original Type to the preprocessed one (Type is hashable), then use this extra index to look up preprocessed types, but I'm not sure if this is reliable/supported.

Some code may clear things up:


for t in all_types: # all_types may contain unnamed types
  processed=process(t)
  store_for_me(processed)
  my_types[t]=processed # Extra index for matching, will this behave as I expect?

for s in all_symbols:
  sym_data_type=bv.data_vars[s.address].type
  # I'd like to do something like retrieve_for_me(sym_data_type.id)
  my_type_for_sym=my_types[sym_data_type]

(My more specific use case is this project)

Are any alternative solutions acceptable?

The most convenient solution for me as a user would be if every type had a unique name (even an auto-generated one), but I'm not sure if this would violate the design of the type system.

Additional Information:

N/A

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

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.

More from Vector35/binaryninja-api

All issues in Vector35/binaryninja-api

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.