From 30fd98b65a5bde549aa98df24f3498356c0f936c Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Thu, 16 Jan 2020 19:24:35 +0100 Subject: [PATCH] ELF: Fix incorrect DT_SYMTAB read offset (part of #15) --- Il2CppInspector/FileFormatReaders/ElfReader.cs | 8 ++++++-- Il2CppInspector/FileFormatReaders/WordConversions.cs | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector/FileFormatReaders/ElfReader.cs b/Il2CppInspector/FileFormatReaders/ElfReader.cs index 4935c96..77e5e77 100644 --- a/Il2CppInspector/FileFormatReaders/ElfReader.cs +++ b/Il2CppInspector/FileFormatReaders/ElfReader.cs @@ -1,6 +1,6 @@ /* Copyright 2017 Perfare - https://github.com/Perfare/Il2CppDumper - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -266,7 +266,11 @@ namespace Il2CppInspector var end = (from x in dynamic_table where conv.Gt(x.d_un, DT_SYMTAB.d_un) orderby x.d_un select x).First().d_un; // Dynamic symbol table - pTables.Add((DT_SYMTAB.d_un, conv.Div(conv.Sub(end, DT_SYMTAB.d_un), Sizeof(typeof(TSym))), DT_STRTAB.d_un)); + pTables.Add(( + conv.FromUInt(MapVATR(conv.ULong(DT_SYMTAB.d_un))), + conv.Div(conv.Sub(end, DT_SYMTAB.d_un), Sizeof(typeof(TSym))), + DT_STRTAB.d_un + )); } } diff --git a/Il2CppInspector/FileFormatReaders/WordConversions.cs b/Il2CppInspector/FileFormatReaders/WordConversions.cs index 52d920c..f56f3f2 100644 --- a/Il2CppInspector/FileFormatReaders/WordConversions.cs +++ b/Il2CppInspector/FileFormatReaders/WordConversions.cs @@ -1,5 +1,5 @@ /* - Copyright 2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2019-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com All rights reserved. */ @@ -16,6 +16,7 @@ namespace Il2CppInspector TWord Sub(TWord a, TWord b); TWord Div(TWord a, TWord b); TWord Div(TWord a, int b); + TWord FromUInt(uint a); int Int(TWord a); long Long(TWord a); ulong ULong(TWord a); @@ -29,18 +30,21 @@ namespace Il2CppInspector public uint Sub(uint a, uint b) => a - b; public uint Div(uint a, uint b) => a / b; public uint Div(uint a, int b) => a / (uint)b; + public uint FromUInt(uint a) => a; public int Int(uint a) => (int)a; public long Long(uint a) => a; public ulong ULong(uint a) => a; public bool Gt(uint a, uint b) => a > b; public uint[] UIntArray(uint[] a) => a; } + internal class Convert64 : IWordConverter { public ulong Add(ulong a, ulong b) => a + b; public ulong Sub(ulong a, ulong b) => a - b; public ulong Div(ulong a, ulong b) => a / b; public ulong Div(ulong a, int b) => a / (uint)b; + public ulong FromUInt(uint a) => a; public int Int(ulong a) => (int)a; public long Long(ulong a) => (long)a; public ulong ULong(ulong a) => a;