Python idaapi 模块,set_cmt() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用idaapi.set_cmt()

项目:bap-ida-python    作者:BinaryAnalysisPlatform    | 项目源码 | 文件源码
def update(self, ea, key, value):
        """Add key=values to comm string at EA."""
        cmt = idaapi.get_cmt(ea, 0)
        comm = cmt and bap_comment.parse(cmt) or {}
        values = comm.setdefault(key, [])
        if value and value != '()' and value not in values:
            values.append(value)
        idaapi.set_cmt(ea, bap_comment.dumps(comm), 0)
项目:bap-ida-python    作者:BinaryAnalysisPlatform    | 项目源码 | 文件源码
def clear_bap_comments(self):
        """Ask user for confirmation and then clear (BAP ..) comments."""

        if idaapi.askyn_c(ASKBTN_YES,
                          "Delete all `BAP: ..` comments?") != ASKBTN_YES:
            return

        for ea in ida.addresses():  # TODO: store actually commented addresses
            comm = idaapi.get_cmt(ea, 0)
            if comm and comm.startswith('BAP:'):
                idaapi.set_cmt(ea, '', 0)
项目:idascripts    作者:ctfhacker    | 项目源码 | 文件源码
def set_comment(ea, comment, **repeatable):
    """Set the comment at address ``ea`` to ``comment``.
    If the bool ``repeatable`` is specified, then modify the repeatable comment.
    """
    return idaapi.set_cmt(interface.address.inside(ea), comment, repeatable.get('repeatable', False))
项目:IDAPPL    作者:yufengzjj    | 项目源码 | 文件源码
def loadcmt(self):
        total = 0
        count = 0
        for line in self.sym_file:
            total+=1
            sm = re.search("C[\s]+([\dA-F]+)[\s]+(.+)", line)
            if sm:
                if is_printable(sm.group(2)) is False:
                    continue
                if idaapi.set_cmt(int(sm.group(1), 16), sm.group(2), 0):
                    count += 1
                else:
                    print "set comment %s:%s failed" % (sm.group(1), sm.group(2))
        print "total %d applied %d comments" % (total,count)
项目:DecLLVM    作者:F8LEFT    | 项目源码 | 文件源码
def MakeComm(ea, comment):
    """
    Set an indented regular comment of an item

    @param ea: linear address
    @param comment: comment string

    @return: None
    """
    return idaapi.set_cmt(ea, comment, 0)
项目:DecLLVM    作者:F8LEFT    | 项目源码 | 文件源码
def MakeRptCmt(ea, comment):
    """
    Set an indented repeatable comment of an item

    @param ea: linear address
    @param comment: comment string

    @return: None
    """
    return idaapi.set_cmt(ea, comment, 1)
项目:idascripts    作者:ctfhacker    | 项目源码 | 文件源码
def _event(cls):
        while True:
            # cmt_changing event
            ea,rpt,new = (yield)
            old = idaapi.get_cmt(ea, rpt)
            f,o,n = idaapi.get_func(ea),internal.comment.decode(old),internal.comment.decode(new)

            # update references before we update the comment
            cls._update_refs(ea, o, n)

            # wait for cmt_changed event
            newea,nrpt,none = (yield)

            # now fix the comment the user typed
            if (newea,nrpt,none) == (ea,rpt,None):
                ncmt,repeatable = idaapi.get_cmt(ea, rpt), cls._is_repeatable(ea)

                if (ncmt or '') != new:
                    logging.warn("internal.{:s}.event : Comment from event is different from database : {:x} : {!r} != {!r}".format('.'.join((__name__,cls.__name__)), ea, new, ncmt))

                # delete it if it's the wrong type
#                if nrpt != repeatable:
#                    idaapi.set_cmt(ea, '', nrpt)

#                # write the tag back to the address
#                if internal.comment.check(new): idaapi.set_cmt(ea, internal.comment.encode(n), repeatable)
#                # write the comment back if it's non-empty
#                elif new: idaapi.set_cmt(ea, new, repeatable)
#                # otherwise, remove it's reference since it's being deleted
#                else: cls._delete_refs(ea, n)

                if internal.comment.check(new): idaapi.set_cmt(ea, internal.comment.encode(n), rpt)
                elif new: idaapi.set_cmt(ea, new, rpt)
                else: cls._delete_refs(ea, n)

                continue

            # if the changed event doesn't happen in the right order
            logging.fatal("{:s}.event : Comment events are out of sync, updating tags from previous comment. : {!r} : {!r}".format('.'.join((__name__,cls.__name__)), o, n))

            # delete the old comment
            cls._delete_refs(ea, o)
            idaapi.set_cmt(ea, '', rpt)
            logging.warn("{:s}.event : Previous comment at {:x} : {!r}".format('.'.join((__name__,cls.__name__)), o))

            # new comment
            new = idaapi.get_cmt(newea, nrpt)
            n = internal.comment.decode(new)
            cls._create_refs(newea, n)

            continue
        return