def createEnum(self, enum): eid = idc.add_enum(-1, enum[0], 0x1100000) # what is this flag? ida_enum.set_enum_bf(eid, 1) val = 0 mask = 0x1F ida_enum.set_enum_width(eid, 1) for i in enum[1]: idc.add_enum_member(eid, i, val, mask) val += 1
def load(infos): for info in infos: enum_id = ida_enum.get_enum(info['name']) if enum_id == BADADDR: print('[IDA-Sync] Creating new enum %s.' % info['name']) enum_id = ida_enum.add_enum( info['idx'], info['name'], info['flag'], ) else: ida_enum.set_enum_idx(enum_id, info['idx']) ida_enum.set_enum_flag(enum_id, info['flag']) ida_enum.set_enum_width(enum_id, info['width']) for member in info['members']: ida_enum.add_enum_member( enum_id, member['name'], member['value'])
def width(self, value): """ Setter for the width of an enum. The width in bytes of an enum can be: 0 (unspecified),1,2,4,8,16,32,64. :param int value: The width of the enum. :raise ValueError: If the value is not supported. :raise RuntimeError: If it was unable to change the width of an enum. """ if value not in (0, 1, 2, 4, 8, 16, 32, 64): raise ValueError("Unsuported width {} for enum".format(value)) if not ida_enum.set_enum_width(self._eid, value): raise RuntimeError("Unable to change width of the enum")