Skip to content

NamedTypeReferenceBuilder doesn't have setters for name, type id, and type #3014

Description

@fuzyll

See title.

Discussed in #3006

Originally posted by saruman9 March 9, 2022
I have a type definition for example:

>>> old_t = [t for t in bv.types if "std::__cxx11::string" == '::'.join(t[0].name)][0]
>>> old_t
('std::__cxx11::string', <type: immutable:NamedTypeReferenceClass 'typedef std::__cxx11::string'>)

Yes, it's a cycle type (typedef std::__cxx11::string std::__cxx11::string;), but it's a example. I don't use get_type_by_name method, because it's don't work for C++ types.

I tried to change the type definition:

>>> t = [t for t in bv.types if "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >" == '::'.join(t[0].name)][0]
>>> t
('std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >', <type: immutable:StructureTypeClass 'class'>)
>>> new_t = NamedTypeReferenceType.create_from_type("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >", type = t[1])
>>> new_t
<type: immutable:NamedTypeReferenceClass 'class std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'>
>>> bv.define_type(old_t[1].type_id, "std::__cxx11::string", new_t)
'std::__cxx11::string'

But nothing happens. If I will undefine std::__cxx11::string using UI, than Binary Ninja will crash (segmentation fault).

How I can change a type definition using API?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Component: APIIssue needs changes to the APIEffort: LowIssues require < 1 week of workImpact: MediumIssue is impactful with a bad, or no, workaround

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions