/// <summary> /// Creates the strong name signature if the module has one of the strong name flags /// set or wants to sign the assembly. /// </summary> protected void CreateStrongNameSignature() { if (TheOptions.StrongNameKey != null) { strongNameSignature = new StrongNameSignature(TheOptions.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 (((TheOptions.Cor20HeaderOptions.Flags ?? Module.Cor20HeaderFlags) & ComImageFlags.StrongNameSigned) != 0) { strongNameSignature = new StrongNameSignature(0x80); } }
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; }
void CreateChunks() { CreateMetaDataChunks(module); if (Options.StrongNameKey != null) { int snSigSize = Options.StrongNameKey.SignatureSize; var cor20Hdr = module.MetaData.ImageCor20Header; if ((uint)snSigSize <= cor20Hdr.StrongNameSignature.Size) { // The original file had a strong name signature, and the new strong name // signature fits in that location. strongNameSigOffset = (long)module.MetaData.PEImage.ToFileOffset(cor20Hdr.StrongNameSignature.VirtualAddress); } else { // The original image wasn't signed, or its strong name signature is smaller // than the new strong name signature. Create a new one. strongNameSignature = new StrongNameSignature(snSigSize); } } }
/// <summary> /// Creates the strong name signature if the module has one of the strong name flags /// set or wants to sign the assembly. /// </summary> protected void CreateStrongNameSignature() { if (TheOptions.StrongNameKey != null) strongNameSignature = new StrongNameSignature(TheOptions.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 (((TheOptions.Cor20HeaderOptions.Flags ?? Module.Cor20HeaderFlags) & ComImageFlags.StrongNameSigned) != 0) strongNameSignature = new StrongNameSignature(0x80); }
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; }