Exemplo n.º 1
0
        public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
        {
            var dataList = new List <Elf32_Phdr>();
            var execList = new List <Elf32_Phdr>();

            foreach (var phdr in programSegment)
            {
                if (phdr.p_memsz != 0ul)
                {
                    switch (phdr.p_flags)
                    {
                    case 1u:     //PF_X
                    case 3u:
                    case 5u:
                    case 7u:
                        execList.Add(phdr);
                        break;

                    case 2u:     //PF_W && PF_R
                    case 4u:
                    case 6u:
                        dataList.Add(phdr);
                        break;
                    }
                }
            }
            var data          = dataList.ToArray();
            var exec          = execList.ToArray();
            var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);

            sectionHelper.SetSection(SearchSectionType.Exec, exec);
            sectionHelper.SetSection(SearchSectionType.Data, data);
            sectionHelper.SetSection(SearchSectionType.Bss, data);
            return(sectionHelper);
        }
Exemplo n.º 2
0
        public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
        {
            var execList = new List <SectionHeader>();
            var dataList = new List <SectionHeader>();

            foreach (var section in sections)
            {
                switch (section.Characteristics)
                {
                case 0x60000020:
                    execList.Add(section);
                    break;

                case 0x40000040:
                case 0xC0000040:
                    dataList.Add(section);
                    break;
                }
            }
            var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
            var data          = dataList.ToArray();
            var exec          = execList.ToArray();

            sectionHelper.SetSection(SearchSectionType.Exec, imageBase, exec);
            sectionHelper.SetSection(SearchSectionType.Data, imageBase, data);
            sectionHelper.SetSection(SearchSectionType.Bss, imageBase, data);
            return(sectionHelper);
        }
Exemplo n.º 3
0
        public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
        {
            var exec = new SearchSection
            {
                offset     = 0,
                offsetEnd  = (ulong)methodCount, //hack
                address    = 0,
                addressEnd = (ulong)methodCount  //hack
            };
            var data = new SearchSection
            {
                offset     = 1024,
                offsetEnd  = Length,
                address    = 1024,
                addressEnd = Length
            };
            var bss = new SearchSection
            {
                offset     = bssStart,
                offsetEnd  = long.MaxValue, //hack
                address    = bssStart,
                addressEnd = long.MaxValue  //hack
            };
            var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);

            sectionHelper.SetSection(SearchSectionType.Exec, exec);
            sectionHelper.SetSection(SearchSectionType.Data, data);
            sectionHelper.SetSection(SearchSectionType.Bss, bss);
            return(sectionHelper);
        }
Exemplo n.º 4
0
        public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
        {
            var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);

            sectionHelper.SetSection(SearchSectionType.Exec, header.TextSegment);
            sectionHelper.SetSection(SearchSectionType.Data, header.DataSegment, header.RoDataSegment);
            sectionHelper.SetSection(SearchSectionType.Bss, header.BssSegment);
            return(sectionHelper);
        }
Exemplo n.º 5
0
        public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
        {
            var data          = sections.Where(x => x.sectname == "__const" || x.sectname == "__cstring" || x.sectname == "__data").ToArray();
            var code          = sections.Where(x => x.flags == 0x80000400).ToArray();
            var bss           = sections.Where(x => x.flags == 1u).ToArray();
            var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);

            sectionHelper.SetSection(SearchSectionType.Exec, code);
            sectionHelper.SetSection(SearchSectionType.Data, data);
            sectionHelper.SetSection(SearchSectionType.Bss, bss);
            return(sectionHelper);
        }