public IEnumerable <EvidenceBase> GetFactorySuppliedEvidence() { if (this.m_assemblyProvidedEvidence == null) { byte[] o = (byte[])null; PEFileEvidenceFactory.GetAssemblySuppliedEvidence(this.m_peFile, JitHelpers.GetObjectHandleOnStack <byte[]>(ref o)); this.m_assemblyProvidedEvidence = new List <EvidenceBase>(); if (o != null) { Evidence evidence = new Evidence(); new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Assert(); try { using (MemoryStream memoryStream = new MemoryStream(o)) evidence = (Evidence) new BinaryFormatter().Deserialize((Stream)memoryStream); } catch { } CodeAccessPermission.RevertAssert(); if (evidence != null) { IEnumerator assemblyEnumerator = evidence.GetAssemblyEnumerator(); while (assemblyEnumerator.MoveNext()) { if (assemblyEnumerator.Current != null) { this.m_assemblyProvidedEvidence.Add(assemblyEnumerator.Current as EvidenceBase ?? (EvidenceBase) new LegacyEvidenceWrapper(assemblyEnumerator.Current)); } } } } } return((IEnumerable <EvidenceBase>) this.m_assemblyProvidedEvidence); }
/// <summary> /// Create a factory which can generate evidence for the specified assembly /// </summary> private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory) { Contract.Assert(targetAssembly != null); Contract.Assert(peFileFactory != null); m_targetAssembly = targetAssembly; m_peFileFactory = peFileFactory; }
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence) { PEFileEvidenceFactory target = new PEFileEvidenceFactory(peFile); Evidence evidence = new Evidence(target); if (hostProvidedEvidence != null) { evidence.MergeWithNoDuplicates(hostProvidedEvidence); } return evidence; }
private Publisher GeneratePublisherEvidence() { byte[] array = null; PEFileEvidenceFactory.GetPublisherCertificate(this.m_peFile, JitHelpers.GetObjectHandleOnStack <byte[]>(ref array)); if (array == null) { return(null); } return(new Publisher(new X509Certificate(array))); }
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence) { PEFileEvidenceFactory target = new PEFileEvidenceFactory(peFile); Evidence evidence = new Evidence(target); if (hostProvidedEvidence != null) { evidence.MergeWithNoDuplicates(hostProvidedEvidence); } return(evidence); }
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence) { PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile); Evidence evidence = new Evidence(evidenceFactory); // If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just // created. The host evidence takes priority. if (hostProvidedEvidence != null) { evidence.MergeWithNoDuplicates(hostProvidedEvidence); } return(evidence); }
private void GenerateLocationEvidence() { if (!this.m_generatedLocationEvidence) { SecurityZone securityZone = SecurityZone.NoZone; string text = null; PEFileEvidenceFactory.GetLocationEvidence(this.m_peFile, out securityZone, JitHelpers.GetStringHandleOnStack(ref text)); if (securityZone != SecurityZone.NoZone) { this.m_zoneEvidence = new Zone(securityZone); } if (!string.IsNullOrEmpty(text)) { this.m_urlEvidence = new Url(text, true); if (!text.StartsWith("file:", StringComparison.OrdinalIgnoreCase)) { this.m_siteEvidence = Site.CreateFromUrl(text); } } this.m_generatedLocationEvidence = true; } }
private void GenerateLocationEvidence() { if (this.m_generatedLocationEvidence) { return; } SecurityZone zone = SecurityZone.NoZone; string s = (string)null; PEFileEvidenceFactory.GetLocationEvidence(this.m_peFile, out zone, JitHelpers.GetStringHandleOnStack(ref s)); if (zone != SecurityZone.NoZone) { this.m_zoneEvidence = new Zone(zone); } if (!string.IsNullOrEmpty(s)) { this.m_urlEvidence = new Url(s, true); if (!s.StartsWith("file:", StringComparison.OrdinalIgnoreCase)) { this.m_siteEvidence = Site.CreateFromUrl(s); } } this.m_generatedLocationEvidence = true; }
private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory) { this.m_targetAssembly = targetAssembly; this.m_peFileFactory = peFileFactory; }
internal void FireEvidenceGeneratedEvent(EvidenceTypeGenerated type) { PEFileEvidenceFactory.FireEvidenceGeneratedEvent(this.m_peFile, type); }
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence) { PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile); Evidence evidence = new Evidence(evidenceFactory); // If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just // created. The host evidence takes priority. if (hostProvidedEvidence != null) { evidence.MergeWithNoDuplicates(hostProvidedEvidence); } return evidence; }