コード例 #1
0
ファイル: hooks.py プロジェクト: rigmar/IDArling
 def _get_user_cmts(ea):
     user_cmts = ida_hexrays.restore_user_cmts(ea)
     if user_cmts is None:
         user_cmts = ida_hexrays.user_cmts_new()
     cmts = []
     it = ida_hexrays.user_cmts_begin(user_cmts)
     while it != ida_hexrays.user_cmts_end(user_cmts):
         tl = ida_hexrays.user_cmts_first(it)
         cmt = ida_hexrays.user_cmts_second(it)
         cmts.append(((tl.ea, tl.itp), Event.decode(str(cmt))))
         it = ida_hexrays.user_cmts_next(it)
     ida_hexrays.user_cmts_free(user_cmts)
     return cmts
コード例 #2
0
ファイル: hooks.py プロジェクト: angr/binsync
    def _get_user_cmts(ea):
        user_cmts = ida_hexrays.restore_user_cmts(ea)
        if user_cmts is None:
            user_cmts = ida_hexrays.user_cmts_new()
        cmts = {}
        it = ida_hexrays.user_cmts_begin(user_cmts)
        while it != ida_hexrays.user_cmts_end(user_cmts):
            tl = ida_hexrays.user_cmts_first(it)
            cmt = ida_hexrays.user_cmts_second(it)
            cmts[tl.ea] = str(cmt)

            it = ida_hexrays.user_cmts_next(it)
        ida_hexrays.user_cmts_free(user_cmts)
        return cmts
コード例 #3
0
ファイル: hexrays_dmp.py プロジェクト: zysyyz/tinyidb
def get_user_define(ea):
    ret = {}
    labels = ida_hexrays.restore_user_labels(ea)
    if labels is not None:
        arr = []
        it = ida_hexrays.user_labels_begin(labels)
        while it != ida_hexrays.user_labels_end(labels):
            org_label = ida_hexrays.user_labels_first(it)
            name = ida_hexrays.user_labels_second(it)
            arr.append((org_label, name.encode("hex")))
            it = ida_hexrays.user_labels_next(it)
        ret["labels"] = arr
        ida_hexrays.user_labels_free(labels)

    cmts = ida_hexrays.restore_user_cmts(ea)
    if cmts is not None:
        arr = []
        for tl, cmt in cmts.iteritems():
            arr.append((tl.ea, tl.itp, str(cmt).encode("hex")))
        ret["cmts"] = arr
        ida_hexrays.user_cmts_free(cmts)

    iflags = ida_hexrays.restore_user_iflags(ea)
    if iflags is not None:
        arr = []
        for cl, f in iflags.iteritems():
            arr.append((cl.ea, cl.op, f))
        ret["iflags"] = arr
        ida_hexrays.user_iflags_free(iflags)

    numforms = ida_hexrays.restore_user_numforms(ea)
    if numforms is not None:
        arr = []
        for ol, nf in numforms.iteritems():
            arr.append((ol.ea, ol.opnum, nf.flags, nf.opnum, nf.props,
                        nf.serial, nf.org_nbytes, nf.type_name))
        ret["numforms"] = arr
        ida_hexrays.user_numforms_free(numforms)

    lvars = _get_user_lvar_settings(ea)
    if lvars:
        ret["lvars"] = lvars

    return ret
コード例 #4
0
def run():

    cfunc = ida_hexrays.decompile(ida_kernwin.get_screen_ea())
    if not cfunc:
        print('Please move the cursor into a function.')
        return

    entry_ea = cfunc.entry_ea
    print("Dump of user-defined information for function at %x" % (entry_ea, ))

    # Display user defined labels.
    labels = ida_hexrays.restore_user_labels(entry_ea)
    if labels is not None:
        print("------- %u user defined labels" % (len(labels), ))
        for org_label, name in labels.items():
            print("Label %d: %s" % (org_label, str(name)))
        ida_hexrays.user_labels_free(labels)

    # Display user defined comments
    cmts = ida_hexrays.restore_user_cmts(entry_ea)
    if cmts is not None:
        print("------- %u user defined comments" % (len(cmts), ))
        for tl, cmt in cmts.items():
            print("Comment at %x, preciser %x:\n%s\n" %
                  (tl.ea, tl.itp, str(cmt)))
        ida_hexrays.user_cmts_free(cmts)

    # Display user defined citem iflags
    iflags = ida_hexrays.restore_user_iflags(entry_ea)
    if iflags is not None:
        print("------- %u user defined citem iflags" % (len(iflags), ))
        for cl, f in iflags.items():
            print("%x(%d): %08X%s" % (cl.ea, cl.op, f, " CIT_COLLAPSED" if f
                                      & ida_hexrays.CIT_COLLAPSED else ""))
        ida_hexrays.user_iflags_free(iflags)

    # Display user defined number formats
    numforms = ida_hexrays.restore_user_numforms(entry_ea)
    if numforms is not None:
        print("------- %u user defined number formats" % (len(numforms), ))
        for ol, nf in numforms.items():

            print("Number format at %a, operand %d: %s" %
                  (ol.ea, ol.opnum, "negated " if
                   (nf.props & NF_NEGATE) != 0 else ""))

            if nf.is_enum():
                print("enum %s (serial %d)" % (str(nf.type_name), nf.serial))

            elif nf.is_char():
                print("char")

            elif nf.is_stroff():
                print("struct offset %s" % (str(nf.type_name), ))

            else:
                print("number base=%d" %
                      (ida_bytes.get_radix(nf.flags, ol.opnum), ))

        ida_hexrays.user_numforms_free(numforms)

    # Display user-defined local variable information
    lvinf = ida_hexrays.lvar_uservec_t()
    if ida_hexrays.restore_user_lvar_settings(lvinf, entry_ea):
        print("------- User defined local variable information\n")
        for lv in lvinf.lvvec:
            print("Lvar defined at %x" % (lv.ll.defea, ))

            if len(str(lv.name)):
                print("  Name: %s" % (str(lv.name), ))

            if len(str(lv.type)):
                #~ print_type_to_one_line(buf, sizeof(buf), idati, .c_str());
                print("  Type: %s" % (str(lv.type), ))

            if len(str(lv.cmt)):
                print("  Comment: %s" % (str(lv.cmt), ))

    return