public CachedFileStream(FileStream AnUnderlyingStream) : base(AnUnderlyingStream.TheFile) { UnderlyingStream = AnUnderlyingStream; CachedData = new byte[(uint)TheFile.Size]; UnderlyingStream.Read(CachedData, 0, CachedData.Length); }
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(); } }
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; }
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; }
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; }
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; }