Example #1
0
        /// <summary>
        /// Decompile the ServiceInstall table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileServiceInstallTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Wix.ServiceInstall serviceInstall = new Wix.ServiceInstall();

                serviceInstall.Id = Convert.ToString(row[0]);

                serviceInstall.Name = Convert.ToString(row[1]);

                if (null != row[2])
                {
                    serviceInstall.DisplayName = Convert.ToString(row[2]);
                }

                int serviceType = Convert.ToInt32(row[3]);
                if (MsiInterop.MsidbServiceInstallInteractive == (serviceType & MsiInterop.MsidbServiceInstallInteractive))
                {
                    serviceInstall.Interactive = Wix.YesNoType.yes;
                }

                if (MsiInterop.MsidbServiceInstallOwnProcess == (serviceType & MsiInterop.MsidbServiceInstallOwnProcess) &&
                    MsiInterop.MsidbServiceInstallShareProcess == (serviceType & MsiInterop.MsidbServiceInstallShareProcess))
                {
                    // TODO: warn
                }
                else if (MsiInterop.MsidbServiceInstallOwnProcess == (serviceType & MsiInterop.MsidbServiceInstallOwnProcess))
                {
                    serviceInstall.Type = Wix.ServiceInstall.TypeType.ownProcess;
                }
                else if (MsiInterop.MsidbServiceInstallShareProcess == (serviceType & MsiInterop.MsidbServiceInstallShareProcess))
                {
                    serviceInstall.Type = Wix.ServiceInstall.TypeType.shareProcess;
                }

                int startType = Convert.ToInt32(row[4]);
                if (MsiInterop.MsidbServiceInstallDisabled == startType)
                {
                    serviceInstall.Start = Wix.ServiceInstall.StartType.disabled;
                }
                else if (MsiInterop.MsidbServiceInstallDemandStart == startType)
                {
                    serviceInstall.Start = Wix.ServiceInstall.StartType.demand;
                }
                else if (MsiInterop.MsidbServiceInstallAutoStart == startType)
                {
                    serviceInstall.Start = Wix.ServiceInstall.StartType.auto;
                }
                else
                {
                    this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[4].Column.Name, row[4]));
                }

                int errorControl = Convert.ToInt32(row[5]);
                if (MsiInterop.MsidbServiceInstallErrorCritical == (errorControl & MsiInterop.MsidbServiceInstallErrorCritical))
                {
                    serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.critical;
                }
                else if (MsiInterop.MsidbServiceInstallErrorNormal == (errorControl & MsiInterop.MsidbServiceInstallErrorNormal))
                {
                    serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.normal;
                }
                else
                {
                    serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.ignore;
                }

                if (MsiInterop.MsidbServiceInstallErrorControlVital == (errorControl & MsiInterop.MsidbServiceInstallErrorControlVital))
                {
                    serviceInstall.Vital = Wix.YesNoType.yes;
                }

                if (null != row[6])
                {
                    serviceInstall.LoadOrderGroup = Convert.ToString(row[6]);
                }

                if (null != row[7])
                {
                    string[] dependencies = NullSplitter.Split(Convert.ToString(row[7]));

                    foreach (string dependency in dependencies)
                    {
                        if (0 < dependency.Length)
                        {
                            Wix.ServiceDependency serviceDependency = new Wix.ServiceDependency();

                            if (dependency.StartsWith("+", StringComparison.Ordinal))
                            {
                                serviceDependency.Group = Wix.YesNoType.yes;
                                serviceDependency.Id = dependency.Substring(1);
                            }
                            else
                            {
                                serviceDependency.Id = dependency;
                            }

                            serviceInstall.AddChild(serviceDependency);
                        }
                    }
                }

                if (null != row[8])
                {
                    serviceInstall.Account = Convert.ToString(row[8]);
                }

                if (null != row[9])
                {
                    serviceInstall.Password = Convert.ToString(row[9]);
                }

                if (null != row[10])
                {
                    serviceInstall.Arguments = Convert.ToString(row[10]);
                }

                if (null != row[12])
                {
                    serviceInstall.Description = Convert.ToString(row[12]);
                }

                Wix.Component component = (Wix.Component)this.core.GetIndexedElement("Component", Convert.ToString(row[11]));
                if (null != component)
                {
                    component.AddChild(serviceInstall);
                }
                else
                {
                    this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", Convert.ToString(row[11]), "Component"));
                }
                this.core.IndexElement(row, serviceInstall);
            }
        }
Example #2
0
        /// <summary>
        /// Finalize the ServiceConfig table.
        /// </summary>
        /// <param name="tables">The collection of all tables.</param>
        /// <remarks>
        /// Since there is no foreign key from the ServiceName column to the
        /// ServiceInstall table, this relationship must be handled late.
        /// </remarks>
        private void FinalizeServiceConfigTable(TableCollection tables)
        {
            Table serviceConfigTable  = tables["ServiceConfig"];
            Table serviceInstallTable = tables["ServiceInstall"];

            Hashtable serviceInstalls = new Hashtable();

            // index the ServiceInstall table because the foreign key used by the ServiceConfig
            // table is actually the ServiceInstall.Name, not the ServiceInstall.ServiceInstall
            // this is unfortunate because the service Name is not guaranteed to be unique, so
            // decompiler must assume there could be multiple matches and add the ServiceConfig to each
            // TODO: the Component column information should be taken into acount to accurately identify
            // the correct column to use
            if (null != serviceInstallTable)
            {
                foreach (Row row in serviceInstallTable.Rows)
                {
                    string             name           = (string)row[1];
                    Wix.ServiceInstall serviceInstall = (Wix.ServiceInstall) this.Core.GetIndexedElement(row);

                    if (!serviceInstalls.Contains(name))
                    {
                        serviceInstalls.Add(name, new ArrayList());
                    }

                    ((ArrayList)serviceInstalls[name]).Add(serviceInstall);
                }
            }

            if (null != serviceConfigTable)
            {
                foreach (Row row in serviceConfigTable.Rows)
                {
                    Util.ServiceConfig serviceConfig = (Util.ServiceConfig) this.Core.GetIndexedElement(row);

                    if (0 == (int)row[2])
                    {
                        Wix.Component component = (Wix.Component) this.Core.GetIndexedElement("Component", (string)row[1]);

                        if (null != component)
                        {
                            component.AddChild(serviceConfig);
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component"));
                        }
                    }
                    else
                    {
                        ArrayList serviceInstallElements = (ArrayList)serviceInstalls[row[0]];

                        if (null != serviceInstallElements)
                        {
                            foreach (Wix.ServiceInstall serviceInstall in serviceInstallElements)
                            {
                                serviceInstall.AddChild(serviceConfig);
                            }
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "ServiceName", (string)row[0], "ServiceInstall"));
                        }
                    }
                }
            }
        }