コード例 #1
0
ファイル: CachedStream.cs プロジェクト: rmhasan/FlingOS
        public CachedFileStream(FileStream AnUnderlyingStream)
            : base(AnUnderlyingStream.TheFile)
        {
            UnderlyingStream = AnUnderlyingStream;

            CachedData = new byte[(uint)TheFile.Size];
            UnderlyingStream.Read(CachedData, 0, CachedData.Length);
        }
コード例 #2
0
ファイル: ELFFile.cs プロジェクト: rmhasan/FlingOS
 public ELFFile(File file)
 {
     theFile = file;
     if (theFile == null)
     {
         Console.Default.ErrorColour();
         Console.Default.Write("Error constructing ELF file! theFile is null");
         BasicConsole.Write("Error constructing ELF file! theFile is null");
         if (file == null)
         {
             Console.Default.Write(" and file is null");
             BasicConsole.Write(" and file is null");
         }
         else
         {
             Console.Default.Write(" and file is NOT null");
             BasicConsole.Write(" and file is NOT null");
         }
         Console.Default.WriteLine(".");
         BasicConsole.WriteLine(".");
         Console.Default.DefaultColour();
         ExceptionMethods.Throw(new FOS_System.Exception("Error loading ELF file! Supplied file is null."));
     }
     theStream = new CachedFileStream(theFile.GetStream());
     ReadHeader();
     
     if (IsValidFile())
     {
         ReadSectionHeaders();
         ReadSegmentHeaders();
     }
 }
コード例 #3
0
ファイル: ELFSegments.cs プロジェクト: kztao/FlingOS
 public virtual int Read(FileStream stream)
 {
     data = new byte[header.FileSize];
     stream.Position = header.FileOffset;
     int bytesRead = stream.Read(data, 0, data.Length);
     if (bytesRead != data.Length)
     {
         ExceptionMethods.Throw(new FOS_System.Exception("Failed to read segment data from file!"));
     }
     return bytesRead;
 }
コード例 #4
0
ファイル: ELFSections.cs プロジェクト: rmhasan/FlingOS
        public override int Read(FileStream stream)
        {
            dynamics.Empty();

            int bytesRead = base.Read(stream);
            uint offset = 0;
            Dynamic currDynamic;
            while (offset < bytesRead)
            {
                currDynamic = new Dynamic();

                currDynamic.Tag = (DynamicTag)ByteConverter.ToUInt32(data, offset + 0);
                currDynamic.Val_Ptr = ByteConverter.ToUInt32(data, offset + 4);

                dynamics.Add(currDynamic);

                offset += header.EntrySize;
            }

            return dynamics.Count;
        }
コード例 #5
0
ファイル: ELFSections.cs プロジェクト: rmhasan/FlingOS
        public override int Read(FileStream stream)
        {
            relocations.Empty();

            int bytesRead = base.Read(stream);
            uint offset = 0;
            RelocationAddend currRelocation;
            while (offset < bytesRead)
            {
                currRelocation = new RelocationAddend();

                currRelocation.Offset = (byte*)ByteConverter.ToUInt32(data, offset + 0);
                currRelocation.Info = ByteConverter.ToUInt32(data, offset + 4);
                currRelocation.Addend = (short)ByteConverter.ToUInt16(data, offset + 8);

                relocations.Add(currRelocation);

                offset += header.EntrySize;
            }

            return relocations.Count;
        }
コード例 #6
0
ファイル: ELFSections.cs プロジェクト: rmhasan/FlingOS
        public override int Read(FileStream stream)
        {
            symbols.Empty();

            int bytesRead = base.Read(stream);
            uint offset = 0;
            Symbol currSymbol;
            while (offset < bytesRead)
            {
                currSymbol = new Symbol();

                currSymbol.NameIdx = ByteConverter.ToUInt32(data, offset + 0);
                currSymbol.Value = (byte*)ByteConverter.ToUInt32(data, offset + 4);
                currSymbol.Size = ByteConverter.ToUInt32(data, offset + 8);
                currSymbol.Info = data[offset + 12];
                currSymbol.Other = data[offset + 13];
                currSymbol.SectionIndex = ByteConverter.ToUInt16(data, offset + 14);

                symbols.Add(currSymbol);

                offset += header.EntrySize;
            }

            return symbols.Count;
        }