Exemple #1
0
 public Method FindMethod(int address)
 {
     if (_methodLookup.ContainsKey(address) == true)
     {
         return(_methodLookup[address]);
     }
     else
     {
         for (int n = 0; n < _methods.Count; n++)
         {
             ElfMethod method = _methods[n];
             if ((method.EntryAddress <= address) &&
                 ((method.EntryAddress + method.Length) > address))
             {
                 return(method);
             }
         }
         return(null);
     }
 }
        private List <ElfMethod> GetMethods(Stream source)
        {
            List <ElfMethod> methods = new List <ElfMethod>();

            ElfFile elf      = new ElfFile(source);
            bool    relocate = (elf.EntryAddress < 0x08900000);

            // Get functions
            List <ElfFile.ElfSymbol> symbols = elf.Symbols;

            foreach (ElfFile.ElfSymbol symbol in symbols)
            {
                // Some NOTYPES are valid, like ctor/dtor aux, frame_dummy, etc.
                // Unfortunately, so many are bad that I can't just include them :(

                if (symbol.SymbolType == ElfFile.ElfSymbolType.Function)
                {
                    // Skip ones with no address (do we skip 0 length too?)
                    if (symbol.Value == 0)
                    {
                        continue;
                    }

                    int address = ( int )symbol.Value;
                    if (relocate == true)
                    {
                        address += 0x08900000;
                    }

                    ElfMethod method = new ElfMethod(address, ( int )symbol.Size, symbol.Name);
                    methods.Add(method);
                }
            }

            return(methods);
        }
        private List<ElfMethod> GetMethods( Stream source )
        {
            List<ElfMethod> methods = new List<ElfMethod>();

            ElfFile elf = new ElfFile( source );
            bool relocate = ( elf.EntryAddress < 0x08900000 );

            // Get functions
            List<ElfFile.ElfSymbol> symbols = elf.Symbols;
            foreach( ElfFile.ElfSymbol symbol in symbols )
            {
                // Some NOTYPES are valid, like ctor/dtor aux, frame_dummy, etc.
                // Unfortunately, so many are bad that I can't just include them :(

                if( symbol.SymbolType == ElfFile.ElfSymbolType.Function )
                {
                    // Skip ones with no address (do we skip 0 length too?)
                    if( symbol.Value == 0 )
                        continue;

                    int address = ( int )symbol.Value;
                    if( relocate == true )
                        address += 0x08900000;

                    ElfMethod method = new ElfMethod( address, ( int )symbol.Size, symbol.Name );
                    methods.Add( method );
                }
            }

            return methods;
        }