From 5e435465f185e45c1e96e16a5717b70e4192344e Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 16 Jun 2020 15:35:00 +0200 Subject: [PATCH] ELF: Don't crash on duplicate section names (#26) --- Il2CppInspector.Common/FileFormatReaders/ElfReader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs b/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs index 582619f..fb81057 100644 --- a/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs @@ -150,11 +150,13 @@ namespace Il2CppInspector section_header_table = ReadArray>(conv.Long(elf_header.e_shoff), elf_header.e_shnum); // Get section name mappings if there are any + // This is currently only used to defeat the XOR obfuscation handled below + // Note: There can be more than one section with the same name, or unnamed; we take the first section with a given name if (elf_header.e_shtrndx < section_header_table.Length) { var pStrtab = section_header_table[elf_header.e_shtrndx].sh_offset; foreach (var section in section_header_table) { var name = ReadNullTerminatedString(conv.Long(pStrtab) + section.sh_name); - sectionByName.Add(name, section); + sectionByName.TryAdd(name, section); } }