示例#1
0
        public static ELFSegment GetSegment(ELFSegmentHeader header)
        {
            //if (header.Type == ElfSegmentTypes.???)
            //{
            //    return new ELF???Segment(header);
            //}

            return(new ELFSegment(header));
        }
示例#2
0
        public void ReadSegmentHeaders()
        {
            byte[] segmentsData = new byte[header.ProgHeaderEntrySize * header.ProgHeaderNumEntries];
            theStream.Position = header.ProgHeaderTableOffset;
            int bytesRead = theStream.Read(segmentsData, 0, segmentsData.Length);

            if (bytesRead == segmentsData.Length)
            {
                uint offset = 0;
                while (offset < segmentsData.Length)
                {
                    ELFSegmentHeader newHeader  = new ELFSegmentHeader(segmentsData, ref offset);
                    ELFSegment       newSegment = ELFSegment.GetSegment(newHeader);

                    newSegment.Read(theStream);

                    Segments.Add(newSegment);
                }

                //BasicConsole.WriteLine();

                #region Segments Output

                //for (int i = 0; i < Segments.Count; i++)
                //{
                //    ELFSegment theSegment = (ELFSegment)Segments[i];
                //    ELFSegmentHeader theHeader = theSegment.Header;
                //    BasicConsole.WriteLine("ELF Segment: ");
                //    BasicConsole.Write(" - Type : ");
                //    BasicConsole.WriteLine((uint)theHeader.Type);
                //    BasicConsole.Write(" - File offset : ");
                //    BasicConsole.WriteLine(theHeader.FileOffset);
                //    BasicConsole.Write(" - Virtual address : ");
                //    BasicConsole.WriteLine((uint)theHeader.VAddr);
                //    BasicConsole.Write(" - Physical address : ");
                //    BasicConsole.WriteLine((uint)theHeader.PAddr);
                //    BasicConsole.Write(" - File size : ");
                //    BasicConsole.WriteLine(theHeader.FileSize);
                //    BasicConsole.Write(" - Memory size : ");
                //    BasicConsole.WriteLine(theHeader.MemSize);
                //    BasicConsole.Write(" - Flags : ");
                //    BasicConsole.WriteLine((uint)theHeader.Flags);
                //    BasicConsole.Write(" - Alignment : ");
                //    BasicConsole.WriteLine(theHeader.Align);

                //    Hardware.Processes.Thread.Sleep(500);
                //      TODO: Use system call not direct call
                //}

                #endregion
            }
            else
            {
                ExceptionMethods.Throw(new FOS_System.Exception("Failed to read segments table data from file!"));
            }
        }
示例#3
0
        public void ReadSegmentHeaders()
        {
            byte[] segmentsData = new byte[header.ProgHeaderEntrySize * header.ProgHeaderNumEntries];
            theStream.Position = header.ProgHeaderTableOffset;
            int bytesRead = theStream.Read(segmentsData, 0, segmentsData.Length);

            if (bytesRead == segmentsData.Length)
            {
                uint offset = 0;
                while (offset < segmentsData.Length)
                {
                    ELFSegmentHeader newHeader = new ELFSegmentHeader(segmentsData, ref offset);
                    ELFSegment newSegment = ELFSegment.GetSegment(newHeader);
                    
                    newSegment.Read(theStream);

                    Segments.Add(newSegment);
                }

                //BasicConsole.WriteLine();

                #region Segments Output

                //for (int i = 0; i < Segments.Count; i++)
                //{
                //    ELFSegment theSegment = (ELFSegment)Segments[i];
                //    ELFSegmentHeader theHeader = theSegment.Header;
                //    BasicConsole.WriteLine("ELF Segment: ");
                //    BasicConsole.Write(" - Type : ");
                //    BasicConsole.WriteLine((uint)theHeader.Type);
                //    BasicConsole.Write(" - File offset : ");
                //    BasicConsole.WriteLine(theHeader.FileOffset);
                //    BasicConsole.Write(" - Virtual address : ");
                //    BasicConsole.WriteLine((uint)theHeader.VAddr);
                //    BasicConsole.Write(" - Physical address : ");
                //    BasicConsole.WriteLine((uint)theHeader.PAddr);
                //    BasicConsole.Write(" - File size : ");
                //    BasicConsole.WriteLine(theHeader.FileSize);
                //    BasicConsole.Write(" - Memory size : ");
                //    BasicConsole.WriteLine(theHeader.MemSize);
                //    BasicConsole.Write(" - Flags : ");
                //    BasicConsole.WriteLine((uint)theHeader.Flags);
                //    BasicConsole.Write(" - Alignment : ");
                //    BasicConsole.WriteLine(theHeader.Align);

                //    Hardware.Processes.Thread.Sleep(500);
                //      TODO: Use system call not direct call
                //}

                #endregion
            }
            else
            {
                ExceptionMethods.Throw(new FOS_System.Exception("Failed to read segments table data from file!"));
            }
        }
示例#4
0
        public static ELFSegment GetSegment(ELFSegmentHeader header)
        {
            //if (header.Type == ElfSegmentTypes.???)
            //{
            //    return new ELF???Segment(header);
            //}

            return new ELFSegment(header);
        }
示例#5
0
 protected ELFSegment(ELFSegmentHeader aHeader)
 {
     header = aHeader;
 }
示例#6
0
 protected ELFSegment(ELFSegmentHeader aHeader)
 {
     header = aHeader;
 }