diff --git a/PInvoke/Security/AdvApi32/WinNT.cs b/PInvoke/Security/AdvApi32/WinNT.cs
index a3c46392..c530f540 100644
--- a/PInvoke/Security/AdvApi32/WinNT.cs
+++ b/PInvoke/Security/AdvApi32/WinNT.cs
@@ -3217,10 +3217,55 @@ namespace Vanara.PInvoke
/// The SID_IDENTIFIER_AUTHORITY structure represents the top-level authority of a security identifier (SID).
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[PInvokeData("Winnt.h", MSDNShortId = "aa379598")]
- public struct SID_IDENTIFIER_AUTHORITY
+ public struct SID_IDENTIFIER_AUTHORITY : IEquatable, IEquatable, IEquatable
{
/// An array of 6 bytes specifying a SID's top-level authority.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] Value;
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(SID_IDENTIFIER_AUTHORITY h1, SID_IDENTIFIER_AUTHORITY h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(SID_IDENTIFIER_AUTHORITY h1, SID_IDENTIFIER_AUTHORITY h2) => h1.Equals(h2);
+
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(PSID_IDENTIFIER_AUTHORITY other) => PSID_IDENTIFIER_AUTHORITY.Equals6Bytes(Value, other.Value);
+
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(SID_IDENTIFIER_AUTHORITY other) => PSID_IDENTIFIER_AUTHORITY.Equals6Bytes(Value, other.Value);
+
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(byte[] other) => PSID_IDENTIFIER_AUTHORITY.Equals6Bytes(Value, other);
+
+ ///
+ public override bool Equals(object obj) => obj switch
+ {
+ PSID_IDENTIFIER_AUTHORITY h => Equals(h),
+ SID_IDENTIFIER_AUTHORITY h => Equals(h),
+ byte[] h => Equals(h),
+ _ => ReferenceEquals(Value, obj),
+ };
+
+ ///
+ public override int GetHashCode() => Value.GetHashCode();
}
///
@@ -4453,7 +4498,7 @@ namespace Vanara.PInvoke
// _SID_IDENTIFIER_AUTHORITY { BYTE Value[6]; } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
[PInvokeData("winnt.h", MSDNShortId = "450a6d2d-d2e4-4098-90af-a8024ddcfcb5")]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
- public class PSID_IDENTIFIER_AUTHORITY
+ public class PSID_IDENTIFIER_AUTHORITY : IEquatable, IEquatable, IEquatable
{
/// An array of 6 bytes specifying a SID's top-level authority.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
@@ -4527,11 +4572,48 @@ namespace Vanara.PInvoke
/// The result of the operator.
public static bool operator ==(PSID_IDENTIFIER_AUTHORITY h1, PSID_IDENTIFIER_AUTHORITY h2) => h1.Equals(h2);
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(PSID_IDENTIFIER_AUTHORITY other) => Equals6Bytes(Value, other.Value);
+
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(SID_IDENTIFIER_AUTHORITY other) => Equals6Bytes(Value, other.Value);
+
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// An object to compare with this object.
+ ///
+ /// if the current object is equal to the parameter; otherwise, .
+ ///
+ public bool Equals(byte[] other) => Equals6Bytes(Value, other);
+
///
- public override bool Equals(object obj) => obj is PSID_IDENTIFIER_AUTHORITY h ? h.LongValue == h.LongValue : false;
+ public override bool Equals(object obj) => obj switch
+ {
+ PSID_IDENTIFIER_AUTHORITY h => Equals(h),
+ SID_IDENTIFIER_AUTHORITY h => Equals(h),
+ byte[] h => Equals(h),
+ _ => ReferenceEquals(Value, obj),
+ };
///
public override int GetHashCode() => LongValue.GetHashCode();
+
+ internal static bool Equals6Bytes(byte[] a, byte[] b)
+ {
+ if (a is null || b is null || a.Length != 6 || b.Length != 6)
+ return false;
+ for (int i = 0; i < 6; i++)
+ if (a[i] != b[i])
+ return false;
+ return true;
+ }
}
/// A SafeHandle for access control lists. If owned, will call LocalFree on the pointer when disposed.