Skip to content

Commit 270ad77

Browse files
committed
Added full path to change notifications.
1 parent a4f6aad commit 270ad77

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

NtApiDotNet/NtFile.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private NtResult<FileBasicInformation> QueryBasicInformation(bool throw_on_error
358358
return Query(FileInformationClass.FileBasicInformation, new FileBasicInformation(), throw_on_error);
359359
}
360360

361-
private static IEnumerable<DirectoryChangeNotification> ReadNotifications(SafeHGlobalBuffer buffer, IoStatus status)
361+
private IEnumerable<DirectoryChangeNotification> ReadNotifications(SafeHGlobalBuffer buffer, IoStatus status)
362362
{
363363
List<DirectoryChangeNotification> ns = new List<DirectoryChangeNotification>();
364364

@@ -370,7 +370,7 @@ private static IEnumerable<DirectoryChangeNotification> ReadNotifications(SafeHG
370370
{
371371
var info = buffer.GetStructAtOffset<FileNotifyInformation>(offset);
372372
var result = info.Result;
373-
ns.Add(new DirectoryChangeNotification(info));
373+
ns.Add(new DirectoryChangeNotification(FullPath, info));
374374
if (result.NextEntryOffset == 0)
375375
{
376376
break;
@@ -380,7 +380,7 @@ private static IEnumerable<DirectoryChangeNotification> ReadNotifications(SafeHG
380380
return ns.AsReadOnly();
381381
}
382382

383-
private static IEnumerable<DirectoryChangeNotificationExtended> ReadExtendedNotifications(SafeHGlobalBuffer buffer, IoStatus status)
383+
private IEnumerable<DirectoryChangeNotificationExtended> ReadExtendedNotifications(SafeHGlobalBuffer buffer, IoStatus status)
384384
{
385385
List<DirectoryChangeNotificationExtended> ns = new List<DirectoryChangeNotificationExtended>();
386386

@@ -392,7 +392,7 @@ private static IEnumerable<DirectoryChangeNotificationExtended> ReadExtendedNoti
392392
{
393393
var info = buffer.GetStructAtOffset<FileNotifyExtendedInformation>(offset);
394394
var result = info.Result;
395-
ns.Add(new DirectoryChangeNotificationExtended(info));
395+
ns.Add(new DirectoryChangeNotificationExtended(FullPath, info));
396396
if (result.NextEntryOffset == 0)
397397
{
398398
break;

NtApiDotNet/NtFileNative.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,19 +1496,22 @@ public sealed class DirectoryChangeNotification
14961496
{
14971497
public FileNotificationAction Action { get; }
14981498
public string FileName { get; }
1499+
public string FullPath { get; }
14991500

1500-
internal DirectoryChangeNotification(SafeStructureInOutBuffer<FileNotifyInformation> buffer)
1501+
internal DirectoryChangeNotification(string base_path, SafeStructureInOutBuffer<FileNotifyInformation> buffer)
15011502
{
15021503
var info = buffer.Result;
15031504
Action = info.Action;
15041505
FileName = buffer.Data.ReadUnicodeString(info.FileNameLength / 2);
1506+
FullPath = Path.Combine(base_path, FileName);
15051507
}
15061508
}
15071509

15081510
public sealed class DirectoryChangeNotificationExtended
15091511
{
15101512
public FileNotificationAction Action { get; }
15111513
public string FileName { get; }
1514+
public string FullPath { get; }
15121515
public DateTime CreationTime { get; }
15131516
public DateTime LastModificationTime { get; }
15141517
public DateTime LastChangeTime { get; }
@@ -1520,7 +1523,7 @@ public sealed class DirectoryChangeNotificationExtended
15201523
public long FileId { get; }
15211524
public long ParentFileId { get; }
15221525

1523-
internal DirectoryChangeNotificationExtended(SafeStructureInOutBuffer<FileNotifyExtendedInformation> buffer)
1526+
internal DirectoryChangeNotificationExtended(string base_path, SafeStructureInOutBuffer<FileNotifyExtendedInformation> buffer)
15241527
{
15251528
var info = buffer.Result;
15261529
Action = info.Action;
@@ -1535,6 +1538,7 @@ internal DirectoryChangeNotificationExtended(SafeStructureInOutBuffer<FileNotify
15351538
FileId = info.FileId.QuadPart;
15361539
ParentFileId = info.ParentFileId.QuadPart;
15371540
FileName = buffer.Data.ReadUnicodeString(info.FileNameLength / 2);
1541+
FullPath = Path.Combine(base_path, FileName);
15381542
}
15391543
}
15401544

0 commit comments

Comments
 (0)