You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to automate the process of identifying structures then retyping the associated fields. I have been able to retype the necessary variables into a structure but I want to change the display type for a specific field. This field is a bitflag whose values are defined in an enumeration -- left as an integer it is tricky to immediately see what is being set.
I have written the following in the Binja console:
Which is supposed to change the display type of an MLIL instruction (where flags is a uint32_t):
var.flags = 0x42000000
into types defined by MyEnum:
enum MyEnum : uint32_t
{
DOG = 0x800000,
CAT = 0x2000000,
BAT = 0x4000000,
RAT = 0x10000000,
BUG = 0x20000000,
MAN = 0x40000000
};
If I were to assign the field type to MyEnum in the struct, Binja does not display the value as a combination of enum values so I need to manually configure the display. However, (despite MyEnum being defined) the code fails due to the type_id missing:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Applications/Binary Ninja.app/Contents/MacOS/plugins/../../Resources/python/binaryninja/function.py", line 2625, in set_int_display_type
display_type = IntegerDisplayType[display_type]
File "/Applications/Binary Ninja.app/Contents/Resources/bundled-python3/lib/python310.zip/enum.py", line 440, in __getitem__
return cls._member_map_[name]
KeyError: 'd9a0799d-d5db-483d-8f1f-b92b63976ff8'
I'm not sure how to correctly determine the type_id, any guidance would be appreciated. Additionally, what is the overhead associated by changing the display type on potentially thousands of instances? Is this trivial overhead or potentially cause problems? Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am trying to automate the process of identifying structures then retyping the associated fields. I have been able to retype the necessary variables into a structure but I want to change the display type for a specific field. This field is a bitflag whose values are defined in an enumeration -- left as an integer it is tricky to immediately see what is being set.
I have written the following in the Binja console:
Which is supposed to change the display type of an MLIL instruction (where
flagsis auint32_t):into types defined by
MyEnum:If I were to assign the field type to
MyEnumin the struct, Binja does not display the value as a combination of enum values so I need to manually configure the display. However, (despiteMyEnumbeing defined) the code fails due to thetype_idmissing:I'm not sure how to correctly determine the
type_id, any guidance would be appreciated. Additionally, what is the overhead associated by changing the display type on potentially thousands of instances? Is this trivial overhead or potentially cause problems? Thanks.Beta Was this translation helpful? Give feedback.
All reactions