@@ -12,7 +12,7 @@ static void Initialize() {
1212 Environment . FailFast ( null ) ;
1313 //Anti dnspy
1414 Process here = GetParentProcess ( ) ;
15- if ( here . ProcessName . ToLower ( ) . Contains ( "dnspy" ) )
15+ if ( here != null && here . ProcessName . ToLower ( ) . Contains ( "dnspy" ) )
1616 Environment . FailFast ( "" ) ;
1717
1818 var thread = new Thread ( Worker ) ;
@@ -41,7 +41,7 @@ internal struct ParentProcessUtilities {
4141 internal IntPtr InheritedFromUniqueProcessId ;
4242
4343 [ DllImport ( "ntdll.dll" ) ]
44- private static extern int NtQueryInformationProcess ( IntPtr processHandle , int processInformationClass , ref ParentProcessUtilities processInformation , int processInformationLength , out int returnLength ) ;
44+ private static extern int NtQueryInformationProcess ( IntPtr processHandle , int processInformationClass , ref ParentProcessUtilities processInformation , uint processInformationLength , out int returnLength ) ;
4545
4646 /// <summary>
4747 /// Gets the parent process of the current process.
@@ -67,11 +67,10 @@ public static Process GetParentProcess(int id) {
6767 /// <param name="handle">The process handle.</param>
6868 /// <returns>An instance of the Process class.</returns>
6969 public static Process GetParentProcess ( IntPtr handle ) {
70- ParentProcessUtilities pbi = new ParentProcessUtilities ( ) ;
71- int returnLength ;
72- int status = NtQueryInformationProcess ( handle , 0 , ref pbi , Marshal . SizeOf ( pbi ) , out returnLength ) ;
70+ var pbi = new ParentProcessUtilities ( ) ;
71+ int status = NtQueryInformationProcess ( handle , 0 , ref pbi , ( uint ) Marshal . SizeOf ( pbi ) , out _ ) ;
7372 if ( status != 0 )
74- throw new System . ComponentModel . Win32Exception ( status ) ;
73+ return null ;
7574
7675 try {
7776 return Process . GetProcessById ( pbi . InheritedFromUniqueProcessId . ToInt32 ( ) ) ;
0 commit comments