Exemple #1
0
        /// <summary>
        /// Overridden ProcessRecord method.
        /// </summary>
        protected override void ProcessRecord()
        {
            switch (ParameterSetName)
            {
            case "All":
                WriteObject(NtWindowStation.GetAccessibleWindowStations(Access), true);
                break;

            case "FromCurrent":
            {
                var winsta = NtWindowStation.Current;
                if (Access.HasFlag(WindowStationAccessRights.MaximumAllowed))
                {
                    WriteObject(winsta);
                }
                else
                {
                    WriteObject(winsta.Duplicate(Access));
                }
            }
            break;

            default:
                base.ProcessRecord();
                break;
            }
        }
Exemple #2
0
        private protected override void RunAccessCheck(IEnumerable <TokenEntry> tokens)
        {
            NtType winsta_type = NtType.GetTypeByType <NtWindowStation>();

            AccessMask winsta_access_rights = winsta_type.GenericMapping.MapMask(AccessRights);
            bool       check_winsta         = CheckMode == WindowStationCheckMode.WindowStationOnly || CheckMode == WindowStationCheckMode.WindowStationAndDesktop;
            bool       check_desktop        = CheckMode == WindowStationCheckMode.DesktopOnly || CheckMode == WindowStationCheckMode.WindowStationAndDesktop;

            using (var winstas = NtWindowStation.GetAccessibleWindowStations().ToDisposableList())
            {
                foreach (var winsta in winstas)
                {
                    if (check_winsta && winsta.IsAccessGranted(WindowStationAccessRights.ReadControl))
                    {
                        var sd = winsta.SecurityDescriptor;
                        foreach (TokenEntry token in tokens)
                        {
                            AccessMask granted_access = NtSecurity.GetMaximumAccess(sd,
                                                                                    token.Token, winsta_type.GenericMapping);
                            if (IsAccessGranted(granted_access, winsta_access_rights))
                            {
                                WriteAccessCheckResult(winsta.FullPath, winsta_type.Name, granted_access, winsta_type.GenericMapping,
                                                       sd, winsta_type.AccessRightsType, true, token.Information);
                            }
                        }
                    }

                    if (check_desktop && winsta.IsAccessGranted(WindowStationAccessRights.EnumDesktops))
                    {
                        RunAccessCheckDesktop(tokens, winsta);
                    }
                }
            }
        }