示例#1
0
        /// <summary>
        /// Decompile the SecureObjects table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileSecureObjectsTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Util.PermissionEx permissionEx = new Util.PermissionEx();

                string[] specialPermissions;
                switch ((string)row[1])
                {
                case "CreateFolder":
                    specialPermissions = UtilExtension.FolderPermissions;
                    break;

                case "File":
                    specialPermissions = UtilExtension.FilePermissions;
                    break;

                case "Registry":
                    specialPermissions = UtilExtension.RegistryPermissions;
                    break;

                case "ServiceInstall":
                    specialPermissions = UtilExtension.ServicePermissions;
                    break;

                default:
                    this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, row.Table.Name, row.Fields[1].Column.Name, row[1]));
                    return;
                }

                int permissionBits = (int)row[4];
                for (int i = 0; i < 32; i++)
                {
                    if (0 != ((permissionBits >> i) & 1))
                    {
                        string name = null;

                        if (16 > i && specialPermissions.Length > i)
                        {
                            name = specialPermissions[i];
                        }
                        else if (28 > i && UtilExtension.StandardPermissions.Length > (i - 16))
                        {
                            name = UtilExtension.StandardPermissions[i - 16];
                        }
                        else if (0 <= (i - 28) && UtilExtension.GenericPermissions.Length > (i - 28))
                        {
                            name = UtilExtension.GenericPermissions[i - 28];
                        }

                        if (null == name)
                        {
                            this.Core.OnMessage(WixWarnings.UnknownPermission(row.SourceLineNumbers, row.Table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), i));
                        }
                        else
                        {
                            switch (name)
                            {
                            case "Append":
                                permissionEx.Append = Util.YesNoType.yes;
                                break;

                            case "ChangePermission":
                                permissionEx.ChangePermission = Util.YesNoType.yes;
                                break;

                            case "CreateChild":
                                permissionEx.CreateChild = Util.YesNoType.yes;
                                break;

                            case "CreateFile":
                                permissionEx.CreateFile = Util.YesNoType.yes;
                                break;

                            case "CreateLink":
                                permissionEx.CreateLink = Util.YesNoType.yes;
                                break;

                            case "CreateSubkeys":
                                permissionEx.CreateSubkeys = Util.YesNoType.yes;
                                break;

                            case "Delete":
                                permissionEx.Delete = Util.YesNoType.yes;
                                break;

                            case "DeleteChild":
                                permissionEx.DeleteChild = Util.YesNoType.yes;
                                break;

                            case "EnumerateSubkeys":
                                permissionEx.EnumerateSubkeys = Util.YesNoType.yes;
                                break;

                            case "Execute":
                                permissionEx.Execute = Util.YesNoType.yes;
                                break;

                            case "GenericAll":
                                permissionEx.GenericAll = Util.YesNoType.yes;
                                break;

                            case "GenericExecute":
                                permissionEx.GenericExecute = Util.YesNoType.yes;
                                break;

                            case "GenericRead":
                                permissionEx.GenericRead = Util.YesNoType.yes;
                                break;

                            case "GenericWrite":
                                permissionEx.GenericWrite = Util.YesNoType.yes;
                                break;

                            case "Notify":
                                permissionEx.Notify = Util.YesNoType.yes;
                                break;

                            case "Read":
                                permissionEx.Read = Util.YesNoType.yes;
                                break;

                            case "ReadAttributes":
                                permissionEx.ReadAttributes = Util.YesNoType.yes;
                                break;

                            case "ReadExtendedAttributes":
                                permissionEx.ReadExtendedAttributes = Util.YesNoType.yes;
                                break;

                            case "ReadPermission":
                                permissionEx.ReadPermission = Util.YesNoType.yes;
                                break;

                            case "ServiceChangeConfig":
                                permissionEx.ServiceChangeConfig = Util.YesNoType.yes;
                                break;

                            case "ServiceEnumerateDependents":
                                permissionEx.ServiceEnumerateDependents = Util.YesNoType.yes;
                                break;

                            case "ServiceInterrogate":
                                permissionEx.ServiceInterrogate = Util.YesNoType.yes;
                                break;

                            case "ServicePauseContinue":
                                permissionEx.ServicePauseContinue = Util.YesNoType.yes;
                                break;

                            case "ServiceQueryConfig":
                                permissionEx.ServiceQueryConfig = Util.YesNoType.yes;
                                break;

                            case "ServiceQueryStatus":
                                permissionEx.ServiceQueryStatus = Util.YesNoType.yes;
                                break;

                            case "ServiceStart":
                                permissionEx.ServiceStart = Util.YesNoType.yes;
                                break;

                            case "ServiceStop":
                                permissionEx.ServiceStop = Util.YesNoType.yes;
                                break;

                            case "ServiceUserDefinedControl":
                                permissionEx.ServiceUserDefinedControl = Util.YesNoType.yes;
                                break;

                            case "Synchronize":
                                permissionEx.Synchronize = Util.YesNoType.yes;
                                break;

                            case "TakeOwnership":
                                permissionEx.TakeOwnership = Util.YesNoType.yes;
                                break;

                            case "Traverse":
                                permissionEx.Traverse = Util.YesNoType.yes;
                                break;

                            case "Write":
                                permissionEx.Write = Util.YesNoType.yes;
                                break;

                            case "WriteAttributes":
                                permissionEx.WriteAttributes = Util.YesNoType.yes;
                                break;

                            case "WriteExtendedAttributes":
                                permissionEx.WriteExtendedAttributes = Util.YesNoType.yes;
                                break;

                            default:
                                throw new InvalidOperationException(String.Format("Unknown permission attribute '{0}'.", name));
                            }
                        }
                    }
                }

                if (null != row[2])
                {
                    permissionEx.Domain = (string)row[2];
                }

                permissionEx.User = (string)row[3];

                this.Core.IndexElement(row, permissionEx);
            }
        }
示例#2
0
        /// <summary>
        /// Decompile the SecureObjects table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileSecureObjectsTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Util.PermissionEx permissionEx = new Util.PermissionEx();

                string[] specialPermissions;
                switch ((string)row[1])
                {
                    case "CreateFolder":
                        specialPermissions = UtilExtension.FolderPermissions;
                        break;
                    case "File":
                        specialPermissions = UtilExtension.FilePermissions;
                        break;
                    case "Registry":
                        specialPermissions = UtilExtension.RegistryPermissions;
                        break;
                    case "ServiceInstall":
                        specialPermissions = UtilExtension.ServicePermissions;
                        break;
                    default:
                        this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, row.Table.Name, row.Fields[1].Column.Name, row[1]));
                        return;
                }

                int permissionBits = (int)row[4];
                for (int i = 0; i < 32; i++)
                {
                    if (0 != ((permissionBits >> i) & 1))
                    {
                        string name = null;

                        if (16 > i && specialPermissions.Length > i)
                        {
                            name = specialPermissions[i];
                        }
                        else if (28 > i && UtilExtension.StandardPermissions.Length > (i - 16))
                        {
                            name = UtilExtension.StandardPermissions[i - 16];
                        }
                        else if (0 <= (i - 28) && UtilExtension.GenericPermissions.Length > (i - 28))
                        {
                            name = UtilExtension.GenericPermissions[i - 28];
                        }

                        if (null == name)
                        {
                            this.Core.OnMessage(WixWarnings.UnknownPermission(row.SourceLineNumbers, row.Table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), i));
                        }
                        else
                        {
                            switch (name)
                            {
                                case "Append":
                                    permissionEx.Append = Util.YesNoType.yes;
                                    break;
                                case "ChangePermission":
                                    permissionEx.ChangePermission = Util.YesNoType.yes;
                                    break;
                                case "CreateChild":
                                    permissionEx.CreateChild = Util.YesNoType.yes;
                                    break;
                                case "CreateFile":
                                    permissionEx.CreateFile = Util.YesNoType.yes;
                                    break;
                                case "CreateLink":
                                    permissionEx.CreateLink = Util.YesNoType.yes;
                                    break;
                                case "CreateSubkeys":
                                    permissionEx.CreateSubkeys = Util.YesNoType.yes;
                                    break;
                                case "Delete":
                                    permissionEx.Delete = Util.YesNoType.yes;
                                    break;
                                case "DeleteChild":
                                    permissionEx.DeleteChild = Util.YesNoType.yes;
                                    break;
                                case "EnumerateSubkeys":
                                    permissionEx.EnumerateSubkeys = Util.YesNoType.yes;
                                    break;
                                case "Execute":
                                    permissionEx.Execute = Util.YesNoType.yes;
                                    break;
                                case "GenericAll":
                                    permissionEx.GenericAll = Util.YesNoType.yes;
                                    break;
                                case "GenericExecute":
                                    permissionEx.GenericExecute = Util.YesNoType.yes;
                                    break;
                                case "GenericRead":
                                    permissionEx.GenericRead = Util.YesNoType.yes;
                                    break;
                                case "GenericWrite":
                                    permissionEx.GenericWrite = Util.YesNoType.yes;
                                    break;
                                case "Notify":
                                    permissionEx.Notify = Util.YesNoType.yes;
                                    break;
                                case "Read":
                                    permissionEx.Read = Util.YesNoType.yes;
                                    break;
                                case "ReadAttributes":
                                    permissionEx.ReadAttributes = Util.YesNoType.yes;
                                    break;
                                case "ReadExtendedAttributes":
                                    permissionEx.ReadExtendedAttributes = Util.YesNoType.yes;
                                    break;
                                case "ReadPermission":
                                    permissionEx.ReadPermission = Util.YesNoType.yes;
                                    break;
                                case "ServiceChangeConfig":
                                    permissionEx.ServiceChangeConfig = Util.YesNoType.yes;
                                    break;
                                case "ServiceEnumerateDependents":
                                    permissionEx.ServiceEnumerateDependents = Util.YesNoType.yes;
                                    break;
                                case "ServiceInterrogate":
                                    permissionEx.ServiceInterrogate = Util.YesNoType.yes;
                                    break;
                                case "ServicePauseContinue":
                                    permissionEx.ServicePauseContinue = Util.YesNoType.yes;
                                    break;
                                case "ServiceQueryConfig":
                                    permissionEx.ServiceQueryConfig = Util.YesNoType.yes;
                                    break;
                                case "ServiceQueryStatus":
                                    permissionEx.ServiceQueryStatus = Util.YesNoType.yes;
                                    break;
                                case "ServiceStart":
                                    permissionEx.ServiceStart = Util.YesNoType.yes;
                                    break;
                                case "ServiceStop":
                                    permissionEx.ServiceStop = Util.YesNoType.yes;
                                    break;
                                case "ServiceUserDefinedControl":
                                    permissionEx.ServiceUserDefinedControl = Util.YesNoType.yes;
                                    break;
                                case "Synchronize":
                                    permissionEx.Synchronize = Util.YesNoType.yes;
                                    break;
                                case "TakeOwnership":
                                    permissionEx.TakeOwnership = Util.YesNoType.yes;
                                    break;
                                case "Traverse":
                                    permissionEx.Traverse = Util.YesNoType.yes;
                                    break;
                                case "Write":
                                    permissionEx.Write = Util.YesNoType.yes;
                                    break;
                                case "WriteAttributes":
                                    permissionEx.WriteAttributes = Util.YesNoType.yes;
                                    break;
                                case "WriteExtendedAttributes":
                                    permissionEx.WriteExtendedAttributes = Util.YesNoType.yes;
                                    break;
                                default:
                                    throw new InvalidOperationException(String.Format("Unknown permission attribute '{0}'.", name));
                            }
                        }
                    }
                }

                if (null != row[2])
                {
                    permissionEx.Domain = (string)row[2];
                }

                permissionEx.User = (string)row[3];

                this.Core.IndexElement(row, permissionEx);
            }
        }
示例#3
0
        /// <summary>
        /// Finalize the SecureObjects table.
        /// </summary>
        /// <param name="tables">The collection of all tables.</param>
        /// <remarks>
        /// Nests the PermissionEx elements below their parent elements.  There are no declared foreign
        /// keys for the parents of the SecureObjects table.
        /// </remarks>
        private void FinalizeSecureObjectsTable(TableCollection tables)
        {
            Table createFolderTable  = tables["CreateFolder"];
            Table secureObjectsTable = tables["SecureObjects"];

            Hashtable createFolders = new Hashtable();

            // index the CreateFolder table because the foreign key to this table from the
            // LockPermissions table is only part of the primary key of this table
            if (null != createFolderTable)
            {
                foreach (Row row in createFolderTable.Rows)
                {
                    Wix.CreateFolder createFolder = (Wix.CreateFolder) this.Core.GetIndexedElement(row);
                    string           directoryId  = (string)row[0];

                    if (!createFolders.Contains(directoryId))
                    {
                        createFolders.Add(directoryId, new ArrayList());
                    }
                    ((ArrayList)createFolders[directoryId]).Add(createFolder);
                }
            }

            if (null != secureObjectsTable)
            {
                foreach (Row row in secureObjectsTable.Rows)
                {
                    string id    = (string)row[0];
                    string table = (string)row[1];

                    Util.PermissionEx permissionEx = (Util.PermissionEx) this.Core.GetIndexedElement(row);

                    if ("CreateFolder" == table)
                    {
                        ArrayList createFolderElements = (ArrayList)createFolders[id];

                        if (null != createFolderElements)
                        {
                            foreach (Wix.CreateFolder createFolder in createFolderElements)
                            {
                                createFolder.AddChild(permissionEx);
                            }
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, "SecureObjects", row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "LockObject", id, table));
                        }
                    }
                    else
                    {
                        Wix.IParentElement parentElement = (Wix.IParentElement) this.Core.GetIndexedElement(table, id);

                        if (null != parentElement)
                        {
                            parentElement.AddChild(permissionEx);
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, "SecureObjects", row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "LockObject", id, table));
                        }
                    }
                }
            }
        }