def __call__(self): cmts = ida_hexrays.user_cmts_new() for (tl_ea, tl_itp), cmt in self.cmts: tl = ida_hexrays.treeloc_t() tl.ea = tl_ea tl.itp = tl_itp cmts.insert(tl, ida_hexrays.citem_cmt_t(Event.encode(cmt))) ida_hexrays.save_user_cmts(self.ea, cmts) HexRaysEvent.refresh_pseudocode_view()
def set_decomp_comments(func_addr, cmt_dict: typing.Dict[int, str]): for addr in cmt_dict: ida_cmts = ida_hexrays.user_cmts_new() comment = cmt_dict[addr] tl = ida_hexrays.treeloc_t() tl.ea = addr # XXX: need a real value here at some point tl.itp = 90 ida_cmts.insert(tl, ida_hexrays.citem_cmt_t(comment)) ida_hexrays.save_user_cmts(func_addr, ida_cmts)
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
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
# XXX - ExpandingStrucEvent # XXX - SegmAddedEvent # XXX - SegmDeletedEvent # XXX - SegmStartChangedEvent # XXX - SegmEndChangedEvent # XXX - SegmNameChangedEvent # XXX - SegmClassChangedEvent # XXX - SegmAttrsUpdatedEvent # XXX - SegmMoved print("[+] Undefining string at 0x78DBDCB0 -> UndefinedEvent") del_items(0x78DBDCB0) # XXX - BytePatchedEvent # XXX - SgrChanged # XXX - UserLabelsEvent print("[+] Defining 2 comments in HexRays window in function defined at 0x78DBB091 -> UserCmtsEvent") list_comments = [((0x78DBB06A, 74), 'one comment in HexRays'), ((0x78DBB091, 74), 'another comment in HexRays')] cmts = ida_hexrays.user_cmts_new() for (tl_ea, tl_itp), cmt in list_comments: tl = ida_hexrays.treeloc_t() tl.ea = tl_ea tl.itp = tl_itp cmts.insert(tl, ida_hexrays.citem_cmt_t(cmt)) ida_hexrays.save_user_cmts(0x78DBB050, cmts) # XXX - UserIflagsEvent # XXX - UserLvarSettingsEvent # XXX - UserNumformsEvent