Esempio n. 1
0
 public DefinitionIdentity(System.Deployment.Application.ReferenceIdentity refId)
 {
     this._idComPtr = System.Deployment.Internal.Isolation.IsolationInterop.IdentityAuthority.CreateDefinition();
     foreach (System.Deployment.Internal.Isolation.IDENTITY_ATTRIBUTE identity_attribute in refId.Attributes)
     {
         this[identity_attribute.Namespace, identity_attribute.Name] = identity_attribute.Value;
     }
 }
        public static void GenerateGACDetectionManifest(System.Deployment.Application.ReferenceIdentity refId, string outputManifest)
        {
            XmlDocument document = CloneAssemblyTemplate();

            if (GACDetectionTempManifestAsmId == null)
            {
                Interlocked.CompareExchange(ref GACDetectionTempManifestAsmId, new System.Deployment.Application.DefinitionIdentity("GACDetectionTempManifest, version=1.0.0.0, type=win32"), null);
            }
            InjectIdentityXml(document, (System.Deployment.Application.DefinitionIdentity)GACDetectionTempManifestAsmId);
            AddDependencies(document, new DependentAssembly[] { new DependentAssembly(refId) });
            using (FileStream stream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
            {
                document.Save(stream);
            }
        }
Esempio n. 3
0
        internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
        {
            Guid guidOfType = IsolationInterop.GetGuidOfType(typeof(IReferenceIdentity));

            System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity((IReferenceIdentity)System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType));
            string processorArchitecture = refId.ProcessorArchitecture;

            if (processorArchitecture != null)
            {
                refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
            }
            System.Deployment.Application.DefinitionIdentity definitionIdentity = new System.Deployment.Application.DefinitionIdentity(refId);
            Logger.AddInternalState("Managed Assembly Identity = " + definitionIdentity.ToString());
            return(definitionIdentity);
        }
Esempio n. 4
0
        public DependentAssembly(AssemblyReferenceEntry assemblyReferenceEntry)
        {
            AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;

            this._size     = dependentAssembly.Size;
            this._codebase = dependentAssembly.Codebase;
            this._group    = dependentAssembly.Group;
            bool     flag         = false;
            ISection hashElements = dependentAssembly.HashElements;
            uint     celt         = hashElements != null ? hashElements.Count : 0U;

            if (celt > 0U)
            {
                uint celtFetched = 0;
                IHashElementEntry[] hashElementEntryArray = new IHashElementEntry[(int)celt];
                Marshal.ThrowExceptionForHR(((System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum).Next(celt, (object[])hashElementEntryArray, ref celtFetched));
                if ((int)celtFetched != (int)celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint index = 0; index < celt; ++index)
                {
                    HashElementEntry allData = hashElementEntryArray[(int)index].AllData;
                    if (allData.DigestValueSize > 0U)
                    {
                        byte[] numArray = new byte[(int)allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, numArray, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(numArray, (CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && dependentAssembly.HashValueSize > 0U)
            {
                byte[] numArray = new byte[(int)dependentAssembly.HashValueSize];
                Marshal.Copy(dependentAssembly.HashValue, numArray, 0, (int)dependentAssembly.HashValueSize);
                this._hashCollection.AddHash(numArray, (CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._preRequisite = (dependentAssembly.Flags & 4U) > 0U;
            this._optional     = (assemblyReferenceEntry.Flags & 1U) > 0U;
            this._visible      = (dependentAssembly.Flags & 2U) > 0U;
            this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8U) > 0U;
            this._resourceFallbackCulture         = dependentAssembly.ResourceFallbackCulture;
            this._description = dependentAssembly.Description;
            this._supportUrl  = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
            this._identity    = new System.Deployment.Application.ReferenceIdentity(assemblyReferenceEntry.ReferenceIdentity);
            this._codebaseFS  = System.Deployment.Application.UriHelper.NormalizePathDirectorySeparators(this._codebase);
        }
        private static void AddDependencies(XmlDocument document, DependentAssembly[] dependentAssemblies)
        {
            Hashtable           hashtable    = new Hashtable();
            XmlNamespaceManager namespaceMgr = GetNamespaceMgr(document);
            XmlElement          element      = (XmlElement)document.SelectSingleNode("/asmv1:assembly", namespaceMgr);

            foreach (DependentAssembly assembly in dependentAssemblies)
            {
                if (!hashtable.Contains(assembly.Identity))
                {
                    XmlElement newChild = document.CreateElement("dependency", "urn:schemas-microsoft-com:asm.v1");
                    element.AppendChild(newChild);
                    XmlElement element3 = document.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
                    newChild.AppendChild(element3);
                    System.Deployment.Application.ReferenceIdentity  refId = assembly.Identity;
                    System.Deployment.Application.DefinitionIdentity asmId = new System.Deployment.Application.DefinitionIdentity(refId);
                    XmlElement element4 = CreateAssemblyIdentityElement(document, asmId);
                    element3.AppendChild(element4);
                    hashtable.Add(refId, asmId);
                }
            }
        }
        public static System.Deployment.Application.DefinitionIdentity GenerateManifest(System.Deployment.Application.ReferenceIdentity suggestedReferenceIdentity, AssemblyManifest manifest, string outputManifest)
        {
            System.Deployment.Application.DefinitionIdentity asmId = manifest.Identity;
            if (manifest.RawXmlBytes != null)
            {
                using (FileStream stream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
                {
                    stream.Write(manifest.RawXmlBytes, 0, manifest.RawXmlBytes.Length);
                    return(asmId);
                }
            }
            XmlDocument document = CloneAssemblyTemplate();

            asmId = new System.Deployment.Application.DefinitionIdentity(suggestedReferenceIdentity);
            InjectIdentityXml(document, asmId);
            AddFiles(document, manifest.Files);
            AddDependencies(document, manifest.DependentAssemblies);
            using (FileStream stream2 = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
            {
                document.Save(stream2);
            }
            return(asmId);
        }
Esempio n. 7
0
 public bool Matches(System.Deployment.Application.ReferenceIdentity refId, bool exact)
 {
     return(System.Deployment.Internal.Isolation.IsolationInterop.IdentityAuthority.DoesDefinitionMatchReference(exact ? 1 : 0, this._idComPtr, refId.ComPointer) && (this.Version == refId.Version));
 }
Esempio n. 8
0
 public DependentAssembly(System.Deployment.Application.ReferenceIdentity refId)
 {
     this._identity = refId;
 }