예제 #1
0
        private void LoadMod0Symbols(MemoryManager Memory, long TextOffset)
        {
            long Mod0Offset = TextOffset + Memory.ReadUInt32(TextOffset + 4);

            if (Mod0Offset < TextOffset || !Memory.IsMapped(Mod0Offset) || (Mod0Offset & 3) != 0)
            {
                return;
            }

            Dictionary <ElfDynamicTag, long> Dynamic = new Dictionary <ElfDynamicTag, long>();

            int Mod0Magic = Memory.ReadInt32(Mod0Offset + 0x0);

            if (Mod0Magic != Mod0)
            {
                return;
            }

            long DynamicOffset    = Memory.ReadInt32(Mod0Offset + 0x4) + Mod0Offset;
            long BssStartOffset   = Memory.ReadInt32(Mod0Offset + 0x8) + Mod0Offset;
            long BssEndOffset     = Memory.ReadInt32(Mod0Offset + 0xc) + Mod0Offset;
            long EhHdrStartOffset = Memory.ReadInt32(Mod0Offset + 0x10) + Mod0Offset;
            long EhHdrEndOffset   = Memory.ReadInt32(Mod0Offset + 0x14) + Mod0Offset;
            long ModObjOffset     = Memory.ReadInt32(Mod0Offset + 0x18) + Mod0Offset;

            while (true)
            {
                long TagVal = Memory.ReadInt64(DynamicOffset + 0);
                long Value  = Memory.ReadInt64(DynamicOffset + 8);

                DynamicOffset += 0x10;

                ElfDynamicTag Tag = (ElfDynamicTag)TagVal;

                if (Tag == ElfDynamicTag.DT_NULL)
                {
                    break;
                }

                Dynamic[Tag] = Value;
            }

            if (!Dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out long StrTab) ||
                !Dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out long SymTab) ||
                !Dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out long SymEntSize))
            {
                return;
            }

            long StrTblAddr = TextOffset + StrTab;
            long SymTblAddr = TextOffset + SymTab;

            List <ElfSymbol> Symbols = new List <ElfSymbol>();

            while ((ulong)SymTblAddr < (ulong)StrTblAddr)
            {
                ElfSymbol Sym = GetSymbol(Memory, SymTblAddr, StrTblAddr);

                Symbols.Add(Sym);

                SymTblAddr += SymEntSize;
            }

            lock (Images)
            {
                Images.Add(new Image(TextOffset, Symbols.OrderBy(x => x.Value).ToArray()));
            }
        }
예제 #2
0
        private void LoadMod0Symbols(IVirtualMemoryManager memory, ulong textOffset)
        {
            ulong mod0Offset = textOffset + memory.Read <uint>(textOffset + 4);

            if (mod0Offset < textOffset || !memory.IsMapped(mod0Offset) || (mod0Offset & 3) != 0)
            {
                return;
            }

            Dictionary <ElfDynamicTag, ulong> dynamic = new Dictionary <ElfDynamicTag, ulong>();

            int mod0Magic = memory.Read <int>(mod0Offset + 0x0);

            if (mod0Magic != Mod0)
            {
                return;
            }

            ulong dynamicOffset    = memory.Read <uint>(mod0Offset + 0x4) + mod0Offset;
            ulong bssStartOffset   = memory.Read <uint>(mod0Offset + 0x8) + mod0Offset;
            ulong bssEndOffset     = memory.Read <uint>(mod0Offset + 0xc) + mod0Offset;
            ulong ehHdrStartOffset = memory.Read <uint>(mod0Offset + 0x10) + mod0Offset;
            ulong ehHdrEndOffset   = memory.Read <uint>(mod0Offset + 0x14) + mod0Offset;
            ulong modObjOffset     = memory.Read <uint>(mod0Offset + 0x18) + mod0Offset;

            bool isAArch32 = memory.Read <ulong>(dynamicOffset) > 0xFFFFFFFF || memory.Read <ulong>(dynamicOffset + 0x10) > 0xFFFFFFFF;

            while (true)
            {
                ulong tagVal;
                ulong value;

                if (isAArch32)
                {
                    tagVal = memory.Read <uint>(dynamicOffset + 0);
                    value  = memory.Read <uint>(dynamicOffset + 4);

                    dynamicOffset += 0x8;
                }
                else
                {
                    tagVal = memory.Read <ulong>(dynamicOffset + 0);
                    value  = memory.Read <ulong>(dynamicOffset + 8);

                    dynamicOffset += 0x10;
                }

                ElfDynamicTag tag = (ElfDynamicTag)tagVal;

                if (tag == ElfDynamicTag.DT_NULL)
                {
                    break;
                }

                dynamic[tag] = value;
            }

            if (!dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out ulong strTab) ||
                !dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out ulong symTab) ||
                !dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out ulong symEntSize))
            {
                return;
            }

            ulong strTblAddr = textOffset + strTab;
            ulong symTblAddr = textOffset + symTab;

            List <ElfSymbol> symbols = new List <ElfSymbol>();

            while (symTblAddr < strTblAddr)
            {
                ElfSymbol sym = isAArch32 ? GetSymbol32(memory, symTblAddr, strTblAddr) : GetSymbol64(memory, symTblAddr, strTblAddr);

                symbols.Add(sym);

                symTblAddr += symEntSize;
            }

            lock (_images)
            {
                _images.Add(new Image(textOffset, symbols.OrderBy(x => x.Value).ToArray()));
            }
        }
예제 #3
0
 public ElfDynamic(ElfDynamicTag Tag, long Value)
 {
     this.Tag   = Tag;
     this.Value = Value;
 }
예제 #4
0
        private void LoadMod0Symbols(MemoryManager memory, long textOffset)
        {
            long mod0Offset = textOffset + memory.ReadUInt32(textOffset + 4);

            if (mod0Offset < textOffset || !memory.IsMapped(mod0Offset) || (mod0Offset & 3) != 0)
            {
                return;
            }

            Dictionary <ElfDynamicTag, long> dynamic = new Dictionary <ElfDynamicTag, long>();

            int mod0Magic = memory.ReadInt32(mod0Offset + 0x0);

            if (mod0Magic != Mod0)
            {
                return;
            }

            long dynamicOffset    = memory.ReadInt32(mod0Offset + 0x4) + mod0Offset;
            long bssStartOffset   = memory.ReadInt32(mod0Offset + 0x8) + mod0Offset;
            long bssEndOffset     = memory.ReadInt32(mod0Offset + 0xc) + mod0Offset;
            long ehHdrStartOffset = memory.ReadInt32(mod0Offset + 0x10) + mod0Offset;
            long ehHdrEndOffset   = memory.ReadInt32(mod0Offset + 0x14) + mod0Offset;
            long modObjOffset     = memory.ReadInt32(mod0Offset + 0x18) + mod0Offset;

            while (true)
            {
                long tagVal = memory.ReadInt64(dynamicOffset + 0);
                long value  = memory.ReadInt64(dynamicOffset + 8);

                dynamicOffset += 0x10;

                ElfDynamicTag tag = (ElfDynamicTag)tagVal;

                if (tag == ElfDynamicTag.DT_NULL)
                {
                    break;
                }

                dynamic[tag] = value;
            }

            if (!dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out long strTab) ||
                !dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out long symTab) ||
                !dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out long symEntSize))
            {
                return;
            }

            long strTblAddr = textOffset + strTab;
            long symTblAddr = textOffset + symTab;

            List <ElfSymbol> symbols = new List <ElfSymbol>();

            while ((ulong)symTblAddr < (ulong)strTblAddr)
            {
                ElfSymbol sym = GetSymbol(memory, symTblAddr, strTblAddr);

                symbols.Add(sym);

                symTblAddr += symEntSize;
            }

            lock (_images)
            {
                _images.Add(new Image(textOffset, symbols.OrderBy(x => x.Value).ToArray()));
            }
        }
예제 #5
0
 public ElfDynamic(ElfDynamicTag tag, long value)
 {
     Tag   = tag;
     Value = value;
 }