in tools/latrodectus/latro_str_decrypt.py [0:0]
def set_decompiler_comment(address: int, decrypted_string: str) -> None:
try:
seg = idaapi.getseg(address)
if seg and seg.name == ".pdata":
print(f"Skipping comment in .pdata section at: {hex(address)}")
return
cfunc = idaapi.decompile(address)
if cfunc is None:
print(f"Failed to decompile function at: {hex(address)}")
return
eamap = cfunc.get_eamap()
decomp_addr = eamap[address][0].ea
tl = idaapi.treeloc_t()
tl.ea = decomp_addr
commentFlag = False
for itp in range(idaapi.ITP_SEMI, idaapi.ITP_COLON):
tl.itp = itp
cfunc.set_user_cmt(tl, decrypted_string)
cfunc.save_user_cmts()
cfunc.__str__()
if not cfunc.has_orphan_cmts():
commentFlag = True
cfunc.save_user_cmts()
break
cfunc.del_orphan_cmts()
if not commentFlag:
print(
f"Failed to put in decompiler comment at: {hex(int.from_bytes(address, 'big'))}"
)
except Exception as e:
print(
f"Failed to put in decompiler comment at: {hex(int.from_bytes(address, 'big'))}"
)