Exemple #1
0
 public DWARFData(IELF elf)
 {
     // The order of loaded sections matters, do not change.
     StringSection = new DebugStringsSection(elf.GetSection(".debug_str"));
     AbbrevSection = new DebugAbbrevSection(elf.GetSection(".debug_abbrev"));
     InfoSection   = new DebugInfoSection(this, elf.GetSection(".debug_info"));
     LineSection   = new DebugLineSection(this, elf.GetSection(".debug_line"));
 }
Exemple #2
0
        public static void Main(string[] args)
        {
            Console.Title = "MinecraftSymbols";

            Console.WriteLine("File path :");
            Console.Write("> ");
            string FilePath = Console.ReadLine();

            if (!File.Exists(FilePath))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("File not found.");
                Console.ReadKey();
                return;
            }

            InitDump();

            Thread.Sleep(1000);
            writeCpp("// File automatically generated by MinecraftSymbols");
            writeCpp("");

            IELF Elf = ELFReader.Load(FilePath);
            SymbolTable <uint> Symbols = (SymbolTable <uint>)Elf.GetSection(".dynsym");

            foreach (var Symbol in Symbols.Entries)
            {
                Console.Title = "MinecraftSymbols || " + Dumped + " symbols";

                if (Symbol.Value != 0 && Symbol.Name.StartsWith("_Z"))
                {
                    // ToDo more work on writeCpp
                    if (Symbol.Type == SymbolType.Object)
                    {
                        writeCpp("// Address : " + Symbol.Value.ToString("x8"));
                        writeCpp("extern \"C\"" + Environment.NewLine + "{" + Environment.NewLine + "    void* " + Symbol.Name + ";\n}");
                        writeCpp("");
                    }

                    if (Symbol.Type == SymbolType.Function)
                    {
                        writeCpp("// Address : " + Symbol.Value.ToString("x8"));
                        writeCpp("extern \"C\"" + Environment.NewLine + "{" + Environment.NewLine + "    void* " + Symbol.Name + "_ptr;\n}");
                        writeCpp("");
                    }

                    Dumped++;
                    Console.WriteLine("Dumped symbol : " + Symbol.Name + " (" + Symbol.Value.ToString("x8") + ")");
                }
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("All the Minecraft symbols have been dumped.");
            Console.ReadKey();
        }
Exemple #3
0
        private Symbol LoadDebugContextInfo(IELF elfFile)
        {
            var symbols = ((ISymbolTable)elfFile.GetSection(".symtab")).Entries.Where(x => x.Type == SymbolType.Object);

            if (_debugCtxSymbol == null)
            {
                var entry = symbols.FirstOrDefault(s => s.Name == "dbg_context");
                if (entry != null)
                {
                    return(new Symbol
                    {
                        Size = (uint)entry.Size,
                        Location = (uint)(entry.Value - _entryOffset)
                    });
                }
            }
            return(null);
        }
Exemple #4
0
 public ISection GetSection(string name)
 {
     return(_inner.GetSection(name));
 }
 public ISection GetSection(int index)
 {
     return(_inner.GetSection(index));
 }