parameters: (x,Demangler=DemangleShort)
docstring: Given X, which is either a symbol triplet or integer, give it
      a name if possible.  Otherwise, is a pass-through to addr.Clickable
  
      >>> ToAddress(0x1391292)
      _main+192h
      >>> ToName(('msvcrt','malloc',15))
      msvcr!malloc+0Fh
      >>> ToName(3)
      00000003
docstring_summary: Given X, which is either a symbol triplet or integer, give it
      a name if possible.  Otherwise, is a pass-through to addr.Clickable
docstring_tokens: Given X which is either a symbol triplet or integer give it a name if possible . Otherwise is a pass - through to addr . Clickable
function: def ToName(x,Demangler=DemangleShort):
      """
      Given X, which is either a symbol triplet or integer, give it
      a name if possible.  Otherwise, is a pass-through to addr.Clickable
  
      >>> ToAddress(0x1391292)
      _main+192h
      >>> ToName(('msvcrt','malloc',15))
      msvcr!malloc+0Fh
      >>> ToName(3)
      00000003
      """
      # print x
      # print hasattr(x,'__len__')
      # try: print len(x)
      # except: pass
      if type(x) in (int,long):
          # If the address is within the bounds of the file loaded in IDA,
          # Attempt to resolve in IDA.  First try an exact name
          # (offset zero) and then just walk backward until we
          # find something.
          if addr.Min() <= x and x < addr.Max():
              FuncOffsetWithArgs = ida.GetFuncOffset(x)
              if FuncOffsetWithArgs:
                  return re.sub('\([^)]+\)', '', FuncOffsetWithArgs)
  
              for Offset in xrange(0,256):
                  NameInIDA = ida.NameEx(ida.BADADDR,x - Offset)
                  NameInIDA = Demangler(NameInIDA)
                  if NameInIDA:
                      return NameInIDA + MakeOffset(Offset)
          # Try to find another module within which the address belongs,
          # and state it as an offset from the base of the module.
          # If the address is not within any module, return the value provided
          # by addr.Clickable()
          else:
              for module in database.modules.find():
                  Base = module['Base']
                  End  = module['End']
                  if Base <= x and x < End:
                      return "%s%s" % (module['Name'], MakeOffset(x-Base))
              return None # ??? addr.Clickable(x)
  
      elif type(x) in (str,unicode):
          return str(x)
      elif isinstance(x, collections.Iterable) and len(x) == 3:
          (module,routine,offset) = x
          rv = ''
          if   module and routine:  rv = module + "!" + routine
          elif module:              rv = module
          elif routine:             rv = routine
          if   offset:              rv += "%s" % MakeOffset(offset)
          return rv
      else:
          raise TypeError('Cannot convert %r to name' % x)
function_tokens: def ToName ( x , Demangler = DemangleShort ) : # print x # print hasattr(x,'__len__') # try: print len(x) # except: pass if type ( x ) in ( int , long ) : # If the address is within the bounds of the file loaded in IDA, # Attempt to resolve in IDA.  First try an exact name # (offset zero) and then just walk backward until we # find something. if addr . Min ( ) <= x and x < addr . Max ( ) : FuncOffsetWithArgs = ida . GetFuncOffset ( x ) if FuncOffsetWithArgs : return re . sub ( '\([^)]+\)' , '' , FuncOffsetWithArgs ) for Offset in xrange ( 0 , 256 ) : NameInIDA = ida . NameEx ( ida . BADADDR , x - Offset ) NameInIDA = Demangler ( NameInIDA ) if NameInIDA : return NameInIDA + MakeOffset ( Offset ) # Try to find another module within which the address belongs, # and state it as an offset from the base of the module. # If the address is not within any module, return the value provided # by addr.Clickable() else : for module in database . modules . find ( ) : Base = module [ 'Base' ] End = module [ 'End' ] if Base <= x and x < End : return "%s%s" % ( module [ 'Name' ] , MakeOffset ( x - Base ) ) return None # ??? addr.Clickable(x) elif type ( x ) in ( str , unicode ) : return str ( x ) elif isinstance ( x , collections . Iterable ) and len ( x ) == 3 : ( module , routine , offset ) = x rv = '' if module and routine : rv = module + "!" + routine elif module : rv = module elif routine : rv = routine if offset : rv += "%s" % MakeOffset ( offset ) return rv else : raise TypeError ( 'Cannot convert %r to name' % x )