def GetNameFlags(name, ea): flags = 0 # we don't know what name_value is... name_value, _name_value = idaapi.get_name_value(ea, name) # if(addr != ea): # if(addr == (ea | 0x100000000) or addr == (ea & 0xFFFFFFFF)): # logger.warn("(IDA bug) get_name_value returned bad address : 0x%016X (instead of 0x%016X)" % (addr, ea)) # else: # logger.warn("get_name_value returned bad address : "\ # "0x%016X (instead of 0x%016X), using idc.SN_CHECK" % (addr, ea)) # return default value used by MakeName # return idc.SN_CHECK if name_value == idaapi.NT_LOCAL: # see name.hpp : LOCAL names can not be public nor weak, and are not listed flags |= idaapi.SN_LOCAL | idaapi.SN_NON_PUBLIC | idaapi.SN_NON_WEAK | idaapi.SN_NOLIST else: if idaapi.is_public_name(ea): flags |= idaapi.SN_PUBLIC else: flags |= idaapi.SN_NON_PUBLIC if idaapi.is_weak_name(ea): flags |= idaapi.SN_WEAK else: flags |= idaapi.SN_NON_WEAK if idaapi.is_in_nlist(ea) is False: flags |= idaapi.SN_NOLIST ida_flags = idc.GetFlags(ea) if idaapi.has_user_name(ida_flags) or idc.hasUserName(ida_flags): flags |= idc.SN_NON_AUTO elif idaapi.has_auto_name(ida_flags): flags |= idc.SN_AUTO elif idaapi.has_dummy_name(ida_flags): # names like "dword_XXXX" flags |= idc.SN_AUTO else: logger.debug("name is not user nor auto?? at 0x%016X : 0x%08X" % (ea, ida_flags)) return flags
def contains(cls, ea): '''Return whether the address `ea` is referenced in the names list.''' return idaapi.is_in_nlist(ea)
def contains(cls, ea): return idaapi.is_in_nlist(ea)
def contains(cls, ea): '''Return whether the address `ea` is referenced in the names list.''' return idaapi.is_in_nlist(ea)
def name(ea=None, *args, **kwds): """name(ea), name(ea, string) First syntax returns the name at the given address. Second syntax changes the name at the given address. """ if len(args) > 1: raise TypeError, "{:s}() takes exactly {!r} arguments ({:d} given)".format( 'name', (1, 2), len(args) + 1 + len(kwds)) if kwds and tuple(kwds.keys()) != ('string', ): raise TypeError, "{:s}() got an unexpected keyword argument '{:s}'".format( 'name', filter(lambda n: n != 'string', kwds.keys())[0]) ea = ui.current.address() if ea is None else ea if len(args) == 1 or kwds.has_key('string'): string = kwds.get('string', args[0]) assert idaapi.SN_NOCHECK == 0, '%s.name : idaapi.SN_NOCHECK != 0' % __name__ SN_NOLIST = idaapi.SN_NOLIST SN_LOCAL = idaapi.SN_LOCAL SN_NON_PUBLIC = idaapi.SN_NON_PUBLIC if idaapi.has_any_name(idaapi.getFlags(ea)): pass flags = idaapi.SN_NON_AUTO flags |= 0 if idaapi.is_in_nlist(ea) else idaapi.SN_NOLIST flags |= idaapi.SN_WEAK if idaapi.is_weak_name( ea) else idaapi.SN_NON_WEAK flags |= idaapi.SN_PUBLIC if idaapi.is_public_name( ea) else idaapi.SN_NON_PUBLIC try: function.top(ea) flags |= idaapi.SN_LOCAL except Exception: flags &= ~idaapi.SN_LOCAL try: # check if we're a label of some kind f = idaapi.getFlags(ea) if idaapi.has_dummy_name(f) or idaapi.has_user_name(f): # that is referenced by an array with a correctly sized pointer inside it (r, sidata), = ((r, type.array(r)) for r in xref.data_up(ea)) if config.bits() == sidata.itemsize * 8 and ea in sidata: # which we check to see if it's a switch_info_t si, = (idaapi.get_switch_info_ex(r) for r in xref.data_up(r)) if si is not None: # because it's name has it's local flag cleared flags ^= idaapi.SN_LOCAL except: pass res, ok = name(ea), idaapi.set_name(ea, string or "", flags) tag(ea, 'name', string) assert ok, '%s.name : unable to call idaapi.set_name(%x, %r, %x)' % ( __name__, ea, string, flags) return res try: return tag(ea, 'name') except KeyError: pass return None
def hasListedName(ea=None): ea = ui.current.address() if ea is None else ea return idaapi.is_in_nlist(ea)