def export_pseudocomments_from_fun(f_ea): d = {} d[f_ea] = {} #f_ea = 0x040033EC print "Attempting to decompile %x" % f_ea try: ct = idaapi.decompile(f_ea) except idaapi.DecompilationFailure: print "error during decompilation (IDA API)" return d user_cmts = ct.user_cmts num_cmts = idaapi.user_cmts_size(user_cmts) #export_user_variables(ct, f_ea) print "Function 0x%08x has %d pseudocomments" % (f_ea, num_cmts) it = idaapi.user_cmts_begin(user_cmts) #while it != idaapi.user_cmts_end(user_cmts) i = 0 while (i < num_cmts): t = idaapi.user_cmts_first(it) #treeloc_t c = idaapi.user_cmts_second(it) #user_cmts_t print "Comment: %s at addr: 0x%08x itp: %d" % (c.c_str(), t.ea, t.itp) d[f_ea][i] = {"ea" : t.ea, "comment": c.c_str(), "itp": t.itp} i += 1 it = idaapi.user_cmts_next(it) return d
def export_pseudocomments_from_fun(f_ea): d = {} d[f_ea] = {} #f_ea = 0x040033EC print "Attempting to decompile %x" % f_ea try: ct = idaapi.decompile(f_ea) except idaapi.DecompilationFailure: print "error during decompilation (IDA API)" return d user_cmts = ct.user_cmts num_cmts = idaapi.user_cmts_size(user_cmts) #export_user_variables(ct, f_ea) print "Function 0x%08x has %d pseudocomments" % (f_ea, num_cmts) it = idaapi.user_cmts_begin(user_cmts) #while it != idaapi.user_cmts_end(user_cmts) i = 0 while (i < num_cmts): t = idaapi.user_cmts_first(it) #treeloc_t c = idaapi.user_cmts_second(it) #user_cmts_t print "Comment: %s at addr: 0x%08x itp: %d" % (c.c_str(), t.ea, t.itp) d[f_ea][i] = {"ea": t.ea, "comment": c.c_str(), "itp": t.itp} i += 1 it = idaapi.user_cmts_next(it) return d
def _get_user_cmts(ea): user_cmts = idaapi.restore_user_cmts(ea) if user_cmts is None: user_cmts = idaapi.user_cmts_new() cmts = [] it = idaapi.user_cmts_begin(user_cmts) while it != idaapi.user_cmts_end(user_cmts): tl = idaapi.user_cmts_first(it) cmt = idaapi.user_cmts_second(it) cmts.append(((tl.ea, tl.itp), str(cmt))) it = idaapi.user_cmts_next(it) idaapi.user_cmts_free(user_cmts) return cmts