From 5c9eeb7616b5ad6a1839fc65fd25ecce8abbe41b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 16 Feb 2014 08:56:34 +0000 Subject: [PATCH 1/1] [NTOSKRNL] - Fix logic in PsReferenceEffectiveToken svn path=/trunk/; revision=62206 --- reactos/ntoskrnl/ps/security.c | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/reactos/ntoskrnl/ps/security.c b/reactos/ntoskrnl/ps/security.c index 7532cbe0703..5c8e7176071 100644 --- a/reactos/ntoskrnl/ps/security.c +++ b/reactos/ntoskrnl/ps/security.c @@ -698,25 +698,7 @@ PsReferenceEffectiveToken(IN PETHREAD Thread, /* Check if we don't have impersonation info */ Process = Thread->ThreadsProcess; - if (!Thread->ActiveImpersonationInfo) - { - /* Fast Reference the Token */ - Token = ObFastReferenceObject(&Process->Token); - - /* Check if we got the Token or if we got locked */ - if (!Token) - { - /* Lock the Process */ - PspLockProcessSecurityShared(Process); - - /* Do a Locked Fast Reference */ - Token = ObFastReferenceObjectLocked(&Process->Token); - - /* Unlock the Process */ - PspUnlockProcessSecurityShared(Process); - } - } - else + if (Thread->ActiveImpersonationInfo) { /* Lock the Process */ PspLockProcessSecurityShared(Process); @@ -742,6 +724,22 @@ PsReferenceEffectiveToken(IN PETHREAD Thread, PspUnlockProcessSecurityShared(Process); } + /* Fast Reference the Token */ + Token = ObFastReferenceObject(&Process->Token); + + /* Check if we got the Token or if we got locked */ + if (!Token) + { + /* Lock the Process */ + PspLockProcessSecurityShared(Process); + + /* Do a Locked Fast Reference */ + Token = ObFastReferenceObjectLocked(&Process->Token); + + /* Unlock the Process */ + PspUnlockProcessSecurityShared(Process); + } + /* Return the token */ *TokenType = TokenPrimary; *EffectiveOnly = FALSE; -- 2.17.1