Fix more wrong structure defintions that don't match official ones, plus fix little bug I introduced.
Modified: trunk/reactos/include/ddk/setypes.h
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
Modified: trunk/reactos/ntoskrnl/ps/create.c
Modified: trunk/reactos/ntoskrnl/se/token.c

Modified: trunk/reactos/include/ddk/setypes.h
--- trunk/reactos/include/ddk/setypes.h	2005-01-03 01:02:26 UTC (rev 12743)
+++ trunk/reactos/include/ddk/setypes.h	2005-01-03 01:13:10 UTC (rev 12744)
@@ -143,12 +143,12 @@
 
 typedef struct _SECURITY_CLIENT_CONTEXT
 {
-  SECURITY_QUALITY_OF_SERVICE SecurityQos;	/* 0x00 */
-  PACCESS_TOKEN Token;				/* 0x0C */
-  BOOLEAN DirectlyAccessClientToken;		/* 0x10 */
-  BOOLEAN DirectAccessEffectiveOnly;		/* 0x11 */
-  BOOLEAN ServerIsRemote;			/* 0x12 */
-  TOKEN_CONTROL ClientTokenControl;		/* 0x14 */
+    SECURITY_QUALITY_OF_SERVICE SecurityQos;
+    PACCESS_TOKEN               ClientToken;
+    BOOLEAN                     DirectlyAccessClientToken;
+    BOOLEAN                     DirectAccessEffectiveOnly;
+    BOOLEAN                     ServerIsRemote;
+    TOKEN_CONTROL               ClientTokenControl;
 } SECURITY_CLIENT_CONTEXT, *PSECURITY_CLIENT_CONTEXT;
 
 

Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
--- trunk/reactos/ntoskrnl/include/internal/ps.h	2005-01-03 01:02:26 UTC (rev 12743)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h	2005-01-03 01:13:10 UTC (rev 12744)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: ps.h,v 1.77 2004/12/05 15:42:41 weiden Exp $
+/* $Id$
  *
  * FILE:            ntoskrnl/ke/kthread.c
  * PURPOSE:         Process manager definitions
@@ -147,10 +147,10 @@
 #ifndef __USE_W32API
 typedef struct
 {
-  PACCESS_TOKEN Token;
-  BOOLEAN CopyOnOpen;
-  BOOLEAN EffectiveOnly;
-  SECURITY_IMPERSONATION_LEVEL Level;
+    PACCESS_TOKEN                   Token;
+    BOOLEAN                         CopyOnOpen;
+    BOOLEAN                         EffectiveOnly;
+    SECURITY_IMPERSONATION_LEVEL    ImpersonationLevel;
 } PS_IMPERSONATION_INFORMATION, *PPS_IMPERSONATION_INFORMATION;
 #endif
 

Modified: trunk/reactos/ntoskrnl/ps/create.c
--- trunk/reactos/ntoskrnl/ps/create.c	2005-01-03 01:02:26 UTC (rev 12743)
+++ trunk/reactos/ntoskrnl/ps/create.c	2005-01-03 01:13:10 UTC (rev 12744)
@@ -134,7 +134,7 @@
 						  sizeof(PS_IMPERSONATION_INFORMATION));
     }
 
-  Thread->ImpersonationInfo->Level = ImpersonationLevel;
+  Thread->ImpersonationInfo->ImpersonationLevel = ImpersonationLevel;
   Thread->ImpersonationInfo->CopyOnOpen = CopyOnOpen;
   Thread->ImpersonationInfo->EffectiveOnly = EffectiveOnly;
   Thread->ImpersonationInfo->Token = Token;
@@ -167,7 +167,7 @@
 	Token = Thread->ImpersonationInfo->Token;
 	*TokenType = TokenImpersonation;
 	*EffectiveOnly = Thread->ImpersonationInfo->EffectiveOnly;
-	*Level = Thread->ImpersonationInfo->Level;
+	*Level = Thread->ImpersonationInfo->ImpersonationLevel;
      }
    return(Token);
 }
@@ -219,9 +219,9 @@
 
   SeImpersonateClient (&ClientContext,
 		       Thread);
-  if (ClientContext.Token != NULL)
+  if (ClientContext.ClientToken != NULL)
     {
-      ObDereferenceObject (ClientContext.Token);
+      ObDereferenceObject (ClientContext.ClientToken);
     }
 
   ObDereferenceObject (ThreadToImpersonate);
@@ -244,7 +244,7 @@
       return NULL;
     }
 
-  *ImpersonationLevel = Thread->ImpersonationInfo->Level;
+  *ImpersonationLevel = Thread->ImpersonationInfo->ImpersonationLevel;
   *CopyOnOpen = Thread->ImpersonationInfo->CopyOnOpen;
   *EffectiveOnly = Thread->ImpersonationInfo->EffectiveOnly;
   ObReferenceObjectByPointer (Thread->ImpersonationInfo->Token,
@@ -255,8 +255,11 @@
   return Thread->ImpersonationInfo->Token;
 }
 
+#ifdef PsDereferencePrimaryToken
+#undef PsDereferenceImpersonationToken
+#endif
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 STDCALL
@@ -264,11 +267,16 @@
     IN PACCESS_TOKEN ImpersonationToken
     )
 {
-	UNIMPLEMENTED;	
+    if (ImpersonationToken) {
+        ObDereferenceObject(ImpersonationToken);
+    }
 }
 
+#ifdef PsDereferencePrimaryToken
+#undef PsDereferencePrimaryToken
+#endif
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 STDCALL
@@ -276,7 +284,7 @@
     IN PACCESS_TOKEN PrimaryToken
     )
 {
-	UNIMPLEMENTED;	
+    ObDereferenceObject(PrimaryToken);
 }
 
 /*
@@ -305,7 +313,7 @@
    ImpersonationState->Token = Thread->ImpersonationInfo->Token;
    ImpersonationState->CopyOnOpen = Thread->ImpersonationInfo->CopyOnOpen;
    ImpersonationState->EffectiveOnly = Thread->ImpersonationInfo->EffectiveOnly;
-   ImpersonationState->Level = Thread->ImpersonationInfo->Level;
+   ImpersonationState->Level = Thread->ImpersonationInfo->ImpersonationLevel;
 
 /* FIXME */
 /*   ExfReleasePushLock(&Thread->ThreadLock); */

Modified: trunk/reactos/ntoskrnl/se/token.c
--- trunk/reactos/ntoskrnl/se/token.c	2005-01-03 01:02:26 UTC (rev 12743)
+++ trunk/reactos/ntoskrnl/se/token.c	2005-01-03 01:13:10 UTC (rev 12744)
@@ -317,7 +317,6 @@
 {
    NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;
-   PTOKEN TokenNew;
      
    InitializeObjectAttributes(&ObjectAttributes,
 			      NULL,
@@ -332,7 +331,6 @@
 				PreviousMode,
 			    (PTOKEN*)&NewToken);
    
-   *NewToken = (PACCESS_TOKEN)TokenNew;
    return(Status);
 }
 
@@ -423,7 +421,7 @@
   ClientContext->SecurityQos.ContextTrackingMode = Qos->ContextTrackingMode;
   ClientContext->SecurityQos.EffectiveOnly = Qos->EffectiveOnly;
   ClientContext->ServerIsRemote = RemoteClient;
-  ClientContext->Token = NewToken;
+  ClientContext->ClientToken = NewToken;
 
   return(STATUS_SUCCESS);
 }
@@ -511,7 +509,7 @@
       ServerThread = PsGetCurrentThread();
     }
   PsImpersonateClient(ServerThread,
-		      ClientContext->Token,
+		      ClientContext->ClientToken,
 		      1,
 		      (ULONG)b,
 		      ClientContext->SecurityQos.ImpersonationLevel);