Ejemplo n.º 1
0
Archivo: GACUtil.cs Proyecto: zha0/wspe
        /// <summary>
        /// Parse all the Assemblies from the Global Assembly Cache (GAC).
        /// </summary>
        /// <returns>Whether the function successfully executed.</returns>
        public uint ParseAllAssemblies()
        {
            ASSEMBLY_IDENTITY dummy = new ASSEMBLY_IDENTITY();

            this.pIAssemblyEnum.Reset();
            return(this.ParseAllAssembliesInternal(null, 0, ref dummy));
        }
Ejemplo n.º 2
0
Archivo: GACUtil.cs Proyecto: zha0/wspe
        /// <summary>
        /// Parse all the Assemblies from the Global Assembly Cache (GAC).
        /// </summary>
        /// <param name="wszFilter">Assembly to find.</param>
        /// <param name="wMajor">Major version of the Assembly to find</param>
        /// <param name="pAssemblyIdentity">Pointer to an ASSEMBLY_IDENTITY structure.</param>
        /// <returns>Whether the function successfully executed</returns>
        private uint ParseAllAssembliesInternal(string wszFilter, short wMajor, ref ASSEMBLY_IDENTITY pAssemblyIdentity)
        {
            // Parse all assemblies
            while (this.pIAssemblyEnum.GetNextAssembly(IntPtr.Zero, out IAssemblyName pIassemblyName, 0) == 0)
            {
                string wszAssemblyName = "";
                this.GetAssemblyName(ref pIassemblyName, ref wszAssemblyName);

                string wszAssemblyGacPath = "";
                this.GetAssemblyGACPath(ref wszAssemblyName, ref wszAssemblyGacPath);

                ASSEMBLY_VERSION AssemblyVersion = new ASSEMBLY_VERSION();
                this.GetAssemblyVersion(ref pIassemblyName, ref AssemblyVersion);

                // Search for an Assembly
                if ((!string.IsNullOrEmpty(wszFilter) && wszFilter.Equals(wszAssemblyName)) && (wMajor != 0) && wMajor == AssemblyVersion.wMajor)
                {
                    if (pAssemblyIdentity.Equals(null))
                    {
                        return(Macros.E_FAIL);
                    }

                    pAssemblyIdentity.szName    = wszFilter;
                    pAssemblyIdentity.szGacPath = wszAssemblyGacPath;
                    pAssemblyIdentity.szVersion = AssemblyVersion.wMajor + "." + AssemblyVersion.wMinor + "." + AssemblyVersion.wBuild + "." + AssemblyVersion.wRevision;
                    return(Macros.S_OK);
                }
            }

            if (!string.IsNullOrEmpty(wszFilter))
            {
                return(Macros.E_FAIL);
            }
            return(Macros.S_OK);
        }
Ejemplo n.º 3
0
Archivo: GACUtil.cs Proyecto: zha0/wspe
        /// <summary>
        /// Find an Assembly from the Global Assembly Cache (GAC).
        /// </summary>
        /// <param name="wszAssemblyName">Name of the Assembly to find.</param>
        /// <param name="wMajor">Major version of the Assembly to find.</param>
        /// <param name="pAssemblyIdentity">Pointer to an ASSEMBLY_IDENTITY structure.</param>
        /// <returns></returns>
        public uint FindAssembly(string wszAssemblyName, short wMajor, ref ASSEMBLY_IDENTITY pAssemblyIdentity)
        {
            if (wszAssemblyName == null || pAssemblyIdentity.Equals(null))
            {
                return(Macros.E_FAIL);
            }

            this.pIAssemblyEnum.Reset();
            return(this.ParseAllAssembliesInternal(wszAssemblyName, wMajor, ref pAssemblyIdentity));
        }