コード例 #1
0
ファイル: test_structs.py プロジェクト: silverf0x/YaCo
 def yatest_create_struct(self):
     for name, comment, repeatable in create_struct:
         sid = idc.AddStrucEx(-1, name, 0)
         self.assertNotEqual(sid, -1)
         if comment is not None:
             err = idc.SetStrucComment(sid, comment, repeatable)
             self.assertNotEqual(err, 0)
コード例 #2
0
ファイル: YaToolIDAExporter.py プロジェクト: tmcmil/YaCo
    def make_header_comment(self, object_version, address):
        try:
            repeatable_headercomment = self.sanitize_comment_to_ascii(
                object_version.get_header_comment(True))
            obj_type = object_version.get_type()
            if obj_type == ya.OBJECT_TYPE_FUNCTION:
                idc.SetFunctionCmt(address, repeatable_headercomment, 1)
            elif obj_type == ya.OBJECT_TYPE_STRUCT:
                struc_id = self.struc_ids[object_version.get_id()]
                idc.SetStrucComment(struc_id, repeatable_headercomment, 1)
        except KeyError:
            pass

        try:
            nonrepeatable_headercomment = self.sanitize_comment_to_ascii(
                object_version.get_header_comment(False))
            obj_type = object_version.get_type()
            if obj_type == ya.OBJECT_TYPE_FUNCTION:
                idc.SetFunctionCmt(address, nonrepeatable_headercomment, 0)
            elif obj_type == ya.OBJECT_TYPE_STRUCT:
                struc_id = self.struc_ids[object_version.get_id()]
                idc.SetStrucComment(struc_id, nonrepeatable_headercomment, 0)
        except KeyError:
            pass
コード例 #3
0
def add_struc_descr(sid, structure, rep):
    """ Insert a (repeatable) comment descripting the structure whose id is sid.
    And name address in added segment annotated with structure description.
    
    Arguments:
    sid -- structure id which the added comment is describing
    structure -- structure object holding data
    rep -- add repeatable comment (True\False)
    
    Return:
    True -- if success; False otherwise
    """

    # TODO correct or not
    descr = format_comment(structure.description) + '\n'

    if idc.SetStrucComment(sid, descr, rep):

        frm = [x.frm for x in idautils.XrefsTo(sid)]

        for ea in frm:
            # Added comment for global %structure.name% variable or pointer
            if ea > idc.MaxEA():
                # getting 'member_t' using ea as 'mid'
                mptr = idaapi.get_member_by_id(ea)

                # IDA 6.8: setting member comment using 'mptr' as index
                idaapi.set_member_cmt(mptr, descr, rep)

                # IDA 6.9: mptr is type of list
                #idaapi.set_member_cmt(mptr[0], descr, rep)
            else:
                if not rep:
                    idc.MakeComm(ea, descr)
                else:
                    idc.MakeRptCmt(ea, descr)

        return True

    else:
        return False
コード例 #4
0
 def set_comment(self, comment, repeteable=True):
     return idc.SetStrucComment(self.sid, comment, repeteable)
コード例 #5
0
ファイル: dispatch.py プロジェクト: Spl3en/ipad
def dispatch(args):

    ## dispatch args....
    class A():
        pass

    a = A()
    for name in args:
        setattr(a, name, args[name])
    del args

    ### dispatch idp events
    if a.action == 'rename':
        debug('[*] renaming %s to %s @ %x', a.old_name, a.new_name, a.ea)
        idc.MakeNameEx(a.ea, str(a.new_name), idaapi.SN_NOWARN)
        return

    ## dispatch idb events
    if a.action == 'cmt_changed':
        if not a.cmt: a.cmt = ''
        _pcmt = a.cmt if len(a.cmt) < 10 else a.cmt[:10] + '...'
        debug('[*] cmt changed @ %X (rep:%s) - %s', a.ea, a.rep, _pcmt)
        if a.rep: idc.MakeRptCmt(a.ea, str(a.cmt))
        else: idc.MakeComm(a.ea, str(a.cmt))

    if a.action == 'struct_created':
        debug('[*] Struct %s created with id %x', a.sname, a.struct)
        print idc.AddStrucEx(-1, str(a.sname), a.union)

    if a.action == 'struct_deleted':
        sid = idc.GetStrucId(a.struct)
        sname = idc.GetStrucName(sid)
        debug('[*] Struct(%x) %s deleted', a.struct, sname)
        idc.DelStruc(sid)

    if a.action == 'struct_renamed':
        sid = idc.GetStrucId(a.struct)
        sname = idc.GetStrucName(sid)
        debug('[*] Struct(%d - %x) renamed from %s to %s', a.struct, sid,
              sname, a.sname)
        idc.SetStrucName(sid, str(a.sname))

    if a.action == 'struct_cmt_changed':
        sid = idc.GetStrucId(a.struct)
        debug('[*] Struct(%d - %x) %s - cmt changed', a.struct, sid, a.sname)
        idc.SetStrucComment(sid, a.cmt, 0)

    if a.action == 'struct_expanded':
        pass

    if a.action == 'struct_member_created':
        pass

    if a.action == 'struct_member_deleted':
        pass
    if a.action == 'struct_member_renamed':
        pass
    if a.action == 'struct_member_changed':
        pass
    if a.action == 'struct_member_':
        pass
    if a.action == 'struct_member_created':
        pass
    if a.action == 'struct_member_created':
        pass

    # if a.action == 'struct_expanded':
    #     debug('

    return 0