Beispiel #1
0
def add_enum(name=None, index=None, flags=idaapi.hex_flag(), bitfield=False):
    """Create a new enum.

    Args:
        name: Name of the enum to create.
        index: The index of the enum. Leave at default to append the enum as the last enum.
        flags: Enum type flags.
        bitfield: Is the enum a bitfield.

    Returns:
        An `Enum` object.
    """
    if name is not None:
        with suppress(exceptions.EnumNotFound):
            _get_enum(name)
            raise exceptions.EnumAlreadyExists()

    if index is None or index < 0:
        index = idaapi.get_enum_qty()

    eid = idaapi.add_enum(index, name, flags)

    if eid == idaapi.BADADDR:
        raise exceptions.EnumCreationFailed(
            'Failed creating enum "{}"'.format(name))

    if bitfield:
        idaapi.set_enum_bf(eid, bitfield)

    return Enum(eid=eid)
Beispiel #2
0
def add_enum(name=None, index=None, flags=idaapi.hexflag(), bitfield=False):
    """Create a new enum.

    Args:
        name: Name of the enum to create.
        index: The index of the enum. Leave at default to append the enum as the last enum.
        flags: Enum type flags.
        bitfield: Is the enum a bitfield.

    Returns:
        An `Enum` object.
    """
    if name is not None:
        with ignored(exceptions.EnumNotFound):
            _get_enum(name)
            raise exceptions.EnumAlreadyExists()

    if index is None or index < 0:
        index = idaapi.get_enum_qty()

    eid = idaapi.add_enum(index, name, flags)

    if eid == idaapi.BADADDR:
        raise exceptions.EnumCreationFailed('Failed creating enum "{}"'.format(name))

    if bitfield:
        idaapi.set_enum_bf(eid, bitfield)

    return Enum(eid=eid)
Beispiel #3
0
def handle_enums(delta, segs):
    for idx in range(idaapi.get_enum_qty()):
        e = idaapi.getn_enum(idx)
        for cmt_type in (True, False):
            cmt = idaapi.get_enum_cmt(e, cmt_type)
            if cmt:
                new_cmt = rebase_comment(segs, delta, cmt)
                if new_cmt:
                    idaapi.set_enum_cmt(e, new_cmt, cmt_type)
        idaapi.for_all_enum_members(e, enum_memb_visitor(segs, delta))
Beispiel #4
0
 def __init__(self):
     #Is this the right way to iterate through enums? Holes?
     self.elts = []
     for i in range(idaapi.get_enum_qty()):
         self.elts.append(enum_node(idaapi.getn_enum(i)))
Beispiel #5
0
def count():
    '''Return the total number of enumerations in the database.'''
    return idaapi.get_enum_qty()
Beispiel #6
0
def __iterate__():
    '''Yield the identifier of each enumeration within the database.'''
    for item in range(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(item)
    return
Beispiel #7
0
def _iter_enum_ids():
    """Iterate the IDs of all enums in the IDB"""
    for index in xrange(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(index)
Beispiel #8
0
def __iterate__():
    '''Yield the identifier of each enumeration within the database.'''
    for n in six.moves.range(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(n)
    return
Beispiel #9
0
def count():
    '''Return the total number of enumerations in the database.'''
    return idaapi.get_enum_qty()
Beispiel #10
0
def __iterate__():
    '''Yield the identifier of each enumeration within the database.'''
    for n in six.moves.range(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(n)
    return
Beispiel #11
0
def iterate():
    '''Yield the identifier of each defined enumeration'''
    for n in xrange(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(n)
    return
Beispiel #12
0
def __iterate__():
    '''Iterate through all enumeration ids defined in the database.'''
    for n in __builtin__.range(idaapi.get_enum_qty()):
        yield idaapi.getn_enum(n)
    return
Beispiel #13
0
 def __init__(self):
     #Is this the right way to iterate through enums? Holes?
     self.elts = []
     for i in range(idaapi.get_enum_qty()):
         self.elts.append(enum_node(idaapi.getn_enum(i)))