internal AttributeListAttribute(INtfsContext context, AttributeRecord record) : base(context, record) { byte[] content = Utilities.ReadAll(Content); _list = new AttributeList(); _list.ReadFrom(content, 0); }
internal StandardInformationAttribute(INtfsContext context, AttributeRecord record) : base(context, record) { byte[] content = Utilities.ReadAll(Content); _si = new StandardInformation(); _si.ReadFrom(content, 0); }
internal FileNameAttribute(INtfsContext context, AttributeRecord record) : base(context, record) { byte[] content = Utilities.ReadAll(Content); _fnr = new FileNameRecord(); _fnr.ReadFrom(content, 0); }
public void SetExtent(FileRecordReference containingFile, AttributeRecord record) { _containingFile = containingFile; _record = record; _extents.Clear(); _extents.Add(new AttributeReference(containingFile, record.AttributeId), record); }
protected NtfsAttribute(File file, FileRecordReference containingFile, AttributeRecord record) { _file = file; _containingFile = containingFile; _primaryRecord = record; _extents = new Dictionary<AttributeReference, AttributeRecord>(); _extents.Add(new AttributeReference(containingFile, record.AttributeId), _primaryRecord); }
TResult Keep <TResult>(TResult control, AttributeRecord record) where TResult : IControl { control.IsRooted.Subscribe(rooted => _attributes.OnNext(rooted ? _attributes.Value.Add(record) : _attributes.Value.Remove(record))); return(control); }
/// <summary> /// Gets the reporting configuration for an attribute /// /// <param name="attribute">the ZclAttribute on which to enable reporting</param> /// <returns>command Task CommandResult</returns> /// </summary> public Task <CommandResult> GetReporting(ZclAttribute attribute) { ReadReportingConfigurationCommand command = new ReadReportingConfigurationCommand(); command.ClusterId = _clusterId; AttributeRecord record = new AttributeRecord(); record.AttributeIdentifier = attribute.Id; record.Direction = 0; command.Records = new List <AttributeRecord>(new[] { record }); command.DestinationAddress = _zigbeeEndpoint.GetEndpointAddress(); return(Send(command)); }
internal static GenericAttribute FromAttributeRecord(INtfsContext context, AttributeRecord record) { switch (record.AttributeType) { case AttributeType.AttributeList: return(new AttributeListAttribute(context, record)); case AttributeType.FileName: return(new FileNameAttribute(context, record)); case AttributeType.StandardInformation: return(new StandardInformationAttribute(context, record)); default: return(new UnknownAttribute(context, record)); } }
public static void CreateVolumeWithPendingFileCreation(string path, long size, int bytesPerCluster, string volumeLabel, string fileName, byte[] fileData) { VirtualHardDisk disk = VirtualHardDisk.CreateFixedDisk(path, size); disk.ExclusiveLock(); Partition partition = NTFSFormatTests.CreatePrimaryPartition(disk); NTFSVolume volume = NTFSVolumeCreator.Format(partition, bytesPerCluster, volumeLabel); long segmentNumber = MasterFileTable.FirstUserSegmentNumber; FileNameRecord fileNameRecord = new FileNameRecord(MasterFileTable.RootDirSegmentReference, fileName, false, DateTime.Now); FileRecordSegment fileRecordSegment = CreateFileRecordSegment(segmentNumber, fileNameRecord, fileData); ulong dataStreamOffset = (ulong)(segmentNumber * volume.BytesPerFileRecordSegment); byte[] redoData = fileRecordSegment.GetBytes(volume.BytesPerFileRecordSegment, volume.MinorVersion, false); MftSegmentReference mftFileReference = new MftSegmentReference(0, 1); AttributeRecord mftDataRecord = volume.GetFileRecord(mftFileReference).GetAttributeRecord(AttributeType.Data, String.Empty); AttributeRecord mftBitmapRecord = volume.GetFileRecord(mftFileReference).GetAttributeRecord(AttributeType.Bitmap, String.Empty); uint transactionID = volume.LogClient.AllocateTransactionID(); volume.LogClient.WriteLogRecord(mftFileReference, mftDataRecord, dataStreamOffset, volume.BytesPerFileRecordSegment, NTFSLogOperation.InitializeFileRecordSegment, redoData, NTFSLogOperation.Noop, new byte[0], transactionID); long bitmapVCN = segmentNumber / (volume.BytesPerCluster * 8); int bitOffsetInCluster = (int)(segmentNumber % (volume.BytesPerCluster * 8)); BitmapRange bitmapRange = new BitmapRange((uint)bitOffsetInCluster, 1); ulong bitmapStreamOffset = (ulong)(bitmapVCN * volume.BytesPerCluster); volume.LogClient.WriteLogRecord(mftFileReference, mftBitmapRecord, bitmapStreamOffset, volume.BytesPerCluster, NTFSLogOperation.SetBitsInNonResidentBitMap, bitmapRange.GetBytes(), NTFSLogOperation.Noop, new byte[0], transactionID); FileRecord parentDirectoryRecord = volume.GetFileRecord(MasterFileTable.RootDirSegmentReference); IndexData parentDirectoryIndex = new IndexData(volume, parentDirectoryRecord, AttributeType.FileName); byte[] fileNameRecordBytes = fileNameRecord.GetBytes(); long leafRecordVBN = 0; IndexRecord leafRecord = parentDirectoryIndex.ReadIndexRecord(leafRecordVBN); ulong indexAllocationOffset = (ulong)parentDirectoryIndex.ConvertToDataOffset(leafRecordVBN); int insertIndex = CollationHelper.FindIndexForSortedInsert(leafRecord.IndexEntries, fileNameRecordBytes, CollationRule.Filename); int insertOffset = leafRecord.GetEntryOffset(volume.BytesPerIndexRecord, insertIndex); AttributeRecord rootDirIndexAllocation = volume.GetFileRecord(MasterFileTable.RootDirSegmentReference).GetAttributeRecord(AttributeType.IndexAllocation, IndexHelper.GetIndexName(AttributeType.FileName)); IndexEntry indexEntry = new IndexEntry(fileRecordSegment.SegmentReference, fileNameRecord.GetBytes()); volume.LogClient.WriteLogRecord(MasterFileTable.RootDirSegmentReference, rootDirIndexAllocation, indexAllocationOffset, volume.BytesPerIndexRecord, 0, insertOffset, NTFSLogOperation.AddIndexEntryToAllocationBuffer, indexEntry.GetBytes(), NTFSLogOperation.Noop, new byte[0], transactionID, false); volume.LogClient.WriteForgetTransactionRecord(transactionID, true); disk.ReleaseLock(); }
public bool ReplaceExtent(AttributeReference oldRef, AttributeReference newRef, AttributeRecord record) { if (!_extents.Remove(oldRef)) { return false; } else { if (oldRef.Equals(Reference) || _extents.Count == 0) { _record = record; _containingFile = newRef.File; } _extents.Add(newRef, record); return true; } }
private void ReadAttributes(byte[] stream, uint maxLength, int offset) { int offsetCpy = offset; while (true) { AttributeTypeCode attType = AttributeRecord.GetTypeCode(stream, offsetCpy); if (attType == AttributeTypeCode.EndOfAttributes) { break; } uint length = AttributeRecord.GetRecordLength(stream, offsetCpy); AttributeRecord attributeRecord = AttributeRecord.ReadSingleAttribute(stream, (int)length, offsetCpy); attributeRecord.RecordOwner = MftSegmentReference; attributes.Add(attributeRecord); offsetCpy += attributeRecord.RecordLength; } }
public UnknownAttribute(INtfsContext context, AttributeRecord record) : base(context, record) { }
internal GenericAttribute(INtfsContext context, AttributeRecord record) { _context = context; _record = record; }
public static NtfsAttribute FromRecord(File file, FileRecordReference recordFile, AttributeRecord record) { switch (record.AttributeType) { case AttributeType.StandardInformation: return new StructuredNtfsAttribute<StandardInformation>(file, recordFile, record); case AttributeType.FileName: return new StructuredNtfsAttribute<FileNameRecord>(file, recordFile, record); case AttributeType.SecurityDescriptor: return new StructuredNtfsAttribute<SecurityDescriptor>(file, recordFile, record); case AttributeType.Data: return new NtfsAttribute(file, recordFile, record); case AttributeType.Bitmap: return new NtfsAttribute(file, recordFile, record); case AttributeType.VolumeName: return new StructuredNtfsAttribute<VolumeName>(file, recordFile, record); case AttributeType.VolumeInformation: return new StructuredNtfsAttribute<VolumeInformation>(file, recordFile, record); case AttributeType.IndexRoot: return new NtfsAttribute(file, recordFile, record); case AttributeType.IndexAllocation: return new NtfsAttribute(file, recordFile, record); case AttributeType.ObjectId: return new StructuredNtfsAttribute<ObjectId>(file, recordFile, record); case AttributeType.ReparsePoint: return new StructuredNtfsAttribute<ReparsePointRecord>(file, recordFile, record); case AttributeType.AttributeList: return new StructuredNtfsAttribute<AttributeList>(file, recordFile, record); default: return new NtfsAttribute(file, recordFile, record); } }
internal static GenericAttribute FromAttributeRecord(INtfsContext context, AttributeRecord record) { switch (record.AttributeType) { case AttributeType.AttributeList: return new AttributeListAttribute(context, record); case AttributeType.FileName: return new FileNameAttribute(context, record); case AttributeType.StandardInformation: return new StandardInformationAttribute(context, record); default: return new UnknownAttribute(context, record); } }
/// <summary> /// Adds an existing attribute. /// </summary> /// <param name="attrRec">The attribute to add</param> /// <returns>The new Id of the attribute</returns> /// <remarks>This method is used to move an attribute between different MFT records</remarks> public ushort AddAttribute(AttributeRecord attrRec) { attrRec.AttributeId = _nextAttributeId++; _attributes.Add(attrRec); _attributes.Sort(); return attrRec.AttributeId; }
public void SetExtent(FileRecordReference containingFile, AttributeRecord record) { _cachedRawBuffer = null; _containingFile = containingFile; _primaryRecord = record; _extents.Clear(); _extents.Add(new AttributeReference(containingFile, record.AttributeId), record); }
public void AddExtent(FileRecordReference containingFile, AttributeRecord record) { _cachedRawBuffer = null; _extents.Add(new AttributeReference(containingFile, record.AttributeId), record); }
private void MoveAttribute(FileRecord record, AttributeRecord attrRec, FileRecord targetRecord) { AttributeReference oldRef = new AttributeReference(record.Reference, attrRec.AttributeId); record.RemoveAttribute(attrRec.AttributeId); targetRecord.AddAttribute(attrRec); AttributeReference newRef = new AttributeReference(targetRecord.Reference, attrRec.AttributeId); foreach (var attr in _attributes) { attr.ReplaceExtent(oldRef, newRef, attrRec); } UpdateAttributeList(); }