Commit in reactos/lib/kernel32/process on MAIN
proc.c+2-21.68 -> 1.69
session.c+47-391.6 -> 1.7
+49-41
2 modified files
fixed ProcessIdToSessionId()

reactos/lib/kernel32/process
proc.c 1.68 -> 1.69
diff -u -r1.68 -r1.69
--- proc.c	23 Sep 2004 19:01:38 -0000	1.68
+++ proc.c	2 Oct 2004 21:14:08 -0000	1.69
@@ -1,4 +1,4 @@
-/* $Id: proc.c,v 1.68 2004/09/23 19:01:38 weiden Exp $
+/* $Id: proc.c,v 1.69 2004/10/02 21:14:08 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -356,7 +356,7 @@
    NTSTATUS errCode;
    HANDLE ProcessHandle;
    OBJECT_ATTRIBUTES ObjectAttributes;
-   CLIENT_ID ClientId ;
+   CLIENT_ID ClientId;
    
    ClientId.UniqueProcess = (HANDLE)dwProcessId;
    ClientId.UniqueThread = INVALID_HANDLE_VALUE;

reactos/lib/kernel32/process
session.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- session.c	23 Sep 2004 21:01:23 -0000	1.6
+++ session.c	2 Oct 2004 21:14:08 -0000	1.7
@@ -1,4 +1,4 @@
-/* $Id: session.c,v 1.6 2004/09/23 21:01:23 ea Exp $
+/* $Id: session.c,v 1.7 2004/10/02 21:14:08 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -48,44 +48,52 @@
 BOOL STDCALL ProcessIdToSessionId (IN  DWORD dwProcessId,
 				   OUT DWORD* pSessionId)
 {
-	NTSTATUS           Status = STATUS_SUCCESS;
-	HANDLE             ProcessHandle = INVALID_HANDLE_VALUE;
-	OBJECT_ATTRIBUTES  Oa = { sizeof (OBJECT_ATTRIBUTES), 0, };
-	DWORD              SessionId = 0;
-
-	if (IsBadWritePtr(pSessionId, sizeof (DWORD)))
-	{
-		SetLastError (ERROR_INVALID_DATA); //FIXME
-		goto ProcessIdToSessionId_FAIL_EXIT;
-	}
-	Status = NtOpenProcess (
-			& ProcessHandle,
-			PROCESS_QUERY_INFORMATION,
-			& Oa,
-			NULL);
-	if (!NT_SUCCESS(Status))
-	{
-		goto ProcessIdToSessionId_FAIL;
-	}
-	Status = NtQueryInformationProcess (
-			ProcessHandle,
-			ProcessSessionInformation,
-			& SessionId,
-			sizeof SessionId,
-			NULL);
-	if (!NT_SUCCESS(Status))
-	{
-		NtClose (ProcessHandle);
-		goto ProcessIdToSessionId_FAIL;
-	}
-	NtClose (ProcessHandle);
-	*pSessionId = SessionId;
-	return TRUE;
-
-ProcessIdToSessionId_FAIL:
-	SetLastErrorByStatus(Status);
-ProcessIdToSessionId_FAIL_EXIT:
-	return FALSE;
+  PROCESS_SESSION_INFORMATION SessionInformation;
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  CLIENT_ID ClientId;
+  HANDLE ProcessHandle;
+  NTSTATUS Status;
+  
+  if(IsBadWritePtr(pSessionId, sizeof(DWORD)))
+  {
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
+  }
+  
+  ClientId.UniqueProcess = (HANDLE)dwProcessId;
+  ClientId.UniqueThread = INVALID_HANDLE_VALUE;
+
+  InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
+  
+  Status = NtOpenProcess(&ProcessHandle,
+                         PROCESS_QUERY_INFORMATION,
+                         &ObjectAttributes,
+                         &ClientId);
+  if(NT_SUCCESS(Status))
+  {
+    Status = NtQueryInformationProcess(ProcessHandle,
+                                       ProcessSessionInformation,
+                                       &SessionInformation,
+                                       sizeof(SessionInformation),
+                                       NULL);
+    NtClose(ProcessHandle);
+    
+    if(NT_SUCCESS(Status))
+    {
+      *pSessionId = SessionInformation.SessionId;
+      return TRUE;
+    }
+    else
+    {
+      SetLastErrorByStatus(Status);
+    }
+  }
+  else
+  {
+    SetLastErrorByStatus(Status);
+  }
+  
+  return FALSE;
 }
 
 /*
CVSspam 0.2.8