Skip to content

Commit 280826a

Browse files
committed
Fix for issue #78. Query for subscribers without throwing.
1 parent 67f78a8 commit 280826a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

NtApiDotNet/NtWnf.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public static IEnumerable<NtWnf> GetRegisteredNotifications()
307307
/// <summary>
308308
/// Get if the state has subscribers.
309309
/// </summary>
310-
public bool SubscribersPresent => Query<int>(StateName, WnfStateNameInformation.SubscribersPresent, true).Result != 0;
310+
public bool SubscribersPresent => GetSubscribersPresent(true).Result;
311311

312312
/// <summary>
313313
/// Get the security descriptor for this object, if known.
@@ -439,6 +439,15 @@ public void DeleteStateData()
439439
DeleteStateData(IntPtr.Zero);
440440
}
441441

442+
/// <summary>
443+
/// Get if the state has subscribers.
444+
/// </summary>
445+
/// <param name="throw_on_error">True to throw on error.</param>
446+
/// <returns>The status of subscribers.</returns>
447+
public NtResult<bool> GetSubscribersPresent(bool throw_on_error)
448+
{
449+
return Query<int>(StateName, WnfStateNameInformation.SubscribersPresent, throw_on_error).Map(i => i != 0);
450+
}
442451
#endregion
443452

444453
/// <summary>

NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal WnfAccessCheckResult(NtWnf wnf,
4646
{
4747
StateName = wnf.StateName;
4848
Lifetime = wnf.Lifetime;
49-
SubscribersPresent = wnf.SubscribersPresent;
49+
SubscribersPresent = wnf.GetSubscribersPresent(false).GetResultOrDefault();
5050
}
5151
}
5252
}

0 commit comments

Comments
 (0)