Esempio n. 1
0
 /// <inheritdoc />
 public IDebugDataSegment ReadDebugData(PEReaderContext context, DebugDataType type,
                                        IBinaryStreamReader reader)
 {
     return(type switch
     {
         DebugDataType.CodeView => CodeViewDataSegment.FromReader(context, reader),
         _ => new CustomDebugDataSegment(type, DataSegment.FromReader(reader))
     });
Esempio n. 2
0
 /// <summary>
 /// Create a program debug database from the given executable stream.
 /// </summary>
 /// <param name="dataType">The type of data to load from the stream.</param>
 /// <param name="stream">A stream containing the executable bytes.</param>
 /// <returns>A new <see cref="IProgramDebugData"/> instance of the given <paramref name="dataType"/>.</returns>
 public static IProgramDebugData Load( DebugDataType dataType, Stream stream )
 {
     switch( dataType )
     {
         case DebugDataType.Elf:
             ElfDebugData edd = new ElfDebugData( stream );
             return edd;
         case DebugDataType.Symbols:
             SimpleElfDebugData sdd = new SimpleElfDebugData( stream );
             return sdd;
         default:
             throw new NotImplementedException();
     }
 }
Esempio n. 3
0
        /// <inheritdoc />
        public IDebugDataSegment ReadDebugData(DebugDataType type, uint rva, uint size)
        {
            var reference = _resolver.GetReferenceToRva(rva);

            if (reference is null || !reference.CanRead)
            {
                return(null);
            }

            var reader = reference.CreateReader();

            reader.ChangeSize(size);

            return(new CustomDebugDataSegment(type, DataSegment.FromReader(reader)));
        }
Esempio n. 4
0
        /// <summary>
        /// Create a program debug database from the given executable stream.
        /// </summary>
        /// <param name="dataType">The type of data to load from the stream.</param>
        /// <param name="stream">A stream containing the executable bytes.</param>
        /// <returns>A new <see cref="IProgramDebugData"/> instance of the given <paramref name="dataType"/>.</returns>
        public static IProgramDebugData Load(DebugDataType dataType, Stream stream)
        {
            switch (dataType)
            {
            case DebugDataType.Elf:
                ElfDebugData edd = new ElfDebugData(stream);
                return(edd);

            case DebugDataType.Symbols:
                SimpleElfDebugData sdd = new SimpleElfDebugData(stream);
                return(sdd);

            default:
                throw new NotImplementedException();
            }
        }
        /// <summary>
        /// Reads a single debug data entry from an input stream.
        /// </summary>
        /// <param name="reader">The input stream.</param>
        /// <param name="dataReader">The object responsible for reading the contents.</param>
        public SerializedDebugDataEntry(IBinaryStreamReader reader, IDebugDataReader dataReader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            _dataReader = dataReader ?? throw new ArgumentNullException(nameof(dataReader));
            Offset      = reader.Offset;
            Rva         = reader.Rva;

            Characteristics   = reader.ReadUInt32();
            TimeDateStamp     = reader.ReadUInt32();
            MajorVersion      = reader.ReadUInt16();
            MinorVersion      = reader.ReadUInt16();
            _type             = (DebugDataType)reader.ReadUInt32();
            _sizeOfData       = reader.ReadUInt32();
            _addressOfRawData = reader.ReadUInt32();
            _pointerToRawData = reader.ReadUInt32();
        }
        /// <summary>
        /// Reads a single debug data entry from an input stream.
        /// </summary>
        /// <param name="context">The reading context.</param>
        /// <param name="directoryReader">The input stream.</param>
        public SerializedDebugDataEntry(
            PEReaderContext context,
            IBinaryStreamReader directoryReader)
        {
            if (directoryReader == null)
            {
                throw new ArgumentNullException(nameof(directoryReader));
            }
            _context = context ?? throw new ArgumentNullException(nameof(context));

            Offset = directoryReader.Offset;
            Rva    = directoryReader.Rva;

            Characteristics   = directoryReader.ReadUInt32();
            TimeDateStamp     = directoryReader.ReadUInt32();
            MajorVersion      = directoryReader.ReadUInt16();
            MinorVersion      = directoryReader.ReadUInt16();
            _type             = (DebugDataType)directoryReader.ReadUInt32();
            _sizeOfData       = directoryReader.ReadUInt32();
            _addressOfRawData = directoryReader.ReadUInt32();
            _pointerToRawData = directoryReader.ReadUInt32();
        }
Esempio n. 7
0
 public bool LoadDebugData( DebugDataType dataType, Stream stream )
 {
     _debugData = ProgramDebugData.Load( dataType, stream );
     return ( _debugData != null );
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a new instance of the <see cref="CustomDebugDataSegment"/> class.
 /// </summary>
 /// <param name="type">The format of the data.</param>
 /// <param name="contents">The contents of the code.</param>
 public CustomDebugDataSegment(DebugDataType type, ISegment contents)
 {
     Type     = type;
     Contents = contents ?? throw new ArgumentNullException(nameof(contents));
 }
Esempio n. 9
0
 /// <inheritdoc />
 public IDebugDataSegment ReadDebugData(PEReaderContext context, DebugDataType type,
                                        IBinaryStreamReader reader)
 {
     return(new CustomDebugDataSegment(type, DataSegment.FromReader(reader)));
 }
Esempio n. 10
0
 public bool LoadDebugData(DebugDataType dataType, Stream stream)
 {
     _debugData = ProgramDebugData.Load(dataType, stream);
     return(_debugData != null);
 }