From be5914df2fa2d7235c14ab45dfda341dfe621aae Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 5 May 2013 22:19:54 +0000 Subject: [PATCH] [RTL] When we are impersonating, also set the flag, so that on release, we can kill it. This hopefully fixes 2nd stage and the whole mess it was causing in privileges. svn path=/trunk/; revision=58959 --- reactos/lib/rtl/priv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reactos/lib/rtl/priv.c b/reactos/lib/rtl/priv.c index 9b9bfb80ce9..5021966d45c 100644 --- a/reactos/lib/rtl/priv.c +++ b/reactos/lib/rtl/priv.c @@ -247,8 +247,9 @@ RtlAcquirePrivilege(IN PULONG Privilege, goto Cleanup; } - /* Save said token */ + /* Save said token and the fact we have impersonated */ State->Token = ImpersonationToken; + State->Flags |= RTL_ACQUIRE_PRIVILEGE_IMPERSONATE; ZwClose(ProcessToken); } @@ -372,7 +373,9 @@ RtlReleasePrivilege(IN PVOID ReturnedState) DPRINT("RtlReleasePrivilege(%p)\n", ReturnedState); - /* If we had an active impersonation before we acquired privileges */ + /* If we had an active impersonation before we acquired privileges + * Or if we have impersonated, quit it + */ if (State->Flags & RTL_ACQUIRE_PRIVILEGE_IMPERSONATE) { /* Restore it for the current thread */