示例#1
0
        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;
        }