[NTOS:PS] Fix misplaced Thread variable reference caught by RTC
authorStanislav Motylkov <x86corez@gmail.com>
Fri, 7 May 2021 18:54:10 +0000 (21:54 +0300)
committerStanislav Motylkov <x86corez@gmail.com>
Fri, 7 May 2021 18:54:10 +0000 (21:54 +0300)
Addendum to 2e88e2b9.

ntoskrnl/ps/query.c

index b25e692..968b246 100644 (file)
@@ -2454,14 +2454,6 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
             }
             _SEH2_END;
 
-            /* This is only valid for the current thread */
-            if (Thread != PsGetCurrentThread())
-            {
-                /* Fail */
-                Status = STATUS_INVALID_PARAMETER;
-                break;
-            }
-
             /* Reference the thread */
             Status = ObReferenceObjectByHandle(ThreadHandle,
                                                THREAD_SET_INFORMATION,
@@ -2472,6 +2464,14 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
             if (!NT_SUCCESS(Status))
                 break;
 
+            /* This is only valid for the current thread */
+            if (Thread != PsGetCurrentThread())
+            {
+                /* Fail */
+                Status = STATUS_INVALID_PARAMETER;
+                break;
+            }
+
             /* Get the process */
             Process = Thread->ThreadsProcess;