Пример #1
0
        static void SetupOriginalKernelElf()
        {
            uint kernelElfHeaderAddr = Address.OriginalKernelElfSection;
            var  kernelElfHeader     = (ElfHeader *)kernelElfHeaderAddr;

            OriginalKernelElf = new ElfHelper
            {
                PhyOffset                     = kernelElfHeaderAddr,
                SectionHeaderArray            = (ElfSectionHeader *)(kernelElfHeaderAddr + kernelElfHeader->ShOff),
                SectionHeaderCount            = kernelElfHeader->ShNum,
                StringTableSectionHeaderIndex = kernelElfHeader->ShStrNdx
            };
            OriginalKernelElf.Init();
        }
Пример #2
0
        /// <summary>
        /// Currently unused, because Kernel is loaded via from kernel.loader
        /// </summary>

        /*unsafe static ElfHelper FromMultiBootInfo(MultiBootInfo* multiBootInfo)
         * {
         *  var helper = new ElfHelper
         *  {
         *      SectionHeaderArray = (ElfSectionHeader*)multiBootInfo->ElfSectionHeader->Addr,
         *      StringTableSectionHeaderIndex = multiBootInfo->ElfSectionHeader->Shndx,
         *      SectionHeaderCount = multiBootInfo->ElfSectionHeader->Count
         *  };
         *  helper.Init();
         *  return helper;
         * }*/

        unsafe static ElfHelper FromAddress(Addr elfStart)
        {
            var elfHeader = (ElfHeader *)elfStart;

            if (elfHeader->Ident1 != ElfHeader.Magic1)
            {
                KernelMessage.WriteLine("No valid ELF found at {0:X8}", elfStart);
                // TODO: Throw Excetion
            }
            var helper = new ElfHelper
            {
                PhyOffset                     = elfStart,
                SectionHeaderArray            = (ElfSectionHeader *)(elfStart + elfHeader->ShOff),
                SectionHeaderCount            = elfHeader->ShNum,
                StringTableSectionHeaderIndex = elfHeader->ShStrNdx
            };

            helper.Init();
            return(helper);
        }