binaryninja-api
binaryninja-api copied to clipboard
Smart create enumeration based on its comparison against costant values
Currently, when one wishes to create an enum, the only way is to use the "Create Type" dialog and type in the enum definition. This is ok, but it is not the most convenient way. We should somehow offer a more smooth way of creating enum and its members. What I have in my mind is a UI dialog that allows you to type in the enum name, its members' name (and values). The members and values are optional. The user can also opt to only specify the enum's name and add its members later.
The way I'd like to see this implemented is to have a "Create New Enum..." option (e.g. on the right-click menu inside of the types sidebar) that just pops up the Create Type dialog with something like this already filled into the box:
enum enum0 {
first = 0
};
I don't believe having a big GUI enum editor would serve much purpose over this, since the primary problem for users is that they don't remember the C syntax for creating enums.
I think one way to improve this would be to have a "Create Enum From Variable" This would first iterate the IL and find any values this is compared against and any switch statements it used in and then would allow you to set a name "FOO" and all the members would be called "FOO_0" "FOO_1" etc. Then once we have the ability to rename enum members using 'N' (what I'm currently working on https://github.com/Vector35/binaryninja-api/issues/3594 ) we'd have a really robust way of quickly creating enumerations with minimal writing of C definitions
We already have the ability to create an empty enum in the types view (right click-> Create New Enumeration...). So I guess the functionality originally requested is somehow addressed.
I will update the issue title to reflect Peter's suggestion