1- using System . Runtime . InteropServices ;
1+ using System ;
2+ using System . Runtime . InteropServices ;
23
34namespace ExampleApp . MiniTerm . Native ;
45
@@ -10,10 +11,21 @@ static class ProcessApi
1011 internal const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000 ;
1112
1213 [ StructLayout ( LayoutKind . Sequential , CharSet = CharSet . Unicode ) ]
13- internal struct STARTUPINFOEX
14+ internal struct STARTUPINFOEX : IEquatable < STARTUPINFOEX >
1415 {
1516 public STARTUPINFO StartupInfo ;
1617 public nint lpAttributeList ;
18+
19+ public readonly bool Equals ( STARTUPINFOEX other ) =>
20+ StartupInfo . Equals ( other . StartupInfo ) && lpAttributeList == other . lpAttributeList ;
21+
22+ public override readonly bool Equals ( object ? obj ) => obj is STARTUPINFOEX other && Equals ( other ) ;
23+
24+ public override readonly int GetHashCode ( ) => HashCode . Combine ( StartupInfo , lpAttributeList ) ;
25+
26+ public static bool operator == ( STARTUPINFOEX left , STARTUPINFOEX right ) => left . Equals ( right ) ;
27+
28+ public static bool operator != ( STARTUPINFOEX left , STARTUPINFOEX right ) => ! left . Equals ( right ) ;
1729 }
1830
1931 [ StructLayout ( LayoutKind . Sequential , CharSet = CharSet . Unicode ) ]
@@ -40,20 +52,44 @@ internal struct STARTUPINFO
4052 }
4153
4254 [ StructLayout ( LayoutKind . Sequential ) ]
43- internal struct PROCESS_INFORMATION
55+ internal struct PROCESS_INFORMATION : IEquatable < PROCESS_INFORMATION >
4456 {
4557 public nint hProcess ;
4658 public nint hThread ;
4759 public int dwProcessId ;
4860 public int dwThreadId ;
61+
62+ public readonly bool Equals ( PROCESS_INFORMATION other ) =>
63+ hProcess == other . hProcess && hThread == other . hThread &&
64+ dwProcessId == other . dwProcessId && dwThreadId == other . dwThreadId ;
65+
66+ public override readonly bool Equals ( object ? obj ) => obj is PROCESS_INFORMATION other && Equals ( other ) ;
67+
68+ public override readonly int GetHashCode ( ) => HashCode . Combine ( hProcess , hThread , dwProcessId , dwThreadId ) ;
69+
70+ public static bool operator == ( PROCESS_INFORMATION left , PROCESS_INFORMATION right ) => left . Equals ( right ) ;
71+
72+ public static bool operator != ( PROCESS_INFORMATION left , PROCESS_INFORMATION right ) => ! left . Equals ( right ) ;
4973 }
5074
5175 [ StructLayout ( LayoutKind . Sequential ) ]
52- internal struct SECURITY_ATTRIBUTES
76+ internal struct SECURITY_ATTRIBUTES : IEquatable < SECURITY_ATTRIBUTES >
5377 {
5478 public int nLength ;
5579 public nint lpSecurityDescriptor ;
5680 public int bInheritHandle ;
81+
82+ public readonly bool Equals ( SECURITY_ATTRIBUTES other ) =>
83+ nLength == other . nLength && lpSecurityDescriptor == other . lpSecurityDescriptor &&
84+ bInheritHandle == other . bInheritHandle ;
85+
86+ public override readonly bool Equals ( object ? obj ) => obj is SECURITY_ATTRIBUTES other && Equals ( other ) ;
87+
88+ public override readonly int GetHashCode ( ) => HashCode . Combine ( nLength , lpSecurityDescriptor , bInheritHandle ) ;
89+
90+ public static bool operator == ( SECURITY_ATTRIBUTES left , SECURITY_ATTRIBUTES right ) => left . Equals ( right ) ;
91+
92+ public static bool operator != ( SECURITY_ATTRIBUTES left , SECURITY_ATTRIBUTES right ) => ! left . Equals ( right ) ;
5793 }
5894
5995 [ DllImport ( "kernel32.dll" , SetLastError = true ) ]
0 commit comments