diff --git a/Il2CppInspector.Common/FileFormatStreams/MachOReader.cs b/Il2CppInspector.Common/FileFormatStreams/MachOReader.cs index 9f78c42..dd97d45 100644 --- a/Il2CppInspector.Common/FileFormatStreams/MachOReader.cs +++ b/Il2CppInspector.Common/FileFormatStreams/MachOReader.cs @@ -65,6 +65,7 @@ namespace Il2CppInspector private MachOHeader header; protected readonly List> machoSections = new List>(); private List
sections = new List
(); + private Dictionary symbolTable; private MachOSection funcTab; private MachOSymtabCommand symTab; @@ -191,6 +192,10 @@ namespace Il2CppInspector break; } } + + // Build symbol table + processSymbols(); + return true; } @@ -239,14 +244,14 @@ namespace Il2CppInspector } } - public override uint[] GetFunctionTable() => ReadArray(funcTab.ImageOffset, conv.Int(funcTab.Size) / (Bits / 8)).Select(x => MapVATR(conv.ULong(x)) & 0xffff_fffe).ToArray(); - - public override Dictionary GetSymbolTable() { - var symbols = new Dictionary(); - + private void processSymbols() { // https://opensource.apple.com/source/cctools/cctools-795/include/mach-o/nlist.h // n_sect: https://opensource.apple.com/source/cctools/cctools-795/include/mach-o/stab.h + StatusUpdate("Processing symbols"); + + symbolTable = new Dictionary(); + var symbolList = ReadArray>(symTab.SymOffset, (int) symTab.NumSyms); // This is a really naive implementation that ignores the values of n_type and n_sect @@ -281,11 +286,14 @@ namespace Il2CppInspector } // Ignore duplicates - symbols.TryAdd(name, new Symbol { Name = name, VirtualAddress = value, Type = type }); + symbolTable.TryAdd(name, new Symbol { Name = name, VirtualAddress = value, Type = type }); } - return symbols; } + public override uint[] GetFunctionTable() => ReadArray(funcTab.ImageOffset, conv.Int(funcTab.Size) / (Bits / 8)).Select(x => MapVATR(conv.ULong(x)) & 0xffff_fffe).ToArray(); + + public override Dictionary GetSymbolTable() => symbolTable; + public override IEnumerable GetExports() => exports; public override IEnumerable
GetSections() => sections;