From 280826ad554f33e5e799d9b860a68c2b7becbc06 Mon Sep 17 00:00:00 2001 From: James Forshaw Date: Sun, 19 May 2024 02:44:40 -0700 Subject: [PATCH] Fix for issue #78. Query for subscribers without throwing. --- NtApiDotNet/NtWnf.cs | 11 ++++++++++- .../Cmdlets/Accessible/WnfAccessCheckResult.cs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NtApiDotNet/NtWnf.cs b/NtApiDotNet/NtWnf.cs index 4db41f5b9..5a63d8cf3 100644 --- a/NtApiDotNet/NtWnf.cs +++ b/NtApiDotNet/NtWnf.cs @@ -307,7 +307,7 @@ public static IEnumerable GetRegisteredNotifications() /// /// Get if the state has subscribers. /// - public bool SubscribersPresent => Query(StateName, WnfStateNameInformation.SubscribersPresent, true).Result != 0; + public bool SubscribersPresent => GetSubscribersPresent(true).Result; /// /// Get the security descriptor for this object, if known. @@ -439,6 +439,15 @@ public void DeleteStateData() DeleteStateData(IntPtr.Zero); } + /// + /// Get if the state has subscribers. + /// + /// True to throw on error. + /// The status of subscribers. + public NtResult GetSubscribersPresent(bool throw_on_error) + { + return Query(StateName, WnfStateNameInformation.SubscribersPresent, throw_on_error).Map(i => i != 0); + } #endregion /// diff --git a/NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs b/NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs index 12d17541c..14fd873db 100644 --- a/NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs +++ b/NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs @@ -46,7 +46,7 @@ internal WnfAccessCheckResult(NtWnf wnf, { StateName = wnf.StateName; Lifetime = wnf.Lifetime; - SubscribersPresent = wnf.SubscribersPresent; + SubscribersPresent = wnf.GetSubscribersPresent(false).GetResultOrDefault(); } } }