/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reader">PE file reader pointing to the start of this section</param>
 /// <param name="verify">Verify section</param>
 /// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
 public ImageDebugDirectory(ref DataReader reader, bool verify)
 {
     SetStartOffset(ref reader);
     characteristics  = reader.ReadUInt32();
     timeDateStamp    = reader.ReadUInt32();
     majorVersion     = reader.ReadUInt16();
     minorVersion     = reader.ReadUInt16();
     type             = (ImageDebugType)reader.ReadUInt32();
     sizeOfData       = reader.ReadUInt32();
     addressOfRawData = reader.ReadUInt32();
     pointerToRawData = reader.ReadUInt32();
     SetEndoffset(ref reader);
 }
コード例 #2
0
        static ImageDebugDirectory TryGetDebugDirectoryEntry(IPEImage peImage, ImageDebugType imageDebugType)
        {
            var list  = peImage.ImageDebugDirectories;
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                var entry = list[i];
                if (entry.Type == imageDebugType)
                {
                    return(entry);
                }
            }
            return(null);
        }
コード例 #3
0
        private static ImageDebugHeaderEntry GetEntry(this ImageDebugHeader header, ImageDebugType type)
        {
            if (!header.HasEntries)
            {
                return(null);
            }

            for (var i = 0; i < header.Entries.Length; i++)
            {
                var entry = header.Entries [i];
                if (entry.Directory.Type == type)
                {
                    return(entry);
                }
            }

            return(null);
        }
コード例 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Processes the debug info.
        /// </summary>
        /// <remarks>Info about debug info from
        /// http://www.debuginfo.com/articles/debuginfomatch.html</remarks>
        /// ------------------------------------------------------------------------------------
        private void ProcessDebugInfo()
        {
            m_stream.Position += 4;
            OverwriteTimestamp();
            m_stream.Position += 4;
            ImageDebugType type = (ImageDebugType)m_reader.ReadInt32();

            if (type != ImageDebugType.Codeview)
            {
                throw new ApplicationException(
                          "Can handle only CodeView debug information at the moment");
            }

            // Size
            // Address of Raw Data
            m_stream.Position += 8;
            int nPointerToDebugInfo = m_reader.ReadInt32();

            m_stream.Position = nPointerToDebugInfo;

            string cvSignature = new string(m_reader.ReadChars(4));

            if (cvSignature == "RSDS")             // PDB 7.0
            {
                // wipe out GUID
                byte[] buffer = new byte[Marshal.SizeOf(typeof(Guid))];
                m_writer.Write(buffer);

                // wipe out Age
                m_writer.Write((int)0);

                // PDB Filename
            }
            else
            {
                throw new ApplicationException(
                          "Unsupported CodeView format (can handle only PDB 7.0)");
            }
        }
コード例 #5
0
 public ImageDebugDirectory TryGetDebugDirectoryEntry(ImageDebugType imageDebugType) =>
 TryGetDebugDirectoryEntry(peImage, imageDebugType);