Esempio n. 1
0
        /// <summary>
        /// Creates a new CodeViewDataSegment depending on CodeView Signature
        /// </summary>
        /// <param name="context">Context for the reader</param>
        /// <param name="reader">The input stream to read from.</param>
        /// <returns></returns>
        public static CodeViewDataSegment FromReader(PEReaderContext context, ref BinaryStreamReader reader)
        {
            var signature = (CodeViewSignature)reader.ReadUInt32();

            return(signature switch
            {
                CodeViewSignature.Rsds => RsdsDataSegment.FromReader(context, ref reader),
                CodeViewSignature.Nb05 => context.NotSupportedAndReturn <CodeViewDataSegment>(),
                CodeViewSignature.Nb09 => context.NotSupportedAndReturn <CodeViewDataSegment>(),
                CodeViewSignature.Nb10 => context.NotSupportedAndReturn <CodeViewDataSegment>(),
                CodeViewSignature.Nb11 => context.NotSupportedAndReturn <CodeViewDataSegment>(),
                _ => context.BadImageAndReturn <CodeViewDataSegment>("Invalid code view debug data signature.")
            });
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of <see cref="RsdsDataSegment"/>
        /// </summary>
        /// <param name="context">Context for the reader</param>
        /// <param name="reader">The input stream to read from.</param>
        /// <returns></returns>
        public new static RsdsDataSegment FromReader(PEReaderContext context, IBinaryStreamReader reader)
        {
            if (reader.Length < RsdsExpectedDataSize)
            {
                context.BadImage("RSDS Data was shorter than the minimal expected length");
                return(null);
            }
            var result = new RsdsDataSegment();

            byte[] buffer = new byte[16];
            reader.ReadBytes(buffer, 0, 16);
            result.Guid = new Guid(buffer);
            result.Age  = reader.ReadUInt32();
            result.Path = Encoding.UTF8.GetString(reader.ReadBytesUntil(0x00));

            return(result);
        }