Skip to content

Commit

Permalink
Fix for issue #78. Query for subscribers without throwing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranid committed May 19, 2024
1 parent 67f78a8 commit 280826a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion NtApiDotNet/NtWnf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static IEnumerable<NtWnf> GetRegisteredNotifications()
/// <summary>
/// Get if the state has subscribers.
/// </summary>
public bool SubscribersPresent => Query<int>(StateName, WnfStateNameInformation.SubscribersPresent, true).Result != 0;
public bool SubscribersPresent => GetSubscribersPresent(true).Result;

/// <summary>
/// Get the security descriptor for this object, if known.
Expand Down Expand Up @@ -439,6 +439,15 @@ public void DeleteStateData()
DeleteStateData(IntPtr.Zero);
}

/// <summary>
/// Get if the state has subscribers.
/// </summary>
/// <param name="throw_on_error">True to throw on error.</param>
/// <returns>The status of subscribers.</returns>
public NtResult<bool> GetSubscribersPresent(bool throw_on_error)
{
return Query<int>(StateName, WnfStateNameInformation.SubscribersPresent, throw_on_error).Map(i => i != 0);
}
#endregion

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion NtObjectManager/Cmdlets/Accessible/WnfAccessCheckResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal WnfAccessCheckResult(NtWnf wnf,
{
StateName = wnf.StateName;
Lifetime = wnf.Lifetime;
SubscribersPresent = wnf.SubscribersPresent;
SubscribersPresent = wnf.GetSubscribersPresent(false).GetResultOrDefault();
}
}
}

0 comments on commit 280826a

Please sign in to comment.