diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c index b25e6928422..968b24623ef 100644 --- a/ntoskrnl/ps/query.c +++ b/ntoskrnl/ps/query.c @@ -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;