Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
936 stars 213 forks source link

Define Binary Ninja Macros Persistence or Setting #5894

Open WhatTheFuzz opened 2 months ago

WhatTheFuzz commented 2 months ago

What is the feature you'd like to have?

Add setting to enable "Define Binary Ninja Macros" by default when selecting "Analysis > Import Header File"

Screenshot 2024-08-29 at 08 14 19

Is your feature request related to a problem?

N/A

Are any alternative solutions acceptable?

Additional Information:

I keep most of my type definitions in a C library for easy source control. I make heavy use of the Binary Ninja macros which define the C type qualifiers, like __padding. This definition isn't found by the parser if "Define Binary Ninja Macros" isn't checked.

CouleeApps commented 2 months ago

The checkbox is automatically enabled if BN_TYPE_PARSER appears within the first 2kb of the file, so that headers generated with Export Header File are detected. Given this, I don't think a setting is required, but the documentation needs to be updated to include this fact.

WhatTheFuzz commented 2 months ago

For future reference for anyone seeing this issue, BN_TYPE_PARSER has to be defined in the exact header file that's being imported, not other header files that are imported within that file. For example, if you're importing <path/to/foo.h, make sure to #define BN_TYPE_PARSER in foo.h, not bar.h that foo.h imports. At least, I'm fairly confident this is the case. 😃

CouleeApps commented 2 months ago

That is correct, it only reads the file(s) specified and sets the checkbox based on their contents on disk, before any sort of parsing is run.