Ejemplo n.º 1
0
        internal NonResident(NonResidentHeader header, byte[] bytes, string attrName)
        {
            // Attr Object
            Name        = (ATTR_TYPE)header.commonHeader.ATTRType;
            NameString  = attrName;
            NonResident = header.commonHeader.NonResident;
            AttributeId = header.commonHeader.Id;

            // NonResident Attribute
            commonHeader    = header.commonHeader;
            StartVCN        = header.StartVCN;
            LastVCN         = header.LastVCN;
            DataRunOffset   = header.DataRunOffset;
            CompUnitSize    = header.CompUnitSize;
            AllocatedSize   = header.AllocatedSize;
            RealSize        = header.RealSize;
            InitializedSize = header.InitializedSize;

            int DataRunLengthByteCount = bytes[0] & 0x0F;
            int DataRunOffsetByteCount = ((bytes[0] & 0xF0) >> 4);

            if (DataRunLengthByteCount != 0)
            {
                // DataRun
                int  offset       = 0;
                long startCluster = 0;

                List <DataRun> dataRunList = new List <DataRun>();
                do
                {
                    if ((offset + DataRunLengthByteCount + DataRunOffsetByteCount + 1) > bytes.Length)
                    {
                        break;
                    }

                    // Instantiate a DataRun object
                    DataRun dataRun = new DataRun(NativeMethods.GetSubArray(bytes, (uint)(offset + 1), (uint)DataRunLengthByteCount + (uint)DataRunOffsetByteCount), DataRunLengthByteCount, DataRunOffsetByteCount, ref startCluster);

                    // Add DataRun Object to dataRunList
                    dataRunList.Add(dataRun);

                    // Increment offset
                    offset = offset + 1 + DataRunLengthByteCount + DataRunOffsetByteCount;

                    if (offset <= (bytes.Length - 1))
                    {
                        DataRunLengthByteCount = bytes[offset] & 0x0F;
                        DataRunOffsetByteCount = ((bytes[offset] & 0xF0) >> 4);
                    }
                    else
                    {
                        break;
                    }
                } while (((offset + DataRunLengthByteCount + DataRunOffsetByteCount + 1) < bytes.Length) && (DataRunOffsetByteCount <= 3) && (DataRunLengthByteCount != 0));

                DataRun = dataRunList.ToArray();
            }
        }
Ejemplo n.º 2
0
        internal ulong StartVCN; // Starting VCN

        #endregion Fields

        #region Constructors

        internal NonResident(NonResidentHeader header, byte[] bytes, string attrName)
        {
            // Attr Object
            Name = (ATTR_TYPE)header.commonHeader.ATTRType;
            NameString = attrName;
            NonResident = header.commonHeader.NonResident;
            AttributeId = header.commonHeader.Id;

            // NonResident Attribute
            commonHeader = header.commonHeader;
            StartVCN = header.StartVCN;
            LastVCN = header.LastVCN;
            DataRunOffset = header.DataRunOffset;
            CompUnitSize = header.CompUnitSize;
            AllocatedSize = header.AllocatedSize;
            RealSize = header.RealSize;
            InitializedSize = header.InitializedSize;

            int DataRunLengthByteCount = bytes[0] & 0x0F;
            int DataRunOffsetByteCount = ((bytes[0] & 0xF0) >> 4);

            if (DataRunLengthByteCount != 0)
            {
                // DataRun
                int offset = 0;
                long startCluster = 0;

                List<DataRun> dataRunList = new List<DataRun>();
                do
                {
                    if ((offset + DataRunLengthByteCount + DataRunOffsetByteCount + 1) > bytes.Length)
                    {
                        break;
                    }

                    // Instantiate a DataRun object
                    DataRun dataRun = new DataRun(NativeMethods.GetSubArray(bytes, (uint)(offset + 1), (uint)DataRunLengthByteCount + (uint)DataRunOffsetByteCount), DataRunLengthByteCount, DataRunOffsetByteCount, ref startCluster);

                    // Add DataRun Object to dataRunList
                    dataRunList.Add(dataRun);

                    // Increment offset
                    offset = offset + 1 + DataRunLengthByteCount + DataRunOffsetByteCount;

                    if (offset <= (bytes.Length - 1))
                    {
                        DataRunLengthByteCount = bytes[offset] & 0x0F;
                        DataRunOffsetByteCount = ((bytes[offset] & 0xF0) >> 4);
                    }
                    else
                    {
                        break;
                    }

                } while (((offset + DataRunLengthByteCount + DataRunOffsetByteCount + 1) < bytes.Length) && (DataRunOffsetByteCount <= 3) && (DataRunLengthByteCount != 0));

                DataRun = dataRunList.ToArray();
            }
        }