MarshalInt() private static method

private static MarshalInt ( byte binaryForm, int offset, int number ) : void
binaryForm byte
offset int
number int
return void
Beispiel #1
0
        /// <summary>Returns an array of byte values that represents the information contained in this <see cref="T:System.Security.AccessControl.GenericSecurityDescriptor" /> object.</summary>
        /// <param name="binaryForm">The byte array into which the contents of the <see cref="T:System.Security.AccessControl.GenericSecurityDescriptor" /> is marshaled.</param>
        /// <param name="offset">The offset at which to start marshaling.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///         <paramref name="offset" /> is negative or too high to allow the entire <see cref="T:System.Security.AccessControl.GenericSecurityDescriptor" /> to be copied into <paramref name="array" />.</exception>
        // Token: 0x0600205D RID: 8285 RVA: 0x00071708 File Offset: 0x0006F908
        public void GetBinaryForm(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 < this.BinaryLength)
            {
                throw new ArgumentOutOfRangeException("binaryForm", Environment.GetResourceString("ArgumentOutOfRange_ArrayTooSmall"));
            }
            int  num          = offset;
            int  binaryLength = this.BinaryLength;
            byte b            = (this is RawSecurityDescriptor && (this.ControlFlags & ControlFlags.RMControlValid) != ControlFlags.None) ? (this as RawSecurityDescriptor).ResourceManagerControl : 0;
            int  num2         = (int)this.ControlFlags;

            if (this.IsCraftedAefaDacl)
            {
                num2 &= -5;
            }
            binaryForm[offset]     = GenericSecurityDescriptor.Revision;
            binaryForm[offset + 1] = b;
            binaryForm[offset + 2] = (byte)num2;
            binaryForm[offset + 3] = (byte)(num2 >> 8);
            int offset2 = offset + 4;
            int offset3 = offset + 8;
            int offset4 = offset + 12;
            int offset5 = offset + 16;

            offset += 20;
            if (this.Owner != null)
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset2, offset - num);
                this.Owner.GetBinaryForm(binaryForm, offset);
                offset += this.Owner.BinaryLength;
            }
            else
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset2, 0);
            }
            if (this.Group != null)
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset3, offset - num);
                this.Group.GetBinaryForm(binaryForm, offset);
                offset += this.Group.BinaryLength;
            }
            else
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset3, 0);
            }
            if ((this.ControlFlags & ControlFlags.SystemAclPresent) != ControlFlags.None && this.GenericSacl != null)
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset4, offset - num);
                this.GenericSacl.GetBinaryForm(binaryForm, offset);
                offset += this.GenericSacl.BinaryLength;
            }
            else
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset4, 0);
            }
            if ((this.ControlFlags & ControlFlags.DiscretionaryAclPresent) != ControlFlags.None && this.GenericDacl != null && !this.IsCraftedAefaDacl)
            {
                GenericSecurityDescriptor.MarshalInt(binaryForm, offset5, offset - num);
                this.GenericDacl.GetBinaryForm(binaryForm, offset);
                offset += this.GenericDacl.BinaryLength;
                return;
            }
            GenericSecurityDescriptor.MarshalInt(binaryForm, offset5, 0);
        }