예제 #1
0
        private void CreateChunks()
        {
            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);

            CreateDebugDirectory();

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

            PEHeaders.IsExeFile = Options.IsExeFile;
        }
예제 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="relocDirectory">Reloc directory</param>
 /// <param name="machine">Machine</param>
 /// <param name="logError">Error logger</param>
 internal StartupStub(RelocDirectory relocDirectory, Machine machine, LogError logError)
 {
     this.relocDirectory = relocDirectory;
     this.machine        = machine;
     this.logError       = logError;
     CpuArch.TryGetCpuArch(machine, out cpuArch);
 }
예제 #3
0
        void CreateChunks()
        {
            peHeaders = new PEHeaders(Options.PEHeadersOptions);

            var  machine = Options.PEHeadersOptions.Machine ?? Machine.I386;
            bool is64bit = machine == Machine.AMD64 || machine == Machine.IA64 || machine == Machine.ARM64;

            relocDirectory = new RelocDirectory(machine);
            if (machine == Machine.I386)
            {
                needStartupStub = true;
            }

            importAddressTable = new ImportAddressTable(is64bit);
            importDirectory    = new ImportDirectory(is64bit);
            startupStub        = new StartupStub(relocDirectory, machine, (format, args) => Error(format, args));

            CreateStrongNameSignature();

            imageCor20Header = new ImageCor20Header(Options.Cor20HeaderOptions);
            CreateMetaDataChunks(module);
            managedExportsWriter = new ManagedExportsWriter(UTF8String.ToSystemStringOrEmpty(module.Name), machine, relocDirectory, metaData, peHeaders, (format, args) => Error(format, args));

            CreateDebugDirectory();

            importDirectory.IsExeFile = Options.IsExeFile;
            peHeaders.IsExeFile       = Options.IsExeFile;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="relocDirectory">Reloc directory</param>
 /// <param name="machine">Machine</param>
 /// <param name="logError">Error logger</param>
 internal StartupStub(RelocDirectory relocDirectory, Machine machine, Action <string, object[]> logError)
 {
     this.relocDirectory = relocDirectory;
     this.machine        = machine;
     this.logError       = logError;
     CpuArch.TryGetCpuArch(machine, out cpuArch);
 }
예제 #5
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;
        }
예제 #6
0
 public ManagedExportsWriter(string moduleName, Machine machine, RelocDirectory relocDirectory, MetaData metaData, PEHeaders peHeaders, LogError logError)
 {
     this.moduleName     = moduleName;
     this.machine        = machine;
     this.relocDirectory = relocDirectory;
     this.metaData       = metaData;
     this.peHeaders      = peHeaders;
     this.logError       = logError;
     vtableFixups        = new VtableFixupsChunk(this);
     stubsChunk          = new StubsChunk(this);
     sdataChunk          = new SdataChunk(this);
     exportDir           = new ExportDir(this);
     vtables             = new List <VTableInfo>();
     allMethodInfos      = new List <MethodInfo>();
     sortedNameInfos     = new List <MethodInfo>();
     // The error is reported later when we know that there's at least one exported method
     CpuArch.TryGetCpuArch(machine, out cpuArch);
 }
예제 #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();
            }

            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;
        }
예제 #8
0
		void CreateChunks() {
			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);

			CreateDebugDirectory();

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

			peHeaders.IsExeFile = Options.IsExeFile;
		}
예제 #9
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;
        }