def rename(ea, newname):
fl = database.type.flags(ea)
labelQ, customQ = (fl & n == n for n in (idaapi.FF_LABL,idaapi.FF_NAME))
#r, fn = database.xref.up(ea), idaapi.get_func(ea)
fn = idaapi.get_func(ea)
# figure out whether a global or function name is being changed, otherwise it's the function's contents
ctx = internal.comment.globals if not fn or (fn.startEA == ea) else internal.comment.contents
# if a name is being removed
if not newname:
# if it's a custom name
if (not labelQ and customQ):
ctx.dec(ea, '__name__')
return
# if it's currently a label or is unnamed
if (labelQ and not customQ) or all(not n for n in (labelQ,customQ)):
ctx.inc(ea, '__name__')
return
评论列表
文章目录