Skip to content

Commit

Permalink
Improved corruption resilient behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
LTRData committed May 24, 2024
1 parent d2afda5 commit a238a20
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
18 changes: 15 additions & 3 deletions Library/DiscUtils.Ntfs/NtfsFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,21 @@ public NtfsFileSystem(Stream stream)
if (VolumeInfo.Version >= VolumeInformation.VersionW2k)
{
_context.SecurityDescriptors = new SecurityDescriptors(GetFile(MasterFileTable.SecureIndex));
_context.ObjectIds = new ObjectIds(GetFile(GetDirectoryEntry(@"$Extend\$ObjId").Value.Reference));
_context.ReparsePoints = new ReparsePoints(GetFile(GetDirectoryEntry(@"$Extend\$Reparse").Value.Reference));
_context.Quotas = new Quotas(GetFile(GetDirectoryEntry(@"$Extend\$Quota").Value.Reference));

if (GetDirectoryEntry(@"$Extend\$ObjId") is { } objIdFile)
{
_context.ObjectIds = new ObjectIds(GetFile(objIdFile.Reference));
}

if (GetDirectoryEntry(@"$Extend\$Reparse") is { } reparse)
{
_context.ReparsePoints = new ReparsePoints(GetFile(reparse.Reference));
}

if (GetDirectoryEntry(@"$Extend\$Quota") is { } quota)
{
_context.Quotas = new Quotas(GetFile(quota.Reference));
}
}

#if false
Expand Down
16 changes: 12 additions & 4 deletions Library/DiscUtils.Ntfs/StructuredNtfsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Buffers;
using System.IO;
using DiscUtils.Streams;
using LTRData.Extensions.Formatting;

namespace DiscUtils.Ntfs;

Expand Down Expand Up @@ -96,11 +97,18 @@ public override string ToString()

public override void Dump(TextWriter writer, string indent)
{
Initialize();
writer.WriteLine($"{indent}{AttributeTypeName} ATTRIBUTE ({(Name == null ? "No Name" : Name)})");
_structure.Dump(writer, $"{indent} ");
try
{
Initialize();
writer.WriteLine($"{indent}{AttributeTypeName} ATTRIBUTE ({Name ?? "No Name"})");
_structure.Dump(writer, $"{indent} ");

_primaryRecord.Dump(writer, $"{indent} ");
_primaryRecord.Dump(writer, $"{indent} ");
}
catch (Exception ex)
{
writer.WriteLine($"{indent}{AttributeTypeName} ATTRIBUTE: {ex.JoinMessages()}");
}
}

private void Initialize()
Expand Down

0 comments on commit a238a20

Please sign in to comment.