public ResidentAttributeRecord(AttributeType type, string name, ushort id, bool indexed, AttributeFlags flags)
     : base(type, name, id, flags)
 {
     _nonResidentFlag = 0;
     _indexedFlag = (byte)(indexed ? 1 : 0);
     _memoryBuffer = new SparseMemoryBuffer(1024);
 }
Ejemplo n.º 2
0
        public static AttributeFlags AttributeBreakdown(FileAttributes flags)
        {
            AttributeFlags attributes = new AttributeFlags();

            if (flags.HasFlag(FileAttributes.Normal))
                attributes.Normal = true;

            if (flags.HasFlag(FileAttributes.Archive))
                attributes.Archive = true;

            if (flags.HasFlag(FileAttributes.Compressed))
                attributes.Compressed = true;

            if (flags.HasFlag(FileAttributes.Device))
                attributes.Device = true;

            if (flags.HasFlag(FileAttributes.Directory))
                attributes.Directory = true;

            if (flags.HasFlag(FileAttributes.Encrypted))
                attributes.Encrypted = true;

            if (flags.HasFlag(FileAttributes.Hidden))
                attributes.Hidden = true;

            if (flags.HasFlag(FileAttributes.IntegrityStream))
                attributes.IntegrityStream = true;

            if (flags.HasFlag(FileAttributes.NoScrubData))
                attributes.NoScrubData = true;

            if (flags.HasFlag(FileAttributes.NotContentIndexed))
                attributes.NotContentIndexed = true;

            if (flags.HasFlag(FileAttributes.Offline))
                attributes.Offline = true;

            if (flags.HasFlag(FileAttributes.ReadOnly))
                attributes.ReadOnly = true;

            if (flags.HasFlag(FileAttributes.ReparsePoint))
                attributes.ReparsePoint = true;

            if (flags.HasFlag(FileAttributes.SparseFile))
                attributes.SparseFile = true;

            if (flags.HasFlag(FileAttributes.System))
                attributes.System = true;

            if (flags.HasFlag(FileAttributes.Temporary))
                attributes.Temporary = true;

            return attributes;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new attribute at a fixed cluster.
        /// </summary>
        /// <param name="type">The type of the new attribute.</param>
        /// <param name="name">The name of the new attribute.</param>
        /// <param name="flags">The flags of the new attribute.</param>
        /// <param name="firstCluster">The first cluster to assign to the attribute.</param>
        /// <param name="numClusters">The number of sequential clusters to assign to the attribute.</param>
        /// <param name="bytesPerCluster">The number of bytes in each cluster.</param>
        /// <returns>The new attribute.</returns>
        private NtfsAttribute CreateAttribute(AttributeType type, string name, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
        {
            bool   indexed = _context.AttributeDefinitions.IsIndexed(type);
            ushort id      = _records[0].CreateNonResidentAttribute(type, name, flags, firstCluster, numClusters, bytesPerCluster);

            AttributeRecord newAttrRecord = _records[0].GetAttribute(id);
            NtfsAttribute   newAttr       = NtfsAttribute.FromRecord(this, MftReference, newAttrRecord);

            _attributes.Add(newAttr);
            UpdateAttributeList();
            MarkMftRecordDirty();
            return(newAttr);
        }
Ejemplo n.º 4
0
        public LuaDocumentStatement(string triviaText)
        {
            var items = triviaText.Replace("///", string.Empty)
                        .Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(i => i.Trim()).ToList();

            int curIndex = 0;

            while (curIndex < items.Count)
            {
                int beginIndex = items.FindIndex(curIndex, i => i == Tokens.OpenSummary);
                if (beginIndex != -1)
                {
                    AddLineText(items, curIndex, beginIndex);
                    int endIndex = items.FindIndex(beginIndex + 1, it => it == Tokens.CloseSummary);
                    if (endIndex != -1)
                    {
                        LuaSummaryDocumentStatement summary = new LuaSummaryDocumentStatement();
                        bool hasAttr = false;
                        for (int i = beginIndex + 1; i < endIndex; ++i)
                        {
                            string text = items[i];
                            if (IsAttribute(text, out AttributeFlags arrt))
                            {
                                attr_  |= arrt;
                                hasAttr = true;
                            }
                            else
                            {
                                summary.Texts.Add(text);
                            }
                        }
                        if (summary.Texts.Count > 0 || !hasAttr)
                        {
                            Statements.Add(summary);
                        }
                        curIndex = endIndex + 1;
                    }
                    else
                    {
                        AddLineText(items, curIndex, items.Count);
                        curIndex = items.Count;
                    }
                }
                else
                {
                    AddLineText(items, curIndex, items.Count);
                    curIndex = items.Count;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute.</param>
        /// <param name="name">The name of the new attribute.</param>
        /// <param name="indexed">Whether the attribute is marked as indexed.</param>
        /// <param name="flags">Flags for the new attribute.</param>
        /// <returns>The id of the new attribute.</returns>
        public ushort CreateAttribute(AttributeType type, string name, bool indexed, AttributeFlags flags)
        {
            ushort id = NextAttributeId++;

            Attributes.Add(
                new ResidentAttributeRecord(
                    type,
                    name,
                    id,
                    indexed,
                    flags));
            Attributes.Sort();
            return(id);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new non-resident attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute</param>
        /// <param name="name">The name of the new attribute</param>
        /// <param name="flags">Flags for the new attribute</param>
        internal ushort CreateNonResidentAttribute(AttributeType type, string name, AttributeFlags flags)
        {
            ushort id = _nextAttributeId++;

            _attributes.Add(
                new NonResidentAttributeRecord(
                    type,
                    name,
                    id,
                    flags,
                    new List <CookedDataRun>())
                );
            _attributes.Sort();
            return(id);
        }
Ejemplo n.º 7
0
        private static NtResult <NtKey> OpenKey(string name, NtObject root, bool open_link, bool open_for_backup)
        {
            AttributeFlags flags = AttributeFlags.CaseInsensitive;

            if (open_link)
            {
                flags |= AttributeFlags.OpenLink;
            }

            using (ObjectAttributes obja = new ObjectAttributes(name,
                                                                flags, root))
            {
                return(NtKey.Open(obja, KeyAccessRights.MaximumAllowed, open_for_backup ? KeyCreateOptions.BackupRestore : KeyCreateOptions.NonVolatile, false));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new non-resident attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute.</param>
        /// <param name="name">The name of the new attribute.</param>
        /// <param name="flags">Flags for the new attribute.</param>
        /// <returns>The id of the new attribute.</returns>
        public ushort CreateNonResidentAttribute(AttributeType type, string name, AttributeFlags flags)
        {
            ushort id = NextAttributeId++;

            Attributes.Add(
                new NonResidentAttributeRecord(
                    type,
                    name,
                    id,
                    flags,
                    0,
                    new List <DataRun>()));
            Attributes.Sort();
            return(id);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute</param>
        /// <param name="name">The name of the new attribute</param>
        /// <param name="flags">The flags of the new attribute</param>
        /// <returns>The new attribute</returns>
        private NtfsAttribute CreateAttribute(AttributeType type, string name, AttributeFlags flags)
        {
            bool   indexed = _context.AttributeDefinitions.IsIndexed(type);
            ushort id      = _records[0].CreateAttribute(type, name, indexed, flags);

            AttributeRecord newAttrRecord = _records[0].GetAttribute(id);
            NtfsAttribute   newAttr       = NtfsAttribute.FromRecord(this, MftReference, newAttrRecord);

            _attributes.Add(newAttr);
            UpdateAttributeList();

            MarkMftRecordDirty();

            return(newAttr);
        }
Ejemplo n.º 10
0
        protected AttributeRecord(byte[] buffer, int offset)
        {
            m_attribueType       = (AttributeType)LittleEndianConverter.ToUInt32(buffer, offset + 0x00);
            m_recordLengthOnDisk = LittleEndianConverter.ToUInt32(buffer, offset + 0x04);
            m_attributeForm      = (AttributeForm)ByteReader.ReadByte(buffer, offset + 0x08);
            m_nameLength         = ByteReader.ReadByte(buffer, offset + 0x09);
            ushort nameOffset = LittleEndianConverter.ToUInt16(buffer, offset + 0x0A);

            Flags      = (AttributeFlags)LittleEndianConverter.ToUInt16(buffer, offset + 0x0C);
            m_instance = LittleEndianConverter.ToUInt16(buffer, offset + 0x0E);
            if (m_nameLength > 0)
            {
                m_name = ByteReader.ReadUTF16String(buffer, offset + nameOffset, m_nameLength);
            }
        }
Ejemplo n.º 11
0
            public static SafeFileHandle OpenFile(string name, FileAccessRights DesiredAccess, ShareMode ShareAccess, FileOpenOptions OpenOptions, bool inherit)
            {
                AttributeFlags flags = AttributeFlags.CaseInsensitive;

                if (inherit)
                {
                    flags |= AttributeFlags.Inherit;
                }
                using (ObjectAttributes obja = new ObjectAttributes(name, flags))
                {
                    IntPtr        handle;
                    IoStatusBlock iostatus = new IoStatusBlock();
                    StatusToNtException(NtOpenFile(out handle, DesiredAccess, obja, iostatus, ShareAccess, OpenOptions));
                    return(new SafeFileHandle(handle, true));
                }
            }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a new attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute</param>
        /// <param name="name">The name of the new attribute</param>
        /// <param name="flags">Flags for the new attribute</param>
        /// <param name="firstCluster">The first cluster to assign to the attribute</param>
        /// <param name="numClusters">The number of sequential clusters to assign to the attribute</param>
        /// <param name="bytesPerCluster">The number of bytes in each cluster</param>
        /// <returns>The id of the new attribute</returns>
        public ushort CreateNonResidentAttribute(AttributeType type, string name, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
        {
            ushort id = _nextAttributeId++;

            _attributes.Add(
                new NonResidentAttributeRecord(
                    type,
                    name,
                    id,
                    flags,
                    firstCluster,
                    numClusters,
                    bytesPerCluster));
            _attributes.Sort();
            return(id);
        }
        public NonResidentAttributeRecord(AttributeType type, string name, ushort id, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
            : base(type, name, id, flags)
        {
            _nonResidentFlag = 1;
            _dataRuns = new List<DataRun>();
            _dataRuns.Add(new DataRun(firstCluster, (long)numClusters, false));
            _lastVCN = numClusters - 1;
            _dataAllocatedSize = bytesPerCluster * numClusters;
            _dataRealSize = bytesPerCluster * numClusters;
            _initializedDataSize = bytesPerCluster * numClusters;

            if ((flags & (AttributeFlags.Compressed | AttributeFlags.Sparse)) != 0)
            {
                _compressionUnitSize = DefaultCompressionUnitSize;
            }
        }
        /// <summary>
        /// Determines whether the specified Object is equal to the current Object.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }


            var other = (VLQuestionColumn)obj;

            //reference types
            if (!Object.Equals(ColumnText, other.ColumnText))
            {
                return(false);
            }
            //value types
            if (!Survey.Equals(other.Survey))
            {
                return(false);
            }
            if (!Question.Equals(other.Question))
            {
                return(false);
            }
            if (!ColumnId.Equals(other.ColumnId))
            {
                return(false);
            }
            if (!DisplayOrder.Equals(other.DisplayOrder))
            {
                return(false);
            }
            if (!AttributeFlags.Equals(other.AttributeFlags))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
        /// </summary>
        /// <param name="tag">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
        /// <param name="textHeight">Height of the attribute definition text.</param>
        /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
        public AttributeDefinition(string tag, double textHeight, TextStyle style)
            : base(DxfObjectCode.AttributeDefinition)
        {
            if (string.IsNullOrEmpty(tag))
            {
                throw new ArgumentNullException(nameof(tag));
            }

            if (tag.Contains(" "))
            {
                throw new ArgumentException("The tag string cannot contain spaces.", nameof(tag));
            }
            this.tag      = tag;
            this.flags    = AttributeFlags.Visible;
            this.prompt   = string.Empty;
            this.attValue = null;
            this.position = Vector3.Zero;
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }
            this.style = style;
            if (textHeight <= 0.0)
            {
                throw new ArgumentOutOfRangeException(nameof(textHeight), this.attValue, "The attribute definition text height must be greater than zero.");
            }
            this.height        = textHeight;
            this.width         = 1.0;
            this.widthFactor   = style.WidthFactor;
            this.obliqueAngle  = style.ObliqueAngle;
            this.rotation      = 0.0;
            this.alignment     = TextAlignment.BaselineLeft;
            this.isBackward    = false;
            this.isUpsideDown  = false;
            this.color         = AciColor.ByLayer;
            this.layer         = Layer.Default;
            this.linetype      = Linetype.ByLayer;
            this.lineweight    = Lineweight.ByLayer;
            this.transparency  = Transparency.ByLayer;
            this.linetypeScale = 1.0;
            this.isVisible     = true;
            this.normal        = Vector3.UnitZ;

            this.xData               = new XDataDictionary();
            this.xData.AddAppReg    += this.XData_AddAppReg;
            this.xData.RemoveAppReg += this.XData_RemoveAppReg;
        }
Ejemplo n.º 16
0
        private ObjectAttributes GetObjectAttributes()
        {
            AttributeFlags flags = AttributeFlags.CaseInsensitive;

            if (OpenLink)
            {
                flags |= AttributeFlags.OpenLink;
            }
            if (Win32Path)
            {
                return(new ObjectAttributes(NtKeyUtils.Win32KeyNameToNt(Path), flags));
            }
            else
            {
                return(new ObjectAttributes(Path, flags, Root));
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Intitializes a new instance of the <c>AttributeDefiniton</c> class.
 /// </summary>
 /// <param name="id">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
 /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
 public AttributeDefinition(string id, TextStyle style)
     : base(EntityType.AttributeDefinition, DxfObjectCode.AttributeDefinition)
 {
     if (id.Contains(" "))
     {
         throw new ArgumentException("The id string cannot contain spaces", "id");
     }
     this.id          = id;
     this.flags       = AttributeFlags.Visible;
     this.text        = string.Empty;
     this.value       = null;
     this.position    = Vector3.Zero;
     this.style       = style;
     this.height      = MathHelper.IsZero(this.style.Height) ? 1.0 : style.Height;
     this.widthFactor = style.WidthFactor;
     this.rotation    = 0.0;
     this.alignment   = TextAlignment.BaselineLeft;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Intitializes a new instance of the <c>Attribute</c> class.
 /// </summary>
 /// <param name="definition"><see cref="AttributeDefinition">Attribute definition</see>.</param>
 /// <param name="value">Attribute value.</param>
 public Attribute(AttributeDefinition definition, object value)
     : base(EntityType.Attribute, DxfObjectCode.Attribute)
 {
     if (definition == null)
     {
         throw new ArgumentNullException("definition");
     }
     this.definition  = definition;
     this.id          = definition.Id;
     this.value       = value;
     this.style       = definition.Style;
     this.position    = definition.Position;
     this.flags       = definition.Flags;
     this.height      = definition.Height;
     this.widthFactor = definition.WidthFactor;
     this.rotation    = definition.Rotation;
     this.alignment   = definition.Alignment;
 }
        /// <summary>
        /// Try and open the directory entry and return an actual NtObject handle.
        /// </summary>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The object opened.</returns>
        /// <exception cref="System.ArgumentException">Thrown if invalid typename.</exception>
        public virtual NtResult <NtObject> ToObject(bool throw_on_error)
        {
            AttributeFlags flags = AttributeFlags.CaseInsensitive;

            if (TypeName.Equals("key", StringComparison.OrdinalIgnoreCase))
            {
                flags |= AttributeFlags.OpenLink;
            }

            if (_root.FullPath == @"\" && RelativePath.StartsWith(@"??\"))
            {
                return(NtObject.OpenWithType(TypeName, @"\" + RelativePath, null,
                                             flags, GenericAccessRights.MaximumAllowed, null, throw_on_error));
            }

            return(NtObject.OpenWithType(TypeName, RelativePath, _root,
                                         flags, GenericAccessRights.MaximumAllowed, null, throw_on_error));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// If the read-only property is not asserted, check the write-enabled status of the watch variable and set/clear the <c>WriteEnabled</c> property accordingly.
        /// The current state is determined by the specified <paramref name="attributeFlags"/> and <paramref name="securityLevel"/> parameters. True, indicates that the
        /// watch variable is currently write enabled; false, indicates that the watch variable is currently read-only.
        /// </summary>
        /// <param name="attributeFlags">The attribute flags associated with the watch variable.</param>
        /// <param name="securityLevel">The current security level.</param>
        private void CheckWriteEnabledStatus(AttributeFlags attributeFlags, SecurityLevel securityLevel)
        {
            // Local flag used to determine if the watch variable is currently write enabled.
            bool writeEnabled;

            // Check whether the ReadOnly property is asserted.
            if (ReadOnly == true)
            {
                // Yes - Force the user control to be read-only.
                writeEnabled = false;
            }
            else
            {
                // Check whether the read-only attribute is set.
                if ((attributeFlags & AttributeFlags.PTUD_READONLY) == AttributeFlags.PTUD_READONLY)
                {
                    // Read-only watch variable.
                    writeEnabled = false;
                }
                else
                {
                    // Check whether the current security level is below that required to modify the watch variable.
                    if (((attributeFlags & AttributeFlags.PTUD_PSSWD1) == AttributeFlags.PTUD_PSSWD1) && (securityLevel < SecurityLevel.Level1))
                    {
                        // Read-only - security level is too low.
                        writeEnabled = false;
                    }
                    else if (((attributeFlags & AttributeFlags.PTUD_PSSWD2) == AttributeFlags.PTUD_PSSWD2) && (securityLevel < SecurityLevel.Level2))
                    {
                        // Read-only - security level is too low.
                        writeEnabled = false;
                    }
                    else
                    {
                        // Write enabled - display value using bold text.
                        m_LabelValueField.Font = new Font(ClientForm.Font, FontStyle.Bold);
                        writeEnabled           = true;
                    }
                }
            }

            SetWriteEnabledProperty(writeEnabled);
        }
Ejemplo n.º 21
0
        private static bool IsAttribute(string text, out AttributeFlags attr)
        {
            attr = AttributeFlags.None;
            int index = text.IndexOf(kAttributePrefix);

            if (index != -1)
            {
                string s = text.Substring(index + kAttributePrefix.Length);
                if (Enum.TryParse(s, out attr))
                {
                    return(true);
                }
                else
                {
                    throw new CompilationErrorException($"{s} is not define attribute");
                }
            }
            return(false);
        }
Ejemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        private string CreateQuery(AttributeFlags flags)
        {
            string query = string.Empty;

            query += $"?network={flags.HasFlag(AttributeFlags.NETWORK).ToString().ToLower()}";
            query += $"&endpoint={flags.HasFlag(AttributeFlags.ENDPOINT).ToString().ToLower()}";
            query += $"&clusterEndpoint={flags.HasFlag(AttributeFlags.CLUSTERENDPOINT).ToString().ToLower()}";
            query += $"&definition={flags.HasFlag(AttributeFlags.DEFINITION).ToString().ToLower()}";
            query += $"&config={flags.HasFlag(AttributeFlags.CONFIG).ToString().ToLower()}";
            query += $"&room={flags.HasFlag(AttributeFlags.ROOM).ToString().ToLower()}";
            query += $"&icons={flags.HasFlag(AttributeFlags.ICONS).ToString().ToLower()}";
            query += $"&value={flags.HasFlag(AttributeFlags.VALUE).ToString().ToLower()}";
            query += $"&parent={flags.HasFlag(AttributeFlags.PARENT).ToString().ToLower()}";
            query += $"&children={flags.HasFlag(AttributeFlags.CHILDREN).ToString().ToLower()}";
            query += $"&full={flags.HasFlag(AttributeFlags.FULL).ToString().ToLower()}";
            query += $"&type={flags.HasFlag(AttributeFlags.TYPE).ToString().ToLower()}";

            return(query);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
 /// </summary>
 /// <param name="tag">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
 /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
 public AttributeDefinition(string tag, TextStyle style)
     : base(EntityType.AttributeDefinition, DxfObjectCode.AttributeDefinition)
 {
     if (tag.Contains(" "))
     {
         throw new ArgumentException("The tag string cannot contain spaces.", nameof(tag));
     }
     this.tag          = tag;
     this.flags        = AttributeFlags.Visible;
     this.prompt       = string.Empty;
     this.value        = null;
     this.position     = Vector3.Zero;
     this.style        = style;
     this.height       = MathHelper.IsZero(this.style.Height) ? 1.0 : style.Height;
     this.widthFactor  = style.WidthFactor;
     this.obliqueAngle = style.ObliqueAngle;
     this.rotation     = 0.0;
     this.alignment    = TextAlignment.BaselineLeft;
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
        /// </summary>
        /// <param name="tag">Attribute identifier.</param>
        /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
        public AttributeDefinition(string tag, TextStyle style)
            : base(EntityType.AttributeDefinition, DxfObjectCode.AttributeDefinition)
        {
            if (string.IsNullOrEmpty(tag))
                throw new ArgumentNullException(nameof(tag));

            this.tag = tag;
            this.flags = AttributeFlags.Visible;
            this.prompt = string.Empty;
            this.value = null;
            this.position = Vector3.Zero;
            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.style = style;
            this.height = MathHelper.IsZero(style.Height) ? 1.0 : style.Height;
            this.widthFactor = style.WidthFactor;
            this.obliqueAngle = style.ObliqueAngle;
            this.rotation = 0.0;
            this.alignment = TextAlignment.BaselineLeft;
        }
Ejemplo n.º 25
0
        protected AttributeRecord(byte[] buffer, int offset)
        {
            m_attribueType       = (AttributeType)LittleEndianConverter.ToUInt32(buffer, offset + 0x00);
            m_recordLengthOnDisk = LittleEndianConverter.ToUInt32(buffer, offset + 0x04);
            m_attributeForm      = (AttributeForm)ByteReader.ReadByte(buffer, offset + 0x08);
            m_nameLength         = ByteReader.ReadByte(buffer, offset + 0x09);
            ushort nameOffset = LittleEndianConverter.ToUInt16(buffer, offset + 0x0A);

            Flags    = (AttributeFlags)LittleEndianConverter.ToUInt16(buffer, offset + 0x0C);
            Instance = LittleEndianConverter.ToUInt16(buffer, offset + 0x0E);
            if (m_nameLength > 0)
            {
                m_name = ByteReader.ReadUTF16String(buffer, offset + nameOffset, m_nameLength);
            }

            if (m_recordLengthOnDisk % 8 > 0)
            {
                throw new InvalidDataException("Corrupt attribute, record not aligned to 8-byte boundary");
            }
        }
Ejemplo n.º 26
0
        protected virtual void Read(byte[] buffer, int offset, out int length)
        {
            _type  = (AttributeType)Utilities.ToUInt32LittleEndian(buffer, offset + 0x00);
            length = Utilities.ToInt32LittleEndian(buffer, offset + 0x04);

            _nonResidentFlag = buffer[offset + 0x08];
            byte   nameLength = buffer[offset + 0x09];
            ushort nameOffset = Utilities.ToUInt16LittleEndian(buffer, offset + 0x0A);

            _flags       = (AttributeFlags)Utilities.ToUInt16LittleEndian(buffer, offset + 0x0C);
            _attributeId = Utilities.ToUInt16LittleEndian(buffer, offset + 0x0E);

            if (nameLength != 0x00)
            {
                if (nameLength + nameOffset > length)
                {
                    throw new IOException("Corrupt attribute, name outside of attribute");
                }

                _name = Encoding.Unicode.GetString(buffer, offset + nameOffset, nameLength * 2);
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Intitializes a new instance of the <c>AttributeDefiniton</c> class.
 /// </summary>
 /// <param name="id">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
 public AttributeDefinition(string id)
     : base(DxfObjectCode.AttributeDefinition)
 {
     if (id.Contains(" "))
     {
         throw new ArgumentException("The id string cannot contain spaces", "id");
     }
     this.id          = id;
     this.flags       = AttributeFlags.Visible;
     this.text        = string.Empty;
     this.value       = null;
     this.basePoint   = Vector3.Zero;
     this.layer       = Layer.Default;
     this.color       = AciColor.ByLayer;
     this.lineType    = LineType.ByLayer;
     this.style       = TextStyle.Default;
     this.alignment   = TextAlignment.BaselineLeft;
     this.height      = MathHelper.IsZero(this.style.Height) ? 1.0f : this.style.Height;
     this.widthFactor = this.style.WidthFactor;
     this.rotation    = 0.0f;
     this.normal      = Vector3.UnitZ;
 }
        public NonResidentAttributeRecord(AttributeType type, string name, ushort id, AttributeFlags flags, long startVcn, List<DataRun> dataRuns)
            : base(type, name, id, flags)
        {
            _nonResidentFlag = 1;
            _dataRuns = dataRuns;
            _startingVCN = (ulong)startVcn;

            if ((flags & (AttributeFlags.Compressed | AttributeFlags.Sparse)) != 0)
            {
                _compressionUnitSize = DefaultCompressionUnitSize;
            }

            if (dataRuns != null && dataRuns.Count != 0)
            {
                _lastVCN = _startingVCN;
                foreach (var run in dataRuns)
                {
                    _lastVCN += (ulong)run.RunLength;
                }

                _lastVCN -= 1;
            }
        }
Ejemplo n.º 29
0
        private ObjectAttributes(SafeBuffer object_name, AttributeFlags attributes, SafeKernelObjectHandle root,
                                 SecurityQualityOfService sqos, SecurityDescriptor security_descriptor)
        {
            try
            {
                if (root == null)
                {
                    throw new ArgumentNullException(nameof(root), "Use SafeKernelObjectHandle.Null for a null handle");
                }
                Length     = Marshal.SizeOf(this);
                ObjectName = object_name;
                Attributes = attributes;
                if (sqos != null)
                {
                    SecurityQualityOfService = sqos.ToBuffer();
                }
                else
                {
                    SecurityQualityOfService = SafeHGlobalBuffer.Null;
                }

                RootDirectory = !root.IsInvalid ? NtObject.DuplicateHandle(root) : SafeKernelObjectHandle.Null;
                if (security_descriptor != null)
                {
                    SecurityDescriptor = security_descriptor.ToSafeBuffer();
                }
                else
                {
                    SecurityDescriptor = SafeHGlobalBuffer.Null;
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
        /// </summary>
        /// <param name="tag">Attribute identifier.</param>
        /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
        public AttributeDefinition(string tag, TextStyle style)
            : base(EntityType.AttributeDefinition, DxfObjectCode.AttributeDefinition)
        {
            if (string.IsNullOrEmpty(tag))
            {
                throw new ArgumentNullException(nameof(tag));
            }

            this.tag      = tag;
            this.flags    = AttributeFlags.Visible;
            this.prompt   = string.Empty;
            this.attValue = null;
            this.position = Vector3.Zero;
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }
            this.style        = style;
            this.height       = MathHelper.IsZero(style.Height) ? 1.0 : style.Height;
            this.widthFactor  = style.WidthFactor;
            this.obliqueAngle = style.ObliqueAngle;
            this.rotation     = 0.0;
            this.alignment    = TextAlignment.BaselineLeft;
        }
Ejemplo n.º 31
0
 public ObjectAttributes(string object_name, AttributeFlags attributes, SafeKernelObjectHandle root, SecurityQualityOfService sqos, GenericSecurityDescriptor security_descriptor)
 {
     Length = Marshal.SizeOf(this);
     if (object_name != null)
     {
         ObjectName = AllocStruct(new UnicodeString(object_name));
     }
     Attributes = attributes;
     if (sqos != null)
     {
         SecurityQualityOfService = AllocStruct(sqos);
     }
     if (root != null)
     {
         RootDirectory = root.DangerousGetHandle();
     }
     if (security_descriptor != null)
     {
         byte[] sd_binary = new byte[security_descriptor.BinaryLength];
         security_descriptor.GetBinaryForm(sd_binary, 0);
         SecurityDescriptor = Marshal.AllocHGlobal(sd_binary.Length);
         Marshal.Copy(sd_binary, 0, SecurityDescriptor, sd_binary.Length);
     }
 }
Ejemplo n.º 32
0
        public LuaDocumentStatement(string triviaText)
        {
            var items = triviaText.Replace("///", string.Empty)
                        .Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(i => i.Trim()).ToList();

            var document = new LuaSummaryDocumentStatement();

            foreach (var item in items)
            {
                if (IsAttribute(item, out AttributeFlags arrt))
                {
                    attr_ |= arrt;
                }
                else
                {
                    document.Texts.Add(item);
                }
            }
            if (document.Texts.Count > 0)
            {
                Statements.Add(document);
            }
        }
        /// <summary>
        /// Open an NT object with a specified type.
        /// </summary>
        /// <param name="typename">The name of the type to open (e.g. Event). If null the method will try and lookup the appropriate type.</param>
        /// <param name="path">The path to the object to open.</param>
        /// <param name="root">A root directory to open from.</param>
        /// <param name="access">Generic access rights to the object.</param>
        /// <param name="attributes">Attributes to open the object.</param>
        /// <param name="security_quality_of_service">Security quality of service.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The opened object.</returns>
        /// <exception cref="NtException">Thrown if an error occurred opening the object.</exception>
        public static NtResult <NtObject> OpenWithType(string typename, string path, NtObject root,
                                                       AttributeFlags attributes, AccessMask access, SecurityQualityOfService security_quality_of_service, bool throw_on_error)
        {
            using (var obj_attr = new ObjectAttributes(path, attributes, root, security_quality_of_service, null))
            {
                if (typename == null)
                {
                    typename = NtDirectory.GetDirectoryEntryType(path, root);
                }

                // Brute force the open.
                if (typename == null)
                {
                    foreach (var nttype in NtType.GetTypes().Where(t => t.CanOpen))
                    {
                        var result = nttype.Open(obj_attr, access, false);
                        if (result.IsSuccess)
                        {
                            return(result);
                        }
                    }

                    return(NtStatus.STATUS_OBJECT_TYPE_MISMATCH.CreateResultFromError <NtObject>(true));
                }

                NtType type = NtType.GetTypeByName(typename, false);
                if (type != null && type.CanOpen)
                {
                    return(type.Open(obj_attr, access, throw_on_error));
                }
                else
                {
                    return(NtStatus.STATUS_OBJECT_TYPE_MISMATCH.CreateResultFromError <NtObject>(true));
                }
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes a new instance of the <c>Attribute</c> class.
        /// </summary>
        /// <param name="definition"><see cref="AttributeDefinition">Attribute definition</see>.</param>
        /// <remarks>
        /// Although the attribute entity could override values defined in its definition for simplicity the implementation has restricted this possibility.
        /// </remarks>
        public Attribute(AttributeDefinition definition)
            : base(DxfObjectCode.Attribute)
        {
            if (definition == null)
                throw new ArgumentNullException("definition");

            //EntityObject properties
            this.color = definition.Color;
            this.layer = definition.Layer;
            this.lineType = definition.LineType;
            this.lineweight = definition.Lineweight;
            this.lineTypeScale = definition.LineTypeScale;
            this.transparency = definition.Transparency;
            this.isVisible = definition.IsVisible;
            this.normal = definition.Normal;

            //Attribute definition properties
            this.definition = definition;
            this.tag = definition.Tag;
            this.value = definition.Value;
            this.style = definition.Style;
            this.position = definition.Position;
            this.flags = definition.Flags;
            this.height = definition.Height;
            this.widthFactor = definition.WidthFactor;
            this.obliqueAngle = definition.ObliqueAngle;
            this.rotation = definition.Rotation;
            this.alignment = definition.Alignment;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="object_name">The name of the object</param>
 /// <param name="attributes">Attribute flags</param>
 public ObjectAttributes(string object_name, AttributeFlags attributes) 
     : this(object_name, attributes, SafeKernelObjectHandle.Null, null, null)
 {
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Creates a new attribute.
 /// </summary>
 /// <param name="type">The type of the new attribute</param>
 /// <param name="name">The name of the new attribute</param>
 /// <param name="flags">Flags for the new attribute</param>
 /// <param name="firstCluster">The first cluster to assign to the attribute</param>
 /// <param name="numClusters">The number of sequential clusters to assign to the attribute</param>
 /// <param name="bytesPerCluster">The number of bytes in each cluster</param>
 /// <returns>The id of the new attribute</returns>
 public ushort CreateNonResidentAttribute(AttributeType type, string name, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
 {
     ushort id = _nextAttributeId++;
     _attributes.Add(
         new NonResidentAttributeRecord(
             type,
             name,
             id,
             flags,
             firstCluster,
             numClusters,
             bytesPerCluster));
     _attributes.Sort();
     return id;
 }
Ejemplo n.º 37
0
 public static extern NtStatus NtOpenProcessTokenEx(
     SafeKernelObjectHandle ProcessHandle,
     TokenAccessRights DesiredAccess,
     AttributeFlags HandleAttributes,
     out SafeKernelObjectHandle TokenHandle);
Ejemplo n.º 38
0
 // Name: clearFlag
 // Description: Unsets the bit designated by an AttributesFlag flag
 // Parameters: AttributesFlags flag , the flag to unset
 public void clearFlag(AttributeFlags flag)
 {
     // NOTing the flag, then ANDing it into the bitfield will always
     // unset the bit:
     //    0000010  <-- Flag
     //    1111101  <-- NOT Flag
     //
     //    0100101
     //  & 1111101  <-- NOT Flag
     //    -------
     //    0100101  <-- Bit unset
     // or, alternatively;
     //    0100111
     //  & 1111101  <-- NOT Flag
     //    -------
     //    0100101  <-- Bit unset
     attributes &= ~flag;
 }
Ejemplo n.º 39
0
 public static extern int NtOpenProcessTokenEx(
     IntPtr ProcessHandle,
     GenericAccessRights DesiredAccess,
     AttributeFlags HandleAttributes,
     out IntPtr TokenHandle);
Ejemplo n.º 40
0
 // Bitfield attribute accessors and mutators
 // Name: setFlag
 // Description: Sets the bit in the bitfield with the given flag
 // Parameters: AttributeFlags flag , the flag being set
 public void setFlag(AttributeFlags flag)
 {
     // ORing the flag into the bitfield will always set the flag:
     //    0100101
     //  | 0000010  <-- Flag
     //    -------
     //    0100111  <-- Bit is set
     // or, alternatively;
     //    0100111
     //  | 0000010  <-- Flag
     //    -------
     //    0100111  <-- Bit is set
     attributes |= flag;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="object_name">The object name, can be null.</param>
        /// <param name="attributes">The object attribute flags.</param>
        /// <param name="root">An optional root handle, can be SafeKernelObjectHandle.Null. Will duplicate the handle.</param>
        /// <param name="sqos">An optional security quality of service.</param>
        /// <param name="security_descriptor">An optional security descriptor.</param>
        public ObjectAttributes(string object_name, AttributeFlags attributes, SafeKernelObjectHandle root, 
            SecurityQualityOfService sqos, SecurityDescriptor security_descriptor)
        {
            Length = Marshal.SizeOf(this);
            if (object_name != null)
            {
                ObjectName = new UnicodeString(object_name).ToBuffer();
            }
            else
            {
                ObjectName = SafeHGlobalBuffer.Null;
            }

            Attributes = attributes;
            if (sqos != null)
            {
                SecurityQualityOfService = sqos.ToBuffer();
            }
            else
            {
                SecurityQualityOfService = SafeHGlobalBuffer.Null; 
            }

            RootDirectory = !root.IsInvalid ? NtObject.DuplicateHandle(root) : SafeKernelObjectHandle.Null;
            if (security_descriptor != null)
            {
                SecurityDescriptor = security_descriptor.ToSafeBuffer();
            }
            else
            {
                SecurityDescriptor = SafeHGlobalBuffer.Null;
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="attributes">Attribute flags</param>
 public ObjectAttributes(AttributeFlags attributes) 
     : this(null, attributes, SafeKernelObjectHandle.Null, null, null)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="object_name">The object name, can be null.</param>
 /// <param name="attributes">The object attribute flags.</param>
 /// <param name="root">An optional root handle, can be SafeKernelObjectHandle.Null. Will duplicate the handle.</param>
 /// <param name="sqos">An optional security quality of service.</param>
 /// <param name="security_descriptor">An optional security descriptor.</param>
 public ObjectAttributes(string object_name, AttributeFlags attributes, NtObject root, 
     SecurityQualityOfService sqos, SecurityDescriptor security_descriptor) 
     : this(object_name, attributes, root != null ? root.Handle : SafeKernelObjectHandle.Null, sqos, security_descriptor)
 {
 }
Ejemplo n.º 44
0
        /// <summary>
        /// If the read-only property is not asserted, check the write-enabled status of the watch variable and set/clear the <c>WriteEnabled</c> property accordingly. 
        /// The current state is determined by the specified <paramref name="attributeFlags"/> and <paramref name="securityLevel"/> parameters. True, indicates that the 
        /// watch variable is currently write enabled; false, indicates that the watch variable is currently read-only.
        /// </summary>
        /// <param name="attributeFlags">The attribute flags associated with the watch variable.</param>
        /// <param name="securityLevel">The current security level.</param>
        private void CheckWriteEnabledStatus(AttributeFlags attributeFlags, SecurityLevel securityLevel)
        {
            // Local flag used to determine if the watch variable is currently write enabled.
            bool writeEnabled;

            // Check whether the ReadOnly property is asserted.
            if (ReadOnly == true)
            {
                // Yes - Force the user control to be read-only.
                writeEnabled = false;
            }
            else
            {
                // Check whether the read-only attribute is set.
                if ((attributeFlags & AttributeFlags.PTUD_READONLY) == AttributeFlags.PTUD_READONLY)
                {
                    // Read-only watch variable.
                    writeEnabled = false;
                }
                else
                {
                    // Check whether the current security level is below that required to modify the watch variable.
                    if (((attributeFlags & AttributeFlags.PTUD_PSSWD1) == AttributeFlags.PTUD_PSSWD1) && (securityLevel < SecurityLevel.Level1))
                    {
                        // Read-only - security level is too low.
                        writeEnabled = false;
                    }
                    else if (((attributeFlags & AttributeFlags.PTUD_PSSWD2) == AttributeFlags.PTUD_PSSWD2) && (securityLevel < SecurityLevel.Level2))
                    {
                        // Read-only - security level is too low.
                        writeEnabled = false;
                    }
                    else
                    {
                        // Write enabled - display value using bold text.
                        m_LabelValueField.Font = new Font(ClientForm.Font, FontStyle.Bold);
                        writeEnabled = true;
                    }
                }
            }

            SetWriteEnabledProperty(writeEnabled);
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Creates a new attribute.
 /// </summary>
 /// <param name="type">The type of the new attribute</param>
 /// <param name="name">The name of the new attribute</param>
 /// <param name="indexed">Whether the attribute is marked as indexed</param>
 /// <param name="flags">Flags for the new attribute</param>
 /// <returns>The id of the new attribute</returns>
 public ushort CreateAttribute(AttributeType type, string name, bool indexed, AttributeFlags flags)
 {
     ushort id = _nextAttributeId++;
     _attributes.Add(
         new ResidentAttributeRecord(
             type,
             name,
             id,
             indexed,
             flags));
     _attributes.Sort();
     return id;
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Intitializes a new instance of the <c>AttributeDefiniton</c> class.
 /// </summary>
 /// <param name="id">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
 public AttributeDefinition(string id)
     : base(DxfObjectCode.AttributeDefinition)
 {
     if (id.Contains(" "))
         throw new ArgumentException("The id string cannot contain spaces", "id");
     this.id = id;
     this.flags = AttributeFlags.Visible;
     this.text = string.Empty;
     this.value = null;
     this.basePoint = Vector3f.Zero;
     this.layer = Layer.Default;
     this.color = AciColor.ByLayer;
     this.lineType = LineType.ByLayer;
     this.style = TextStyle.Default;
     this.alignment = TextAlignment.BaselineLeft;
     this.height = this.style.Height == 0 ? 1.0f : this.style.Height;
     this.widthFactor = this.style.WidthFactor;
     this.rotation = 0.0f;
     this.normal = Vector3f.UnitZ;
 }
Ejemplo n.º 47
0
 public ObjectAttributes(string object_name)
 {
     Length = Marshal.SizeOf(this);
     if (object_name != null)
     {
       ObjectName = AllocStruct(new UnicodeString(object_name));
     }
     Attributes = AttributeFlags.None;
 }
Ejemplo n.º 48
0
        public static FileAttributes AttributesFromBools(AttributeFlags attributes)
        {
            FileAttributes flags = new FileAttributes();

            if (attributes.Normal)
                flags |= FileAttributes.Normal;

            if (attributes.Archive)
                flags |= FileAttributes.Archive;

            if (attributes.Compressed)
                flags |= FileAttributes.Compressed;

            if (attributes.Device)
                flags |= FileAttributes.Device;

            if (attributes.Directory)
                flags |= FileAttributes.Directory;

            if (attributes.Encrypted)
                flags |= FileAttributes.Encrypted;

            if (attributes.Hidden)
                flags |= FileAttributes.Hidden;

            if (attributes.IntegrityStream)
                flags |= FileAttributes.IntegrityStream;

            if (attributes.NoScrubData)
                flags |= FileAttributes.NoScrubData;

            if (attributes.NotContentIndexed)
                flags |= FileAttributes.NotContentIndexed;

            if (attributes.Offline)
                flags |= FileAttributes.Offline;

            if (attributes.ReadOnly)
                flags |= FileAttributes.ReadOnly;

            if (attributes.ReparsePoint)
                flags |= FileAttributes.ReparsePoint;

            if (attributes.SparseFile)
                flags |= FileAttributes.SparseFile;

            if (attributes.System)
                flags |= FileAttributes.System;

            if (attributes.Temporary)
                flags |= FileAttributes.Temporary;

            return flags;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="object_name">The name of the object</param>
 /// <param name="attributes">Attribute flags</param>
 /// <param name="root">A root object to lookup a relative path</param>
 public ObjectAttributes(string object_name, AttributeFlags attributes, NtObject root) 
     : this(object_name, attributes, root, null, null)
 {
 }
Ejemplo n.º 50
0
 // Name: isFlagSet
 // Description: Checks to see if the given flag is set in attributes
 // Parameters: AttributeFlags flag , the flag being checked
 // Returns: bool , whether the flag is set
 public bool isFlagSet(AttributeFlags flag)
 {
     // If the bit for the given flag is set, ANDing the flag into the
     // bitfield should yield the flag, otherwise the AND will not yield
     // the flag:
     //    0100101
     //  & 0000010  <-- Flag
     //    -------
     //    0000000 != 0000010 <-- Bit was not set
     // Or, alternatively;
     //    0100111
     //  & 0000010  <-- Flag
     //    -------
     //    0000010 == 0000010 <-- Bit was set
     return (attributes & flag) == flag;
 }
Ejemplo n.º 51
0
        /// <summary>
        /// Creates a new attribute at a fixed cluster.
        /// </summary>
        /// <param name="type">The type of the new attribute.</param>
        /// <param name="name">The name of the new attribute.</param>
        /// <param name="flags">The flags of the new attribute.</param>
        /// <param name="firstCluster">The first cluster to assign to the attribute.</param>
        /// <param name="numClusters">The number of sequential clusters to assign to the attribute.</param>
        /// <param name="bytesPerCluster">The number of bytes in each cluster.</param>
        /// <returns>The new attribute.</returns>
        private NtfsAttribute CreateAttribute(AttributeType type, string name, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
        {
            bool indexed = _context.AttributeDefinitions.IsIndexed(type);
            ushort id = _records[0].CreateNonResidentAttribute(type, name, flags, firstCluster, numClusters, bytesPerCluster);

            AttributeRecord newAttrRecord = _records[0].GetAttribute(id);
            NtfsAttribute newAttr = NtfsAttribute.FromRecord(this, MftReference, newAttrRecord);

            _attributes.Add(newAttr);
            UpdateAttributeList();
            MarkMftRecordDirty();
            return newAttr;
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
        /// </summary>
        /// <param name="tag">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
        /// <param name="textHeight">Height of the attribute definition text.</param>
        /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
        public AttributeDefinition(string tag, double textHeight, TextStyle style)
            : base(EntityType.AttributeDefinition, DxfObjectCode.AttributeDefinition)
        {
            if (string.IsNullOrEmpty(tag))
                throw new ArgumentNullException(nameof(tag));

            if (tag.Contains(" "))
                throw new ArgumentException("The tag string cannot contain spaces.", nameof(tag));
            this.tag = tag;
            this.flags = AttributeFlags.Visible;
            this.prompt = string.Empty;
            this.value = null;
            this.position = Vector3.Zero;
            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.style = style;
            if (textHeight <= 0.0)
                throw new ArgumentOutOfRangeException(nameof(textHeight), this.value, "The attribute definition text height must be greater than zero.");
            this.height = textHeight;
            this.widthFactor = style.WidthFactor;
            this.obliqueAngle = style.ObliqueAngle;
            this.rotation = 0.0;
            this.alignment = TextAlignment.BaselineLeft;
        }
Ejemplo n.º 53
0
 /// <summary>
 /// Creates a new unnamed attribute.
 /// </summary>
 /// <param name="type">The type of the new attribute.</param>
 /// <param name="flags">The flags of the new attribute.</param>
 /// <returns>The new attribute.</returns>
 private NtfsAttribute CreateAttribute(AttributeType type, AttributeFlags flags)
 {
     return CreateAttribute(type, null, flags);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Duplicate object.
 /// </summary>
 /// <param name="access_rights">Access rights to duplicate with.</param>
 /// <param name="flags">Attribute flags.</param>
 /// <param name="options">Duplicate options</param>
 /// <returns>The duplicated object.</returns>
 public NtObject DuplicateObject(AccessMask access_rights, AttributeFlags flags, DuplicateObjectOptions options)
 {
     return(DuplicateObject(access_rights, flags, options, true).Result);
 }
Ejemplo n.º 55
0
        /// <summary>
        /// Creates a new attribute.
        /// </summary>
        /// <param name="type">The type of the new attribute.</param>
        /// <param name="name">The name of the new attribute.</param>
        /// <param name="flags">The flags of the new attribute.</param>
        /// <returns>The new attribute.</returns>
        private NtfsAttribute CreateAttribute(AttributeType type, string name, AttributeFlags flags)
        {
            bool indexed = _context.AttributeDefinitions.IsIndexed(type);
            ushort id = _records[0].CreateAttribute(type, name, indexed, flags);

            AttributeRecord newAttrRecord = _records[0].GetAttribute(id);
            NtfsAttribute newAttr = NtfsAttribute.FromRecord(this, MftReference, newAttrRecord);

            _attributes.Add(newAttr);
            UpdateAttributeList();

            MarkMftRecordDirty();

            return newAttr;
        }
Ejemplo n.º 56
0
 public ObjectAttributes(string object_name, AttributeFlags flags, IntPtr root)
 {
     Length = Marshal.SizeOf(this);
     if (object_name != null)
     {
       ObjectName = AllocStruct(new UnicodeString(object_name));
     }
     Attributes = flags;
     RootDirectory = root;
 }
Ejemplo n.º 57
0
 /// <summary>
 /// Creates a new non-resident attribute.
 /// </summary>
 /// <param name="type">The type of the new attribute</param>
 /// <param name="name">The name of the new attribute</param>
 /// <param name="flags">Flags for the new attribute</param>
 /// <returns>The id of the new attribute</returns>
 public ushort CreateNonResidentAttribute(AttributeType type, string name, AttributeFlags flags)
 {
     ushort id = _nextAttributeId++;
     _attributes.Add(
         new NonResidentAttributeRecord(
             type,
             name,
             id,
             flags,
             0,
             new List<DataRun>()));
     _attributes.Sort();
     return id;
 }