Type names generated by analysis.rtti.vftAnalysis cannot be parsed by clang
Version and Platform (required):
- Binary Ninja Version: 5.1.7418
- Edition: Ultimate
- OS: macOS
- CPU Architecture: arm64
Bug Description:
The usage of :: in the types generated by VFT analysis (an amazing feature) are not able to be parsed by clang.
I'm using a complex process to transform output from source2gen's header generator into something that can be passed into Binary Ninja's type system and auto-applied to virtual funcs. I plan to piggyback on the existing RTTI by slotting in the vftable pointer to these headers.
This results in output that looks like this:
struct CEntityComponent {
CEntityComponent::VTable* vftable;
};
struct CHitboxComponent {
CEntityComponent::CHitboxComponent::VTable* vftable;
uint8_t _pad0008 [ 0x1c ];
uint32_t m_bvDisabledHitGroups [ 1 ];
};
This would theoretically be solid and give us our type, but when trying to import my final generated header, we fail with the following error:
error: <stuff>.h:125:23 'CHitboxComponent' is not a class, namespace, or enumeration.
If it would be possible to have an option to output valid clang type names, e.g. something as simple as CHitboxComponent_vtable for the type name, that would be ideal. Currently my workaround is going to be writing a script to do that.
This isn't really a bug, if a user wants they can rename the vtable type so they can refer to the decl without preparing the type beforehand. This naming convention is pretty common with internal types like a vtable, moreover this is actually what we do for PDB types as well. https://github.com/Vector35/binaryninja-api/blob/1b135ac9d41053326dd5da74d31716f90008f89f/plugins/pdb-ng/src/type_parser.rs#L1047
So if we want to change this behavior we likely would want to change the behavior of the pdb plugin, or make it so that namespaces are squashed for type names (I.e. Namespace::Item -> Namespace_Item, or something similar), when exporting.