def rename(self, ea, name): # Don't rely on the name in curfunc, as it could have already been renamed curname = idc.get_name(ea, ida_name.GN_VISIBLE) # Don't rename if the name is a special identifier, or if the ea has already been named # TODO: What's a better way to check for reserved name prefixes? if curname.startswith('sub_') and name.split('_')[0] not in {'sub', 'loc', 'unk', 'dword', 'word', 'byte'}: # Don't rename if the name already exists in the IDB if idc.get_name_ea_simple(name) == idc.BADADDR: if idc.set_name(ea, name, ida_name.SN_CHECK): idc.set_func_attr(ea, idc.FUNCATTR_FLAGS, (idc.get_func_attr(ea, idc.FUNCATTR_FLAGS) | idc.FUNC_LIB)) # print "%s => %s" % (curname, name) return 1 # else: # print "WARNING: Attempted to rename '%s' => '%s', but '%s' already exists!" % (curname, name, name) return 0
def SetFuncFlags(ea): func_flags = idc.get_func_attr(ea, FUNCATTR_FLAGS) func_flags |= 0x84 # FUNC_THUNK|FUNC_LIB idc.set_func_attr(ea, FUNCATTR_FLAGS, func_flags)
def SetFunctionFlags(ea, flags): return idc.set_func_attr(ea, FUNCATTR_FLAGS, flags)