GetDebugInfo() public method

public GetDebugInfo ( ImageDebugDirectory &idd ) : byte[]
idd ImageDebugDirectory
return byte[]
Beispiel #1
0
        void Patch()
        {
            // patch debug info in PE file to match PDB
            //try
            //{
            byte[] DebugInfo = m_writer.GetDebugInfo();
            m_writer.Close();

            RVA  debugHeaderRVA = m_module.Image.PEOptionalHeader.DataDirectories.Debug.VirtualAddress;
            long debugHeaderPos = m_module.Image.ResolveVirtualAddress(debugHeaderRVA);
            uint sizeUntilData  = 0x1c;    // copied from ImageWriter
            long debugDataPos   = debugHeaderPos + sizeUntilData;

            using (FileStream fs = new FileStream(m_assembly, FileMode.Open, FileAccess.Write))
            {
                BinaryWriter writer = new BinaryWriter(fs);
                writer.BaseStream.Position = debugDataPos;
                writer.Write(DebugInfo);
            }
            //  }
            //  catch (Exception ex)
            //  {
            //      System.Diagnostics.Debug.WriteLine("in PdbWriter.Patch: " + ex.Message);
            //  }
        }
Beispiel #2
0
        public ImageDebugHeader GetDebugHeader()
        {
            ImageDebugDirectory directory;
            var data = writer.GetDebugInfo(out directory);

            directory.TimeDateStamp = (int)module.timestamp;
            return(new ImageDebugHeader(new ImageDebugHeaderEntry(directory, data)));
        }
Beispiel #3
0
        public void Write()
        {
            var entry_point = module.EntryPoint;

            if (entry_point != null)
            {
                writer.SetUserEntryPoint(entry_point.MetadataToken.ToInt32());
            }

            debug_info = writer.GetDebugInfo(out debug_directory);
            debug_directory.TimeDateStamp = (int)module.timestamp;

            writer.Close();
        }
Beispiel #4
0
        public bool GetDebugHeader(out ImageDebugDirectory directory, out byte [] header)
        {
            header = writer.GetDebugInfo(out directory);

            if (directory.Type != 2) //IMAGE_DEBUG_TYPE_CODEVIEW
            {
                return(false);
            }
            if (directory.MajorVersion != 0 || directory.MinorVersion != 0)
            {
                return(false);
            }

            if (header.Length < 24)
            {
                return(false);
            }

            var magic = ReadInt32(header, 0);

            if (magic != 0x53445352)
            {
                return(false);
            }

            var guid_bytes = new byte[16];

            Buffer.BlockCopy(header, 4, guid_bytes, 0, 16);

            this.guid = new Guid(guid_bytes);
            this.age  = ReadInt32(header, 20);

            this.signatureProvider?.Invoke(new Signature()
            {
                Guid = guid,
                Age  = age
            });

            return(true);
        }
Beispiel #5
0
 public bool GetDebugHeader(out ImageDebugDirectory directory, out byte [] header)
 {
     header = writer.GetDebugInfo(out directory);
     return(true);
 }