void CreateChunks()
        {
            bool hasDebugDirectory = false;

            peHeaders = new PEHeaders(Options.PEHeadersOptions);

            if (!Options.Is64Bit)
            {
                importAddressTable = new ImportAddressTable();
                importDirectory    = new ImportDirectory();
                startupStub        = new StartupStub();
                relocDirectory     = new RelocDirectory();
            }

            CreateStrongNameSignature();

            imageCor20Header = new ImageCor20Header(Options.Cor20HeaderOptions);
            CreateMetaDataChunks(module);

            if (hasDebugDirectory)
            {
                debugDirectory = new DebugDirectory();
            }

            if (importDirectory != null)
            {
                importDirectory.IsExeFile = Options.IsExeFile;
            }

            peHeaders.IsExeFile = Options.IsExeFile;
        }
Example #2
0
 /// <summary>
 /// Creates the debug directory if a PDB file should be written
 /// </summary>
 protected void CreateDebugDirectory()
 {
     if (CanWritePdb())
     {
         debugDirectory = new DebugDirectory();
     }
 }
Example #3
0
 internal static void WriteDebugDirectory(this DataWriter writer, DebugDirectory chunk)
 {
     if (chunk == null || chunk.GetVirtualSize() == 0)
     {
         writer.WriteUInt64(0);
     }
     else
     {
         writer.WriteUInt32((uint)chunk.RVA);
         writer.WriteUInt32((uint)(chunk.Count * DebugDirectory.HEADER_SIZE));
     }
 }
Example #4
0
        void CreateChunks()
        {
            bool hasDebugDirectory = false;

            peHeaders = new PEHeaders(Options.PEHeadersOptions);

            if (!Options.Is64Bit)
            {
                importAddressTable = new ImportAddressTable();
                importDirectory    = new ImportDirectory();
                startupStub        = new StartupStub();
                relocDirectory     = new RelocDirectory();
            }

            if (Options.StrongNameKey != null)
            {
                strongNameSignature = new StrongNameSignature(Options.StrongNameKey.SignatureSize);
            }
            else if (module.Assembly != null && !PublicKeyBase.IsNullOrEmpty2(module.Assembly.PublicKey))
            {
                int len = module.Assembly.PublicKey.Data.Length - 0x20;
                strongNameSignature = new StrongNameSignature(len > 0 ? len : 0x80);
            }
            else if (((Options.Cor20HeaderOptions.Flags ?? module.Cor20HeaderFlags) & ComImageFlags.StrongNameSigned) != 0)
            {
                strongNameSignature = new StrongNameSignature(0x80);
            }

            imageCor20Header = new ImageCor20Header(Options.Cor20HeaderOptions);
            CreateMetaDataChunks(module);

            if (hasDebugDirectory)
            {
                debugDirectory = new DebugDirectory();
            }

            if (importDirectory != null)
            {
                importDirectory.IsExeFile = Options.IsExeFile;
            }

            peHeaders.IsExeFile = Options.IsExeFile;
        }
Example #5
0
		/// <summary>
		/// Creates the debug directory if a PDB file should be written
		/// </summary>
		protected void CreateDebugDirectory() {
			if (CanWritePdb())
				debugDirectory = new DebugDirectory();
		}
        void CreateChunks()
        {
            bool hasDebugDirectory = false;

            peHeaders = new PEHeaders(Options.PEHeadersOptions);

            if (!Options.Is64Bit) {
                importAddressTable = new ImportAddressTable();
                importDirectory = new ImportDirectory();
                startupStub = new StartupStub();
                relocDirectory = new RelocDirectory();
            }

            if (Options.StrongNameKey != null)
                strongNameSignature = new StrongNameSignature(Options.StrongNameKey.SignatureSize);
            else if (module.Assembly != null && !PublicKeyBase.IsNullOrEmpty2(module.Assembly.PublicKey)) {
                int len = module.Assembly.PublicKey.Data.Length - 0x20;
                strongNameSignature = new StrongNameSignature(len > 0 ? len : 0x80);
            }
            else if (((Options.Cor20HeaderOptions.Flags ?? module.Cor20HeaderFlags) & ComImageFlags.StrongNameSigned) != 0)
                strongNameSignature = new StrongNameSignature(0x80);

            imageCor20Header = new ImageCor20Header(Options.Cor20HeaderOptions);
            CreateMetaDataChunks(module);

            if (hasDebugDirectory)
                debugDirectory = new DebugDirectory();

            if (importDirectory != null)
                importDirectory.IsExeFile = Options.IsExeFile;

            peHeaders.IsExeFile = Options.IsExeFile;
        }
Example #7
0
        void CreateChunks()
        {
            bool hasDebugDirectory = false;

            peHeaders = new PEHeaders(Options.PEHeadersOptions);

            if (!Options.Is64Bit) {
                importAddressTable = new ImportAddressTable();
                importDirectory = new ImportDirectory();
                startupStub = new StartupStub();
                relocDirectory = new RelocDirectory();
            }

            CreateStrongNameSignature();

            imageCor20Header = new ImageCor20Header(Options.Cor20HeaderOptions);
            CreateMetaDataChunks(module);

            if (hasDebugDirectory)
                debugDirectory = new DebugDirectory();

            if (importDirectory != null)
                importDirectory.IsExeFile = Options.IsExeFile;

            peHeaders.IsExeFile = Options.IsExeFile;
        }