Ejemplo n.º 1
0
 def mask(cls, mid):
     '''Return the bitmask for the enumeration member `mid`.'''
     if not interface.node.is_identifier(mid):
         raise E.MemberNotFoundError(
             u"{:s}.mask({:#x}) : Unable to locate member by the specified identifier."
             .format('.'.join([__name__, cls.__name__]), mid))
     return idaapi.get_enum_member_bmask(mid)
Ejemplo n.º 2
0
 def by_identifier(cls, enum, mid):
     '''Return the member of the enumeration specified by `enum` and its `mid`.'''
     eid = by(enum)
     if member.parent(mid) != eid:
         raise E.MemberNotFoundError(
             u"{:s}.by_identifier({:#x}, {:d}) : Unable to locate member by the specified identifier."
             .format('.'.join([__name__, cls.__name__]), eid, mid))
     return mid
Ejemplo n.º 3
0
 def name(cls, mid):
     '''Return the name of the enumeration member `mid`.'''
     if not interface.node.is_identifier(mid):
         raise E.MemberNotFoundError(
             u"{:s}.name({:#x}) : Unable to locate member by the specified identifier."
             .format('.'.join([__name__, cls.__name__]), mid))
     res = idaapi.get_enum_member_name(mid)
     return utils.string.of(res)
Ejemplo n.º 4
0
 def by_value(cls, enum, value):
     '''Return the member identifier for the member of the enumeration `enum` with the specified `value`.'''
     eid = by(enum)
     bmask = idaapi.BADADDR & mask(eid)
     res, _ = idaapi.get_first_serial_enum_member(eid, value, bmask)
     if res == idaapi.BADADDR:
         raise E.MemberNotFoundError(u"{:s}.by_value({:#x}, {:d}) : Unable to locate member by value.".format('.'.join((__name__, cls.__name__)), eid, value))
     return res
Ejemplo n.º 5
0
    def value(cls, mid, value, **bitmask):
        """Set the `value` for the enumeration `member` belonging to `enum`.

        If the integer `bitmask` is specified, then use it as a bitmask. Otherwise assume all bits are set.
        """
        if not interface.node.is_identifier(mid):
            raise E.MemberNotFoundError(u"{:s}.value({:#x}, {:#x}) : Unable to locate member by the specified identifier.".format('.'.join((__name__, cls.__name__)), mid, value))
        bmask = bitmask.get('bitmask', idaapi.BADADDR & cls.mask(mid))
        return idaapi.set_enum_member_value(mid, value, bmask)
Ejemplo n.º 6
0
    def comment(cls, mid, comment, **repeatable):
        """Set the comment for the enumeration member id `mid` to `comment`.

        If the bool `repeatable` is specified, then set the repeatable comment.
        """
        if not interface.node.is_identifier(mid):
            raise E.MemberNotFoundError(u"{:s}.comment({:#x}, {!r}) : Unable to locate member by the specified identifier.".format('.'.join((__name__, cls.__name__)), mid, comment))
        res = utils.string.to(comment)
        return idaapi.set_enum_member_cmt(mid, res, repeatable.get('repeatable', True))
Ejemplo n.º 7
0
 def by_index(cls, enum, index):
     '''Return the member identifier for the member of the enumeration `enum` at the specified `index`.'''
     eid = by(enum)
     try:
         return next(mid for i, mid in enumerate(cls.iterate(eid))
                     if i == index)
     except StopIteration:
         pass
     raise E.MemberNotFoundError(
         u"{:s}.by_index({:#x}, {:d}) : Unable to locate member by index.".
         format('.'.join([__name__, cls.__name__]), eid, index))
Ejemplo n.º 8
0
    def comment(cls, mid, **repeatable):
        """Return the comment for the enumeration member `mid`.

        If the bool `repeatable` is specified, then return the repeatable comment.
        """
        if not interface.node.is_identifier(mid):
            raise E.MemberNotFoundError(
                u"{:s}.comment({:#x}) : Unable to locate member by the specified identifier."
                .format('.'.join([__name__, cls.__name__]), mid))
        res = idaapi.get_enum_member_cmt(mid,
                                         repeatable.get('repeatable', True))
        return utils.string.of(res)
Ejemplo n.º 9
0
 def serial(cls, mid):
     '''Return the serial of the enumeration member `mid`.'''
     if not interface.node.is_identifier(mid):
         raise E.MemberNotFoundError(u"{:s}.serial({:#x}) : Unable to locate member by the specified identifier.".format('.'.join((__name__, cls.__name__)), mid))
     return idaapi.get_enum_member_serial(mid)