From 0c8f07854b88c594674644ecbe30cf94c66d4d54 Mon Sep 17 00:00:00 2001 From: Stanislav Motylkov Date: Fri, 7 May 2021 21:54:10 +0300 Subject: [PATCH] [NTOS:PS] Fix misplaced Thread variable reference caught by RTC Addendum to 2e88e2b9. --- ntoskrnl/ps/query.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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;