Ejemplo n.º 1
0
		public RawSecurityDescriptor (byte[] binaryForm, int offset)
		{
			if (binaryForm == null)
				throw new ArgumentNullException("binaryForm");
			
			if (offset < 0 || offset > binaryForm.Length - 0x14)
				throw new ArgumentOutOfRangeException("offset", offset, "Offset out of range");
			
			if (binaryForm[offset] != 1)
				throw new ArgumentException("Unrecognized Security Descriptor revision.", "binaryForm");
			
			resourcemgr_control = binaryForm[offset + 0x01];
			control_flags = (ControlFlags)ReadUShort(binaryForm, offset + 0x02);
			
			int ownerPos = ReadInt(binaryForm, offset + 0x04);
			int groupPos = ReadInt(binaryForm, offset + 0x08);
			int saclPos = ReadInt(binaryForm, offset + 0x0C);
			int daclPos = ReadInt(binaryForm, offset + 0x10);
			
			if (ownerPos != 0)
				owner_sid = new SecurityIdentifier(binaryForm, ownerPos);
			
			if (groupPos != 0)
				group_sid = new SecurityIdentifier(binaryForm, groupPos);
			
			if (saclPos != 0)
				system_acl = new RawAcl(binaryForm, saclPos);
			
			if (daclPos != 0)
				discretionary_acl = new RawAcl(binaryForm, daclPos);
		}
Ejemplo n.º 2
0
		public RawSecurityDescriptor (ControlFlags flags,
					      SecurityIdentifier owner,
					      SecurityIdentifier group,
					      RawAcl systemAcl,
					      RawAcl discretionaryAcl)
		{
		}
Ejemplo n.º 3
0
		public RawSecurityDescriptor (string sddlForm)
		{
			if (sddlForm == null)
				throw new ArgumentNullException ("sddlForm");
			
			ParseSddl (sddlForm.Replace (" ", ""));
			
			control_flags |= ControlFlags.SelfRelative;
		}
Ejemplo n.º 4
0
		public CommonSecurityDescriptor (bool isContainer, bool isDS,
						 ControlFlags flags,
						 SecurityIdentifier owner,
						 SecurityIdentifier group,
						 SystemAcl systemAcl,
						 DiscretionaryAcl discretionaryAcl)
		{
			Init (isContainer, isDS, flags, owner, group, systemAcl, discretionaryAcl);
		}
Ejemplo n.º 5
0
		public RawSecurityDescriptor (ControlFlags flags,
		                              SecurityIdentifier owner,
		                              SecurityIdentifier @group,
		                              RawAcl systemAcl,
		                              RawAcl discretionaryAcl)
		{
			control_flags = flags;
			owner_sid = owner;
			group_sid = @group;
			system_acl = systemAcl;
			discretionary_acl = discretionaryAcl;
		}
Ejemplo n.º 6
0
		public CommonSecurityDescriptor (bool isContainer, bool isDS,
						 ControlFlags flags,
						 SecurityIdentifier owner,
						 SecurityIdentifier group,
						 SystemAcl systemAcl,
						 DiscretionaryAcl discretionaryAcl)
		{
			this.isContainer = isContainer;
			this.isDS = isDS;
			this.flags = flags;
			this.owner = owner;
			this.group = group;
			this.systemAcl = systemAcl;
			this.discretionaryAcl = discretionaryAcl;
			
			throw new NotImplementedException ();
		}
Ejemplo n.º 7
0
 public void ClearFlags(ControlFlags value)
 {
     flags &= (~value);
 }
Ejemplo n.º 8
0
 /// <summary>Sets the <see cref="P:System.Security.AccessControl.RawSecurityDescriptor.ControlFlags" /> property of this <see cref="T:System.Security.AccessControl.RawSecurityDescriptor" /> object to the specified value.</summary>
 /// <param name="flags">One or more values of the <see cref="T:System.Security.AccessControl.ControlFlags" /> enumeration combined with a logical OR operation.</param>
 // Token: 0x06002070 RID: 8304 RVA: 0x00071BD1 File Offset: 0x0006FDD1
 public void SetFlags(ControlFlags flags)
 {
     this._flags = (flags | ControlFlags.SelfRelative);
 }
Ejemplo n.º 9
0
 public UserHintJumpBlock(BinaryReader binaryReader)
 {
     this.flags = (Flags)binaryReader.ReadInt16();
     this.geometryIndex = binaryReader.ReadShortBlockIndex1();
     this.forceJumpHeight = (ForceJumpHeight)binaryReader.ReadInt16();
     this.controlFlags = (ControlFlags)binaryReader.ReadInt16();
 }
Ejemplo n.º 10
0
 public static bool IsBreak(this ControlFlags flags)
 {
     return(IsFlagged(flags, ControlFlags.Internal_Break) ||
            IsFlagged(flags, ControlFlags.Layout_ForceBreak));
 }
Ejemplo n.º 11
0
		internal override string GetSddlForm(ControlFlags sdFlags,
		                                     bool isDacl)
		{
			StringBuilder result = new StringBuilder();
			
			if(isDacl) {
				if((sdFlags & ControlFlags.DiscretionaryAclProtected) != 0)
					result.Append("P");
				if((sdFlags & ControlFlags.DiscretionaryAclAutoInheritRequired) != 0)
					result.Append("AR");
				if((sdFlags & ControlFlags.DiscretionaryAclAutoInherited) != 0)
					result.Append("AI");
			} else {
				if((sdFlags & ControlFlags.SystemAclProtected) != 0)
					result.Append("P");
				if((sdFlags & ControlFlags.SystemAclAutoInheritRequired) != 0)
					result.Append("AR");
				if((sdFlags & ControlFlags.SystemAclAutoInherited) != 0)
					result.Append("AI");
			}
			
			foreach(var ace in list)
			{
				result.Append(ace.GetSddlForm());
			}
			
			return result.ToString();
		}
Ejemplo n.º 12
0
 public void SetFlags(ControlFlags value)
 {
     flags |= value;
 }
Ejemplo n.º 13
0
        private static bool VerifyResult(bool isContainer, bool isDS, ControlFlags controlFlags, SecurityIdentifier owner, SecurityIdentifier group, SystemAcl sacl, DiscretionaryAcl dacl)
        {
            CommonSecurityDescriptor commonSecurityDescriptor = null;
            bool result = false;

            try
            {
                commonSecurityDescriptor = new CommonSecurityDescriptor(isContainer, isDS, controlFlags, owner, group, sacl, dacl);
                // verify the result
                if ((isContainer == commonSecurityDescriptor.IsContainer) &&
                    (isDS == commonSecurityDescriptor.IsDS) &&
                    ((((sacl != null) ? (controlFlags | ControlFlags.SystemAclPresent) : (controlFlags & (~ControlFlags.SystemAclPresent)))
                      | ControlFlags.SelfRelative | ControlFlags.DiscretionaryAclPresent) == commonSecurityDescriptor.ControlFlags) &&
                    (owner == commonSecurityDescriptor.Owner) &&
                    (group == commonSecurityDescriptor.Group) &&
                    (sacl == commonSecurityDescriptor.SystemAcl) &&
                    (Utils.ComputeBinaryLength(commonSecurityDescriptor, dacl != null) == commonSecurityDescriptor.BinaryLength))
                {
                    if (dacl == null)
                    {
                        //check the constructor created an empty Dacl with correct IsContainer and isDS info
                        if (isContainer == commonSecurityDescriptor.DiscretionaryAcl.IsContainer &&
                            isDS == commonSecurityDescriptor.DiscretionaryAcl.IsDS &&
                            commonSecurityDescriptor.DiscretionaryAcl.Count == 1 &&
                            Utils.VerifyDaclWithCraftedAce(isContainer, isDS, commonSecurityDescriptor.DiscretionaryAcl))
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    else if (dacl == commonSecurityDescriptor.DiscretionaryAcl)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            catch (ArgumentException)
            {
                if ((sacl != null && sacl.IsContainer != isContainer) ||
                    (sacl != null && sacl.IsDS != isDS) ||
                    (dacl != null && dacl.IsContainer != isContainer) ||
                    (dacl != null && dacl.IsDS != isDS))
                {
                    result = true;
                }
                else
                {
                    // unexpected exception
                    result = false;
                }
            }
            return(result);
        }
Ejemplo n.º 14
0
        private void CreateFromParts(bool isContainer, bool isDS, ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, SystemAcl systemAcl, DiscretionaryAcl discretionaryAcl)
        {
            if (systemAcl != null &&
                systemAcl.IsContainer != isContainer)
            {
                throw new ArgumentException(
                     isContainer ?
                        SR.AccessControl_MustSpecifyContainerAcl :
                        SR.AccessControl_MustSpecifyLeafObjectAcl,
nameof(systemAcl));
            }

            if (discretionaryAcl != null &&
                discretionaryAcl.IsContainer != isContainer)
            {
                throw new ArgumentException(
                     isContainer ?
                        SR.AccessControl_MustSpecifyContainerAcl :
                        SR.AccessControl_MustSpecifyLeafObjectAcl,
nameof(discretionaryAcl));
            }

            _isContainer = isContainer;

            if (systemAcl != null &&
                systemAcl.IsDS != isDS)
            {
                throw new ArgumentException(
                     isDS ?
                        SR.AccessControl_MustSpecifyDirectoryObjectAcl :
                        SR.AccessControl_MustSpecifyNonDirectoryObjectAcl,
nameof(systemAcl));
            }

            if (discretionaryAcl != null &&
                discretionaryAcl.IsDS != isDS)
            {
                throw new ArgumentException(
                    isDS ?
                        SR.AccessControl_MustSpecifyDirectoryObjectAcl :
                        SR.AccessControl_MustSpecifyNonDirectoryObjectAcl,
nameof(discretionaryAcl));
            }

            _isDS = isDS;

            _sacl = systemAcl;

            //
            // Replace null DACL with an allow-all for everyone DACL
            //

            if (discretionaryAcl == null)
            {
                //
                // to conform to native behavior, we will add allow everyone ace for DACL
                //

                discretionaryAcl = DiscretionaryAcl.CreateAllowEveryoneFullAccess(_isDS, _isContainer);
            }

            _dacl = discretionaryAcl;

            //
            // DACL is never null. So always set the flag bit on
            //

            ControlFlags actualFlags = flags | ControlFlags.DiscretionaryAclPresent;

            //
            // Keep SACL and the flag bit in sync.
            //

            if (systemAcl == null)
            {
                unchecked { actualFlags &= ~(ControlFlags.SystemAclPresent); }
            }
            else
            {
                actualFlags |= (ControlFlags.SystemAclPresent);
            }

            _rawSd = new RawSecurityDescriptor(actualFlags, owner, group, systemAcl == null ? null : systemAcl.RawAcl, discretionaryAcl.RawAcl);
        }
Ejemplo n.º 15
0
        public void WriteTo(byte[] buffer, int offset)
        {
            // Write out the security descriptor manually because on NTFS the DACL is written
            // before the Owner & Group.  Writing the components in the same order means the
            // hashes will match for identical Security Descriptors.
            ControlFlags controlFlags = Descriptor.ControlFlags;

            buffer[offset + 0x00] = 1;
            buffer[offset + 0x01] = Descriptor.ResourceManagerControl;
            EndianUtilities.WriteBytesLittleEndian((ushort)controlFlags, buffer, offset + 0x02);

            // Blank out offsets, will fill later
            for (int i = 0x04; i < 0x14; ++i)
            {
                buffer[offset + i] = 0;
            }

            int pos = 0x14;

            RawAcl discAcl = Descriptor.DiscretionaryAcl;

            if ((controlFlags & ControlFlags.DiscretionaryAclPresent) != 0 && discAcl != null)
            {
                EndianUtilities.WriteBytesLittleEndian(pos, buffer, offset + 0x10);
                discAcl.GetBinaryForm(buffer, offset + pos);
                pos += Descriptor.DiscretionaryAcl.BinaryLength;
            }
            else
            {
                EndianUtilities.WriteBytesLittleEndian(0, buffer, offset + 0x10);
            }

            RawAcl sysAcl = Descriptor.SystemAcl;

            if ((controlFlags & ControlFlags.SystemAclPresent) != 0 && sysAcl != null)
            {
                EndianUtilities.WriteBytesLittleEndian(pos, buffer, offset + 0x0C);
                sysAcl.GetBinaryForm(buffer, offset + pos);
                pos += Descriptor.SystemAcl.BinaryLength;
            }
            else
            {
                EndianUtilities.WriteBytesLittleEndian(0, buffer, offset + 0x0C);
            }

            if (Descriptor.Owner != null)
            {
                EndianUtilities.WriteBytesLittleEndian(pos, buffer, offset + 0x04);
                Descriptor.Owner.GetBinaryForm(buffer, offset + pos);
                pos += Descriptor.Owner.BinaryLength;
            }
            else
            {
                EndianUtilities.WriteBytesLittleEndian(0, buffer, offset + 0x04);
            }

            if (Descriptor.Group != null)
            {
                EndianUtilities.WriteBytesLittleEndian(pos, buffer, offset + 0x08);
                Descriptor.Group.GetBinaryForm(buffer, offset + pos);
                pos += Descriptor.Group.BinaryLength;
            }
            else
            {
                EndianUtilities.WriteBytesLittleEndian(0, buffer, offset + 0x08);
            }

            if (pos != Descriptor.BinaryLength)
            {
                throw new IOException("Failed to write Security Descriptor correctly");
            }
        }
Ejemplo n.º 16
0
 internal abstract string GetSddlForm(ControlFlags sdFlags,
                                      bool isDacl);
Ejemplo n.º 17
0
 // Constructors
 public RawSecurityDescriptor(ControlFlags flags, System.Security.Principal.SecurityIdentifier owner, System.Security.Principal.SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
 {
 }
Ejemplo n.º 18
0
 // Methods
 public void SetFlags(ControlFlags flags)
 {
 }
Ejemplo n.º 19
0
        /// <summary>Initializes a new instance of the <see cref="T:System.Security.AccessControl.RawSecurityDescriptor" /> class from the specified array of byte values.</summary>
        /// <param name="binaryForm">The array of byte values from which to create the new <see cref="T:System.Security.AccessControl.RawSecurityDescriptor" /> object.</param>
        /// <param name="offset">The offset in the  <paramref name="binaryForm" /> array at which to begin copying.</param>
        // Token: 0x06002063 RID: 8291 RVA: 0x0007194C File Offset: 0x0006FB4C
        public RawSecurityDescriptor(byte[] binaryForm, int offset)
        {
            if (binaryForm == null)
            {
                throw new ArgumentNullException("binaryForm");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            }
            if (binaryForm.Length - offset < 20)
            {
                throw new ArgumentOutOfRangeException("binaryForm", Environment.GetResourceString("ArgumentOutOfRange_ArrayTooSmall"));
            }
            if (binaryForm[offset] != GenericSecurityDescriptor.Revision)
            {
                throw new ArgumentOutOfRangeException("binaryForm", Environment.GetResourceString("AccessControl_InvalidSecurityDescriptorRevision"));
            }
            byte         resourceManagerControl = binaryForm[offset + 1];
            ControlFlags controlFlags           = (ControlFlags)((int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8));

            if ((controlFlags & ControlFlags.SelfRelative) == ControlFlags.None)
            {
                throw new ArgumentException(Environment.GetResourceString("AccessControl_InvalidSecurityDescriptorSelfRelativeForm"), "binaryForm");
            }
            int num = GenericSecurityDescriptor.UnmarshalInt(binaryForm, offset + 4);
            SecurityIdentifier owner;

            if (num != 0)
            {
                owner = new SecurityIdentifier(binaryForm, offset + num);
            }
            else
            {
                owner = null;
            }
            int num2 = GenericSecurityDescriptor.UnmarshalInt(binaryForm, offset + 8);
            SecurityIdentifier group;

            if (num2 != 0)
            {
                group = new SecurityIdentifier(binaryForm, offset + num2);
            }
            else
            {
                group = null;
            }
            int    num3 = GenericSecurityDescriptor.UnmarshalInt(binaryForm, offset + 12);
            RawAcl systemAcl;

            if ((controlFlags & ControlFlags.SystemAclPresent) != ControlFlags.None && num3 != 0)
            {
                systemAcl = new RawAcl(binaryForm, offset + num3);
            }
            else
            {
                systemAcl = null;
            }
            int    num4 = GenericSecurityDescriptor.UnmarshalInt(binaryForm, offset + 16);
            RawAcl discretionaryAcl;

            if ((controlFlags & ControlFlags.DiscretionaryAclPresent) != ControlFlags.None && num4 != 0)
            {
                discretionaryAcl = new RawAcl(binaryForm, offset + num4);
            }
            else
            {
                discretionaryAcl = null;
            }
            this.CreateFromParts(controlFlags, owner, group, systemAcl, discretionaryAcl);
            if ((controlFlags & ControlFlags.RMControlValid) != ControlFlags.None)
            {
                this.ResourceManagerControl = resourceManagerControl;
            }
        }
Ejemplo n.º 20
0
 internal void RemoveControlFlags(ControlFlags flags)
 {
     unchecked
     {
         _rawSd.SetFlags(_rawSd.ControlFlags & ~flags);
     }
 }
        public static void TestGetSddlForm(bool isContainer, bool isDS, int flags, string ownerStr, string groupStr, string saclStr, string daclStr, bool getOwner, bool getGroup, bool getSacl, bool getDacl, string expectedSddl)
        {
            CommonSecurityDescriptor commonSecurityDescriptor = null;
            string resultSddl = null;

            ControlFlags          controlFlags       = ControlFlags.OwnerDefaulted;
            SecurityIdentifier    owner              = null;
            SecurityIdentifier    group              = null;
            RawAcl                rawAcl             = null;
            SystemAcl             sacl               = null;
            DiscretionaryAcl      dacl               = null;
            AccessControlSections accControlSections = AccessControlSections.None;

            controlFlags = (ControlFlags)flags;
            owner        = (ownerStr != null) ? new SecurityIdentifier(Utils.TranslateStringConstFormatSidToStandardFormatSid(ownerStr)) : null;
            group        = (groupStr != null) ? new SecurityIdentifier(Utils.TranslateStringConstFormatSidToStandardFormatSid(groupStr)) : null;

            rawAcl = (saclStr != null) ? Utils.CreateRawAclFromString(saclStr) : null;
            if (rawAcl == null)
            {
                sacl = null;
            }
            else
            {
                sacl = new SystemAcl(isContainer, isDS, rawAcl);
            }

            rawAcl = (daclStr != null) ? Utils.CreateRawAclFromString(daclStr) : null;
            if (rawAcl == null)
            {
                dacl = null;
            }
            else
            {
                dacl = new DiscretionaryAcl(isContainer, isDS, rawAcl);
            }

            commonSecurityDescriptor = new CommonSecurityDescriptor(isContainer, isDS, controlFlags, owner, group, sacl, dacl);
            if (getOwner)
            {
                accControlSections |= AccessControlSections.Owner;
            }
            if (getGroup)
            {
                accControlSections |= AccessControlSections.Group;
            }
            if (getSacl)
            {
                accControlSections |= AccessControlSections.Audit;
            }
            if (getDacl)
            {
                accControlSections |= AccessControlSections.Access;
            }

            resultSddl = commonSecurityDescriptor.GetSddlForm(accControlSections);
            if (expectedSddl == null || resultSddl == null)
            {
                Assert.True(expectedSddl == null && resultSddl == null);
            }
            else
            {
                Assert.True(String.Compare(expectedSddl, resultSddl, StringComparison.CurrentCultureIgnoreCase) == 0);
            }
        }
Ejemplo n.º 22
0
        //
        // Creates a security descriptor explicitly
        //

        public RawSecurityDescriptor(ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
            : base()
        {
            CreateFromParts(flags, owner, group, systemAcl, discretionaryAcl);
        }
Ejemplo n.º 23
0
        private static void ParseFlags(string sddlForm,
                                       bool isDacl,
                                       ref ControlFlags sdFlags,
                                       ref int pos)
        {
            char ch = Char.ToUpperInvariant(sddlForm[pos]);

            while (ch == 'P' || ch == 'A')
            {
                if (ch == 'P')
                {
                    if (isDacl)
                    {
                        sdFlags |= ControlFlags.DiscretionaryAclProtected;
                    }
                    else
                    {
                        sdFlags |= ControlFlags.SystemAclProtected;
                    }
                    pos++;
                }
                else if (sddlForm.Length > pos + 1)
                {
                    ch = Char.ToUpperInvariant(sddlForm[pos + 1]);
                    if (ch == 'R')
                    {
                        if (isDacl)
                        {
                            sdFlags |= ControlFlags.DiscretionaryAclAutoInheritRequired;
                        }
                        else
                        {
                            sdFlags |= ControlFlags.SystemAclAutoInheritRequired;
                        }
                        pos += 2;
                    }
                    else if (ch == 'I')
                    {
                        if (isDacl)
                        {
                            sdFlags |= ControlFlags.DiscretionaryAclAutoInherited;
                        }
                        else
                        {
                            sdFlags |= ControlFlags.SystemAclAutoInherited;
                        }
                        pos += 2;
                    }
                    else
                    {
                        throw new ArgumentException("Invalid SDDL string.", "sddlForm");
                    }
                }
                else
                {
                    throw new ArgumentException("Invalid SDDL string.", "sddlForm");
                }

                ch = Char.ToUpperInvariant(sddlForm[pos]);
            }
        }
Ejemplo n.º 24
0
 private bool GetControlFlag(ControlFlags flag)
 {
     return (agentControls & (uint)flag) != 0;
 }
Ejemplo n.º 25
0
        private void ProcessTagWord(int tagWord)
        {
            //
            // From the TRICON schematic (page 16):
            // Bit 3 is the Enable bit, which enables selection of one of four commands
            // to the drive, specified in bits 1 and 2:
            // (and as usual, these are in the backwards Nova/Alto bit ordering scheme)
            // Bits 1 and 2 decode to:
            // 0 0 - Control
            // 0 1 - Set Head
            // 1 0 - Set Cylinder
            // 1 1 - Set Drive
            //
            // Head, Cylinder, Drive are straightforward -- the lower bits of the tag
            // word contain the data for the command.
            //
            // The Control bits are described in the Trident T300 Theory of Operations manual,
            // Page 3-13 and are the lower 10 bits of the tag command:
            //
            // 0 - Strobe Late  : Skews read data detection 4ns late for attempted read-error recovery.
            // 1 - Strobe Early : Same as above, but early.
            // 2 - Write        : Turns on circuits to write data,
            // 3 - Read         : Turns on read circuits and resets Attention interrupts.
            // 4 - Address Mark : Commands an address mark to be generated, if writing; or
            //                    enables the address mark detector, if reading.
            // 5 - Reset Head Register : Resets HAR to 0
            // 6 - Device Check Reset : Resets most types of Device Check errors unless an error
            //                          condition is still present.
            // 7 - Head Select  : Tuns on the head-selection circuits.  Head select must be active 5
            //                    or 15 microseconds before Write or Read is commanded, respectively.
            // 8 - Rezero       : Repositions the heads to cylinder 000, selects Head Address 0, and resets
            //                    some types of Device Checks.
            // 9 - Head Advance : Increases Head Address count by one.
            //
            //
            // Bit 0 of the Tag word, if set, tells the controller to hold off Output FIFO processing
            // until the next sector pulse.
            //
            if ((tagWord & 0x8000) != 0)
            {
                _pauseOutputProcessing = true;
                Log.Write(LogComponent.TridentController, "Output FIFO processing paused until next sector pulse.");
            }

            //
            // See if the enable bit (3) is set, in which case this is a command to the drive.
            //
            if ((tagWord & 0x1000) != 0)
            {
                //
                // Switch on the specific command
                switch ((TagCommand)((tagWord & 0x6000) >> 13))
                {
                case TagCommand.Control:
                    Log.Write(LogComponent.TridentController, "Control word.");
                    ControlFlags control = (ControlFlags)tagWord;

                    if ((control & ControlFlags.HeadAdvance) != 0)
                    {
                        if (!SelectedDrive.IsLoaded)
                        {
                            _deviceCheck = true;
                        }
                        else
                        {
                            if (SelectedDrive.Head + 1 >= SelectedDrive.Pack.Geometry.Heads)
                            {
                                _headOverflow = true;
                                _deviceCheck  = true;

                                Log.Write(LogComponent.TridentController, "Head {0} is out of range on Head Advance.", SelectedDrive.Head + 1);
                            }
                            else
                            {
                                SelectedDrive.Head++;
                                Log.Write(LogComponent.TridentController, "Control: Head Advance.  Head is now {0}", SelectedDrive.Head);
                            }
                        }
                    }

                    if ((control & ControlFlags.Rezero) != 0)
                    {
                        _deviceCheck       = false;
                        SelectedDrive.Head = 0;

                        InitSeek(0);

                        Log.Write(LogComponent.TridentController, "Control: Rezero.");
                    }

                    if ((control & ControlFlags.HeadSelect) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Head Select.");

                        if (!SelectedDrive.IsLoaded)
                        {
                            _deviceCheck = true;
                        }

                        // TODO: technically this needs to be active before a write or read is selected.  Do I care?
                    }

                    if ((control & ControlFlags.DeviceCheckReset) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Device Check Reset.");
                        _deviceCheck = false;
                    }

                    if ((control & ControlFlags.ResetHeadRegister) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Reset Head Register.");
                        SelectedDrive.Head = 0;
                    }

                    if ((control & ControlFlags.AddressMark) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Address mark.");

                        // Not much to do here, emulation-wise.
                    }

                    if ((control & ControlFlags.Read) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Read.");
                        //
                        // Commence reading -- start reading a word at a time into the input FIFO,
                        // Waking up the Input task as necessary.
                        //
                        if (NotReady())
                        {
                            _deviceCheck = true;
                        }
                        else
                        {
                            InitRead();
                        }
                    }

                    if ((control & ControlFlags.Write) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Write.");

                        //
                        // Commence writing -- start pulling a word at a time out of the output FIFO,
                        // Waking up the Output task as necessary.
                        //
                        if (NotReady())
                        {
                            _deviceCheck = true;
                        }
                        else
                        {
                            InitWrite();
                        }
                    }

                    if ((control & ControlFlags.StrobeEarly) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Strobe Early.");

                        // Not going to emulate this, as fun as it sounds.
                    }

                    if ((control & ControlFlags.StrobeLate) != 0)
                    {
                        Log.Write(LogComponent.TridentController, "Control: Strobe Late.");

                        // Not going to emulate this either.
                    }

                    break;

                case TagCommand.SetHead:
                    int head = tagWord & 0x1f;     // low 5 bits
                    Log.Write(LogComponent.TridentController, "Command is Set Head {0}", head);

                    if (!SelectedDrive.IsLoaded)
                    {
                        _deviceCheck = true;
                    }
                    else
                    {
                        if (head >= SelectedDrive.Pack.Geometry.Heads)
                        {
                            _headOverflow = true;
                            _deviceCheck  = true;

                            Log.Write(LogComponent.TridentController, "Head {0} is out of range.", head);
                        }
                        else
                        {
                            SelectedDrive.Head = head;
                        }
                    }
                    break;

                case TagCommand.SetCylinder:
                    int cyl = tagWord & 0x3ff;     // low 10 bits
                    Log.Write(LogComponent.TridentController, "Command is Set Cylinder {0}.", cyl);

                    if (NotReady())
                    {
                        _deviceCheck = true;
                    }
                    else
                    {
                        InitSeek(cyl);
                    }
                    break;

                case TagCommand.SetDrive:
                    //
                    // We take all four drive-select bits even though only 8 drives are actually supported.
                    // The high bit is used by many trident utilities to select an invalid drive to test for
                    // the presence of the 8-drive multiplexer.
                    // (In the absence of the multiplexer, selecting any drive selects drive 0.)
                    //
                    _selectedDrive = tagWord & 0xf;

                    Log.Write(LogComponent.TridentController, "Command is Set Drive {0}", _selectedDrive);
                    break;
                }
            }
        }
Ejemplo n.º 26
0
		private static void ParseFlags(string sddlForm,
		                               bool isDacl,
		                               ref ControlFlags sdFlags,
		                               ref int pos)
		{
			char ch = Char.ToUpperInvariant(sddlForm[pos]);
			while(ch == 'P' || ch == 'A') {
				if(ch == 'P') {
					if (isDacl)
						sdFlags |= ControlFlags.DiscretionaryAclProtected;
					else
						sdFlags |= ControlFlags.SystemAclProtected;
					pos++;
				} else if(sddlForm.Length > pos + 1) {
					ch = Char.ToUpperInvariant(sddlForm[pos + 1]);
					if(ch == 'R') {
						if (isDacl)
							sdFlags |= ControlFlags.DiscretionaryAclAutoInheritRequired;
						else
							sdFlags |= ControlFlags.SystemAclAutoInheritRequired;
						pos += 2;
					} else if (ch == 'I') {
						if (isDacl)
							sdFlags |= ControlFlags.DiscretionaryAclAutoInherited;
						else
							sdFlags |= ControlFlags.SystemAclAutoInherited;
						pos += 2;
					} else {
						throw new ArgumentException("Invalid SDDL string.", "sddlForm");
					}
				} else {
					throw new ArgumentException("Invalid SDDL string.", "sddlForm");
				}
				
				ch = Char.ToUpperInvariant(sddlForm[pos]);
			}
			
		}
Ejemplo n.º 27
0
		public void SetDiscretionaryAclProtection (bool isProtected,
							   bool preserveInheritance)
		{
			DiscretionaryAcl.IsAefa = false;
			
			if (!isProtected) {
				flags &= ~ControlFlags.DiscretionaryAclProtected;
				return;
			}
			
			flags |= ControlFlags.DiscretionaryAclProtected;
			if (!preserveInheritance)
				DiscretionaryAcl.RemoveInheritedAces ();
		}
	// Constructors
	public CommonSecurityDescriptor(bool isContainer, bool isDS, ControlFlags flags, System.Security.Principal.SecurityIdentifier owner, System.Security.Principal.SecurityIdentifier group, SystemAcl systemAcl, DiscretionaryAcl discretionaryAcl) {}
Ejemplo n.º 29
0
		public void AddDiscretionaryAcl (byte revision, int trusted)
		{
			DiscretionaryAcl = new DiscretionaryAcl (IsContainer, IsDS, revision, trusted);
			flags |= ControlFlags.DiscretionaryAclPresent;
		}
Ejemplo n.º 30
0
		public void SetFlags (ControlFlags flags)
		{
			control_flags = flags | ControlFlags.SelfRelative;
		}
Ejemplo n.º 31
0
 public static bool IsStackedOrFloating(this ControlFlags flags)
 {
     return(IsFlagged(flags, ControlFlags.Layout_Stacked) || IsFlagged(flags, ControlFlags.Layout_Floating));
 }
Ejemplo n.º 32
0
        public Binding(string sourcePath, object target, string targetPath, BindingMode mode, ConversionMode conversionMode, IValueConverter converter)
        {
            if (target == null)
            {
                Debug.LogError("target is null");
                return;
            }

            if (string.IsNullOrEmpty(sourcePath))
            {
                Debug.LogError("sourcePath is null", target as UnityEngine.Object);
                return;
            }

            if (string.IsNullOrEmpty(targetPath))
            {
                Debug.LogError("targetPath is null", target as UnityEngine.Object);
                return;
            }

            // handle nested path
            var bindingTarget      = BindingUtility.GetBindingObject(target, targetPath);
            var targetPropertyName = BindingUtility.GetPropertyName(targetPath);
            var targetType         = bindingTarget.GetType();

            // get target property accessor
            var targetProperty = TypeCache.Instance.GetPropertyAccessor(targetType, targetPropertyName);

            if (targetProperty == null)
            {
                Debug.LogError(string.Format("Invalid target path {0}", targetPath), target as UnityEngine.Object);
                return;
            }

            // check conversion mode
            if (conversionMode == ConversionMode.Parameter && converter == null)
            {
                Debug.LogError("Converter is null", target as UnityEngine.Object);
                return;
            }

            // set fields
            this.mode               = mode;
            this.sourcePath         = sourcePath;
            this.sourcePropertyName = BindingUtility.GetPropertyName(sourcePath);
            this.target             = bindingTarget;
            this.targetPath         = targetPropertyName;
            this.targetProperty     = targetProperty;

            // setup converter
            if (conversionMode == ConversionMode.Parameter)
            {
                // use specified converter
                this.converter = converter;
            }
            else if (conversionMode == ConversionMode.Automatic)
            {
                // set flag
                flags = ControlFlags.AutoMatchConverter;
            }
        }
Ejemplo n.º 33
0
 internal void UpdateControlFlags(ControlFlags flagsToUpdate, ControlFlags newFlags)
 {
     ControlFlags finalFlags = newFlags | (_rawSd.ControlFlags & (~flagsToUpdate));
     _rawSd.SetFlags(finalFlags);
 }
Ejemplo n.º 34
0
 public void SetFlags(ControlFlags flags)
 {
     control_flags = flags | ControlFlags.SelfRelative;
 }
Ejemplo n.º 35
0
        public static bool IsFlagged(this ControlFlags flags, ControlFlags flag)
        {
            var masked = (uint)(flags & flag);

            return(masked == (int)flag);
        }
Ejemplo n.º 36
0
		public void SetSystemAclProtection (bool isProtected,
						    bool preserveInheritance)
		{
			if (!isProtected) {
				flags &= ~ControlFlags.SystemAclProtected;
				return;
			}
			
			flags |= ControlFlags.SystemAclProtected;
			if (!preserveInheritance && SystemAcl != null)
				SystemAcl.RemoveInheritedAces ();
		}
Ejemplo n.º 37
0
 private bool GetControlFlag(ControlFlags flag)
 {
     return((agentControls & (uint)flag) != 0);
 }
Ejemplo n.º 38
0
		public void AddSystemAcl(byte revision, int trusted)
		{
			SystemAcl = new SystemAcl (IsContainer, IsDS, revision, trusted);
			flags |= ControlFlags.SystemAclPresent;
		}
Ejemplo n.º 39
0
        internal void UpdateControlFlags(ControlFlags flagsToUpdate, ControlFlags newFlags)
        {
            ControlFlags finalFlags = newFlags | (_rawSd.ControlFlags & (~flagsToUpdate));

            _rawSd.SetFlags(finalFlags);
        }
Ejemplo n.º 40
0
		void Init (bool isContainer, bool isDS,
			   ControlFlags flags,
			   SecurityIdentifier owner,
			   SecurityIdentifier group,
			   SystemAcl systemAcl,
			   DiscretionaryAcl discretionaryAcl)
		{
			this.flags = flags & ~ControlFlags.SystemAclPresent;
			this.is_container = isContainer;
			this.is_ds = isDS;
			
			Owner = owner;
			Group = group;
			SystemAcl = systemAcl;
			DiscretionaryAcl = discretionaryAcl;
		}
Ejemplo n.º 41
0
        //
        // These two add/remove method must be called with great care (and thus it is internal)
        // The caller is responsible for keeping the SaclPresent and DaclPresent bits in sync
        // with the actual SACL and DACL.
        //

        internal void AddControlFlags(ControlFlags flags)
        {
            _rawSd.SetFlags(_rawSd.ControlFlags | flags);
        }
Ejemplo n.º 42
0
        //
        // These two add/remove method must be called with great care (and thus it is internal)
        // The caller is responsible for keeping the SaclPresent and DaclPresent bits in sync
        // with the actual SACL and DACL.
        //

        internal void AddControlFlags(ControlFlags flags)
        {
            _rawSd.SetFlags(_rawSd.ControlFlags | flags);
        }
Ejemplo n.º 43
0
        //
        // Creates a security descriptor explicitly
        //

        public RawSecurityDescriptor(ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
            : base()
        {
            CreateFromParts(flags, owner, group, systemAcl, discretionaryAcl);
        }
Ejemplo n.º 44
0
 private void CreateFromParts(ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
 {
     SetFlags(flags);
     Owner = owner;
     Group = group;
     SystemAcl = systemAcl;
     DiscretionaryAcl = discretionaryAcl;
     ResourceManagerControl = 0;
 }
Ejemplo n.º 45
0
        private void CreateFromParts(bool isContainer, bool isDS, ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, SystemAcl systemAcl, DiscretionaryAcl discretionaryAcl)
        {
            if (systemAcl != null &&
                systemAcl.IsContainer != isContainer)
            {
                throw new ArgumentException(
                          isContainer ?
                          SR.AccessControl_MustSpecifyContainerAcl :
                          SR.AccessControl_MustSpecifyLeafObjectAcl,
                          nameof(systemAcl));
            }

            if (discretionaryAcl != null &&
                discretionaryAcl.IsContainer != isContainer)
            {
                throw new ArgumentException(
                          isContainer ?
                          SR.AccessControl_MustSpecifyContainerAcl :
                          SR.AccessControl_MustSpecifyLeafObjectAcl,
                          nameof(discretionaryAcl));
            }

            _isContainer = isContainer;

            if (systemAcl != null &&
                systemAcl.IsDS != isDS)
            {
                throw new ArgumentException(
                          isDS ?
                          SR.AccessControl_MustSpecifyDirectoryObjectAcl :
                          SR.AccessControl_MustSpecifyNonDirectoryObjectAcl,
                          nameof(systemAcl));
            }

            if (discretionaryAcl != null &&
                discretionaryAcl.IsDS != isDS)
            {
                throw new ArgumentException(
                          isDS ?
                          SR.AccessControl_MustSpecifyDirectoryObjectAcl :
                          SR.AccessControl_MustSpecifyNonDirectoryObjectAcl,
                          nameof(discretionaryAcl));
            }

            _isDS = isDS;

            _sacl = systemAcl;

            //
            // Replace null DACL with an allow-all for everyone DACL
            //

            if (discretionaryAcl == null)
            {
                //
                // to conform to native behavior, we will add allow everyone ace for DACL
                //

                discretionaryAcl = DiscretionaryAcl.CreateAllowEveryoneFullAccess(_isDS, _isContainer);
            }

            _dacl = discretionaryAcl;

            //
            // DACL is never null. So always set the flag bit on
            //

            ControlFlags actualFlags = flags | ControlFlags.DiscretionaryAclPresent;

            //
            // Keep SACL and the flag bit in sync.
            //

            if (systemAcl == null)
            {
                unchecked { actualFlags &= ~(ControlFlags.SystemAclPresent); }
            }
            else
            {
                actualFlags |= (ControlFlags.SystemAclPresent);
            }

            _rawSd = new RawSecurityDescriptor(actualFlags, owner, group, systemAcl == null ? null : systemAcl.RawAcl, discretionaryAcl.RawAcl);
        }
Ejemplo n.º 46
0
        public void SetFlags(ControlFlags flags)
        {
            //
            // We can not deal with non-self-relative descriptors
            // so just forget about it
            //

            _flags = (flags | ControlFlags.SelfRelative);
        }
Ejemplo n.º 47
0
        //
        // Creates a security descriptor explicitly
        //

        public CommonSecurityDescriptor(bool isContainer, bool isDS, ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, SystemAcl systemAcl, DiscretionaryAcl discretionaryAcl)
        {
            CreateFromParts(isContainer, isDS, flags, owner, group, systemAcl, discretionaryAcl);
        }
Ejemplo n.º 48
0
 private CommonSecurityDescriptor(bool isContainer, bool isDS, ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
     : this(isContainer, isDS, flags, owner, group, systemAcl == null ? null : new SystemAcl(isContainer, isDS, systemAcl), discretionaryAcl == null ? null : new DiscretionaryAcl(isContainer, isDS, discretionaryAcl))
 {
 }
Ejemplo n.º 49
0
 private CommonSecurityDescriptor(bool isContainer, bool isDS, ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl)
     : this(isContainer, isDS, flags, owner, group, systemAcl == null ? null : new SystemAcl(isContainer, isDS, systemAcl), discretionaryAcl == null ? null : new DiscretionaryAcl(isContainer, isDS, discretionaryAcl))
 {
 }
Ejemplo n.º 50
0
 private void SetControlFlag(ControlFlags flag, bool value)
 {
     if (value) agentControls |= (uint)flag;
     else agentControls &= ~((uint)flag);
 }
Ejemplo n.º 51
0
	// Get a control flag.
	private bool GetControlFlag(ControlFlags mask)
			{
				return ((flags & mask) == mask);
			}
Ejemplo n.º 52
0
		internal static RawAcl ParseSddlForm(string sddlForm,
		                                     bool isDacl,
		                                     ref ControlFlags sdFlags,
		                                     ref int pos)
		{
			ParseFlags(sddlForm, isDacl, ref sdFlags, ref pos);
			
			byte revision = GenericAcl.AclRevision;
			List<GenericAce> aces = new List<GenericAce>();
			while(pos < sddlForm.Length && sddlForm[pos] == '(') {
				GenericAce ace = GenericAce.CreateFromSddlForm(
							sddlForm, ref pos);
				if ((ace as ObjectAce) != null)
					revision = GenericAcl.AclRevisionDS;
				aces.Add(ace);
			}
			
			
			return new RawAcl(revision, aces);
		}
Ejemplo n.º 53
0
	// Set a control flag.
	private void SetControlFlag(ControlFlags mask, bool value)
			{
				if(value)
				{
					flags |= mask;
				}
				else
				{
					flags &= ~mask;
				}
			}
 public void SetFlags(ControlFlags flags);
Ejemplo n.º 55
0
            public IEnumerator <TaskStatus> StackProc(MentalTask bwxTask, Atom x, Atom y)
            {
                Task       _bwxTask    = null;
                Context    _bwxContext = null;
                Message    _bwxMsg;
                Clause     _bwxClause  = null;
                Atom       _bwxSubject = null;
                TaskResult _bwxResult  = null;

                Begin(bwxTask);
                {
                    ControlFlags _bwxQflags = ControlFlags.None;
                    {
                        if (!bwxTask.Context.Exists(x, Ent_isClear, true))
                        {
                            _bwxQflags |= ControlFlags.PartialSuccess;
                            {
                                _bwxMsg = new Message(MessageKind.Attempt, null, null, new Clause(Ent_Perform, Ent_Self, Ent_clear, x));
                                Post(bwxTask.Process, _bwxMsg);
                            }
                        }
                        else
                        {
                            _bwxQflags |= ControlFlags.PartialFailure;
                        }
                    }
                    if (_bwxQflags == ControlFlags.PartialSuccess)
                    {
                        {
                            yield return(Fail(bwxTask.Process, bwxTask.Message));
                        }
                    }
                }
                {
                    ControlFlags _bwxQflags = ControlFlags.None;
                    {
                        if (!bwxTask.Context.Exists(y, Ent_isClear, true))
                        {
                            _bwxQflags |= ControlFlags.PartialSuccess;
                            {
                                _bwxMsg = new Message(MessageKind.Attempt, null, null, new Clause(Ent_Perform, Ent_Self, Ent_clear, y));
                                Post(bwxTask.Process, _bwxMsg);
                            }
                        }
                        else
                        {
                            _bwxQflags |= ControlFlags.PartialFailure;
                        }
                    }
                    if (_bwxQflags == ControlFlags.PartialSuccess)
                    {
                        {
                            yield return(Fail(bwxTask.Process, bwxTask.Message));
                        }
                    }
                }
                {
                    foreach (Atom z in bwxTask.Context.QuerySubjPred <Atom>(x, Ent_onTop))
                    {
                        {
                            _bwxMsg = new Message(MessageKind.Remove, null, null, new Clause(Ent_Belief, x, Ent_onTop, z));
                            Post(bwxTask.Process, _bwxMsg);
                        }
                    }
                }
                _bwxMsg = new Message(MessageKind.Add, null, null, new Clause(Ent_Belief, x, Ent_onTop, y));
                Post(bwxTask.Process, _bwxMsg);
                yield return(Succeed(bwxTask.Process, bwxTask.Message));
            }