Esempio n. 1
0
        /// <summary>
        /// Calls self-reg harvester.
        /// </summary>
        /// <param name="parentElement">The parent element.</param>
        /// <param name="fileSource">The file source.</param>
        private void HarvestSelfReg(Wix.IParentElement parentElement, string fileSource)
        {
            // try the self-reg harvester
            try
            {
                DllHarvester dllHarvester = new DllHarvester();

                this.Core.OnMessage(UtilVerboses.HarvestingSelfReg(fileSource));
                Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(fileSource);

                foreach (Wix.RegistryValue registryValue in registryValues)
                {
                    parentElement.AddChild(registryValue);
                }
            }
            catch (TargetInvocationException tie)
            {
                if (tie.InnerException is EntryPointNotFoundException)
                {
                    // No DllRegisterServer(), which is fine by me.
                }
                else
                {
                    this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, tie.Message));
                }
            }
            catch (Exception ex)
            {
                this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, ex.Message));
            }
        }
Esempio n. 2
0
        private void ProcessInfFile(List <InfFileInstructions> InfFiles, Wix.Wix wix)
        {
            foreach (InfFileInstructions ifi in InfFiles)
            {
                Wix.Component FileComponent = this.GetComponentWithFileFromWix(null, wix, ifi.FileName, false);

                if (null == FileComponent)
                {
                    Console.WriteLine("Exception: this file wasn't found in the current component...");
                }

                if (mainComponentGuid == null)
                {
                    mainComponentGuid  = Guid.NewGuid().ToString("B").ToUpper();
                    FileComponent.Guid = mainComponentGuid;
                }
                else
                {
                    FileComponent.Guid = Guid.NewGuid().ToString("B").ToUpper();
                }


                String FilePath = GetFilePathFromComponent(FileComponent, ifi.FileName, false);

                if (ifi.RegisterServer == "yes")
                {
                    DllHarvester dh = new DllHarvester();

                    Wix.RegistryValue[] axregvals = dh.HarvestRegistryValues(FilePath);

                    foreach (Wix.RegistryValue r in axregvals)
                    {
                        FileComponent.AddChild(r);
                    }
                }
            }
        }
        /// <summary>
        /// Mutate a file.
        /// </summary>
        /// <param name="parentElement">The parent of the element to mutate.</param>
        /// <param name="file">The file to mutate.</param>
        private void MutateFile(Wix.IParentElement parentElement, Wix.File file)
        {
            if (null != file.Source)
            {
                string fileExtension = Path.GetExtension(file.Source);
                string fileSource = this.Core.ResolveFilePath(file.Source);

                if (String.Equals(".ax", fileExtension, StringComparison.OrdinalIgnoreCase) || // DirectShow filter
                    String.Equals(".dll", fileExtension, StringComparison.OrdinalIgnoreCase) ||
                    String.Equals(".exe", fileExtension, StringComparison.OrdinalIgnoreCase) ||
                    String.Equals(".ocx", fileExtension, StringComparison.OrdinalIgnoreCase)) // ActiveX
                {
                    // try the assembly harvester
                    try
                    {
                        AssemblyHarvester assemblyHarvester = new AssemblyHarvester();

                        this.Core.OnMessage(UtilVerboses.HarvestingAssembly(fileSource));
                        Wix.RegistryValue[] registryValues = assemblyHarvester.HarvestRegistryValues(fileSource);

                        foreach (Wix.RegistryValue registryValue in registryValues)
                        {
                            parentElement.AddChild(registryValue);
                        }
                    }
                    catch (BadImageFormatException) // not an assembly, try raw DLL.
                    {
                        // try the self-reg harvester
                        try
                        {
                            DllHarvester dllHarvester = new DllHarvester();

                            this.Core.OnMessage(UtilVerboses.HarvestingSelfReg(fileSource));
                            Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(fileSource);

                            foreach (Wix.RegistryValue registryValue in registryValues)
                            {
                                parentElement.AddChild(registryValue);
                            }
                        }
                        catch (TargetInvocationException tie)
                        {
                            if (tie.InnerException is EntryPointNotFoundException)
                            {
                                // No DllRegisterServer(), which is fine by me.
                            }
                            else
                            {
                                this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, tie.Message));
                            }
                        }
                        catch (Exception ex)
                        {
                            this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, ex.Message));
                        }
                    }
                    catch (Exception ex)
                    {
                        this.Core.OnMessage(UtilWarnings.AssemblyHarvestFailed(fileSource, ex.Message));
                    }
                }
                else if (String.Equals(".olb", fileExtension, StringComparison.OrdinalIgnoreCase) || // type library
                          String.Equals(".tlb", fileExtension, StringComparison.OrdinalIgnoreCase)) // type library
                {
                    // try the type library harvester
                    try
                    {
                        TypeLibraryHarvester typeLibHarvester = new TypeLibraryHarvester();

                        this.Core.OnMessage(UtilVerboses.HarvestingTypeLib(fileSource));
                        Wix.RegistryValue[] registryValues = typeLibHarvester.HarvestRegistryValues(fileSource);

                        foreach (Wix.RegistryValue registryValue in registryValues)
                        {
                            parentElement.AddChild(registryValue);
                        }
                    }
                    catch (COMException ce)
                    {
                        //  0x8002801C (TYPE_E_REGISTRYACCESS)
                        // If we don't have permission to harvest typelibs, it's likely because we're on
                        // Vista or higher and aren't an Admin, or don't have the appropriate QFE installed.
                        if (!this.calledPerUserTLibReg && (0x8002801c == unchecked((uint)ce.ErrorCode)))
                        {
                            this.Core.OnMessage(WixWarnings.InsufficientPermissionHarvestTypeLib());
                        }
                        else if (0x80029C4A == unchecked((uint)ce.ErrorCode)) // generic can't load type library
                        {
                            this.Core.OnMessage(UtilWarnings.TypeLibLoadFailed(fileSource, ce.Message));
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Calls self-reg harvester.
        /// </summary>
        /// <param name="parentElement">The parent element.</param>
        /// <param name="fileSource">The file source.</param>
        private void HarvestSelfReg(Wix.IParentElement parentElement, string fileSource)
        {
           // try the self-reg harvester
           try
           {
              DllHarvester dllHarvester = new DllHarvester();

              this.Core.OnMessage(UtilVerboses.HarvestingSelfReg(fileSource));
              Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(fileSource);

              foreach (Wix.RegistryValue registryValue in registryValues)
              {
                 parentElement.AddChild(registryValue);
              }
           }
           catch (TargetInvocationException tie)
           {
              if (tie.InnerException is EntryPointNotFoundException)
              {
                 // No DllRegisterServer(), which is fine by me.
              }
              else
              {
                 this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, tie.Message));
              }
           }
           catch (Exception ex)
           {
              this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, ex.Message));
           }
        }
Esempio n. 5
0
        /// <summary>
        /// Mutate a file.
        /// </summary>
        /// <param name="parentElement">The parent of the element to mutate.</param>
        /// <param name="file">The file to mutate.</param>
        private void MutateFile(Wix.IParentElement parentElement, Wix.File file)
        {
            if (null != file.Source)
            {
                string fileExtension = Path.GetExtension(file.Source);
                string fileSource    = this.Core.ResolveFilePath(file.Source);

                if (String.Equals(".ax", fileExtension, StringComparison.OrdinalIgnoreCase) || // DirectShow filter
                    String.Equals(".dll", fileExtension, StringComparison.OrdinalIgnoreCase) ||
                    String.Equals(".exe", fileExtension, StringComparison.OrdinalIgnoreCase) ||
                    String.Equals(".ocx", fileExtension, StringComparison.OrdinalIgnoreCase)) // ActiveX
                {
                    // try the assembly harvester
                    try
                    {
                        AssemblyHarvester assemblyHarvester = new AssemblyHarvester();

                        this.Core.OnMessage(UtilVerboses.HarvestingAssembly(fileSource));
                        Wix.RegistryValue[] registryValues = assemblyHarvester.HarvestRegistryValues(fileSource);

                        foreach (Wix.RegistryValue registryValue in registryValues)
                        {
                            parentElement.AddChild(registryValue);
                        }
                    }
                    catch (BadImageFormatException) // not an assembly, try raw DLL.
                    {
                        // try the self-reg harvester
                        try
                        {
                            DllHarvester dllHarvester = new DllHarvester();

                            this.Core.OnMessage(UtilVerboses.HarvestingSelfReg(fileSource));
                            Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(fileSource);

                            foreach (Wix.RegistryValue registryValue in registryValues)
                            {
                                parentElement.AddChild(registryValue);
                            }
                        }
                        catch (TargetInvocationException tie)
                        {
                            if (tie.InnerException is EntryPointNotFoundException)
                            {
                                // No DllRegisterServer(), which is fine by me.
                            }
                            else
                            {
                                this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, tie.Message));
                            }
                        }
                        catch (Exception ex)
                        {
                            this.Core.OnMessage(UtilWarnings.SelfRegHarvestFailed(fileSource, ex.Message));
                        }
                    }
                    catch (Exception ex)
                    {
                        this.Core.OnMessage(UtilWarnings.AssemblyHarvestFailed(fileSource, ex.Message));
                    }
                }
                else if (String.Equals(".olb", fileExtension, StringComparison.OrdinalIgnoreCase) || // type library
                         String.Equals(".tlb", fileExtension, StringComparison.OrdinalIgnoreCase))   // type library
                {
                    // try the type library harvester
                    try
                    {
                        TypeLibraryHarvester typeLibHarvester = new TypeLibraryHarvester();

                        this.Core.OnMessage(UtilVerboses.HarvestingTypeLib(fileSource));
                        Wix.RegistryValue[] registryValues = typeLibHarvester.HarvestRegistryValues(fileSource);

                        foreach (Wix.RegistryValue registryValue in registryValues)
                        {
                            parentElement.AddChild(registryValue);
                        }
                    }
                    catch (COMException ce)
                    {
                        //  0x8002801C (TYPE_E_REGISTRYACCESS)
                        // If we don't have permission to harvest typelibs, it's likely because we're on
                        // Vista or higher and aren't an Admin, or don't have the appropriate QFE installed.
                        if (!this.calledPerUserTLibReg && (0x8002801c == unchecked ((uint)ce.ErrorCode)))
                        {
                            this.Core.OnMessage(WixWarnings.InsufficientPermissionHarvestTypeLib());
                        }
                        else if (0x80029C4A == unchecked ((uint)ce.ErrorCode)) // generic can't load type library
                        {
                            this.Core.OnMessage(UtilWarnings.TypeLibLoadFailed(fileSource, ce.Message));
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Mutate a file.
        /// </summary>
        /// <param name="parentElement">The parent of the element to mutate.</param>
        /// <param name="file">The file to mutate.</param>
        private void MutateFile(Wix.IParentElement parentElement, Wix.File file)
        {
            if (null != file.Source)
            {
                string fileExtension = Path.GetExtension(file.Source);

                if (0 == String.Compare(".ax", fileExtension, true) || // DirectShow filter
                    0 == String.Compare(".dll", fileExtension, true) ||
                    0 == String.Compare(".exe", fileExtension, true) ||
                    0 == String.Compare(".ocx", fileExtension, true) || // ActiveX
                    0 == String.Compare(".olb", fileExtension, true) || // type library
                    0 == String.Compare(".tlb", fileExtension, true))   // type library
                {
                    // try the assembly harvester
                    try
                    {
                        AssemblyHarvester assemblyHarvester = new AssemblyHarvester();

                        Wix.RegistryValue[] registryValues = assemblyHarvester.HarvestRegistryValues(file.Source);

                        foreach (Wix.RegistryValue registryValue in registryValues)
                        {
                            parentElement.AddChild(registryValue);
                        }
                    }
                    catch
                    {
                        // try the self-reg harvester
                        try
                        {
                            DllHarvester dllHarvester = new DllHarvester();

                            Wix.RegistryValue[] registryValues = dllHarvester.HarvestRegistryValues(file.Source);

                            foreach (Wix.RegistryValue registryValue in registryValues)
                            {
                                parentElement.AddChild(registryValue);
                            }
                        }
                        catch
                        {
                            // try the type library harvester
                            try
                            {
                                TypeLibraryHarvester typeLibHarvester = new TypeLibraryHarvester();

                                Wix.RegistryValue[] registryValues = typeLibHarvester.HarvestRegistryValues(file.Source);

                                foreach (Wix.RegistryValue registryValue in registryValues)
                                {
                                    parentElement.AddChild(registryValue);
                                }
                            }
                            catch
                            {
                                // ignore all exceptions
                            }
                        }
                    }
                }
            }
        }