Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)))
Exemplo n.º 5
0
def count():
    '''Return the total number of enumerations in the database.'''
    return idaapi.get_enum_qty()
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 9
0
def count():
    '''Return the total number of enumerations in the database.'''
    return idaapi.get_enum_qty()
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)))