mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
fixed ProcessIdToSessionId()
svn path=/trunk/; revision=11161
This commit is contained in:
parent
3f75c451d1
commit
b26683b0b3
2 changed files with 48 additions and 40 deletions
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -356,7 +356,7 @@ OpenProcess(DWORD dwDesiredAccess,
|
||||||
NTSTATUS errCode;
|
NTSTATUS errCode;
|
||||||
HANDLE ProcessHandle;
|
HANDLE ProcessHandle;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
CLIENT_ID ClientId ;
|
CLIENT_ID ClientId;
|
||||||
|
|
||||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||||
ClientId.UniqueThread = INVALID_HANDLE_VALUE;
|
ClientId.UniqueThread = INVALID_HANDLE_VALUE;
|
||||||
|
|
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -48,44 +48,52 @@ DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath)
|
||||||
BOOL STDCALL ProcessIdToSessionId (IN DWORD dwProcessId,
|
BOOL STDCALL ProcessIdToSessionId (IN DWORD dwProcessId,
|
||||||
OUT DWORD* pSessionId)
|
OUT DWORD* pSessionId)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
PROCESS_SESSION_INFORMATION SessionInformation;
|
||||||
HANDLE ProcessHandle = INVALID_HANDLE_VALUE;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
OBJECT_ATTRIBUTES Oa = { sizeof (OBJECT_ATTRIBUTES), 0, };
|
CLIENT_ID ClientId;
|
||||||
DWORD SessionId = 0;
|
HANDLE ProcessHandle;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if(IsBadWritePtr(pSessionId, sizeof(DWORD)))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||||
|
ClientId.UniqueThread = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
if (IsBadWritePtr(pSessionId, sizeof (DWORD)))
|
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
||||||
{
|
|
||||||
SetLastError (ERROR_INVALID_DATA); //FIXME
|
Status = NtOpenProcess(&ProcessHandle,
|
||||||
goto ProcessIdToSessionId_FAIL_EXIT;
|
PROCESS_QUERY_INFORMATION,
|
||||||
}
|
&ObjectAttributes,
|
||||||
Status = NtOpenProcess (
|
&ClientId);
|
||||||
& ProcessHandle,
|
if(NT_SUCCESS(Status))
|
||||||
PROCESS_QUERY_INFORMATION,
|
{
|
||||||
& Oa,
|
Status = NtQueryInformationProcess(ProcessHandle,
|
||||||
NULL);
|
ProcessSessionInformation,
|
||||||
if (!NT_SUCCESS(Status))
|
&SessionInformation,
|
||||||
{
|
sizeof(SessionInformation),
|
||||||
goto ProcessIdToSessionId_FAIL;
|
NULL);
|
||||||
}
|
NtClose(ProcessHandle);
|
||||||
Status = NtQueryInformationProcess (
|
|
||||||
ProcessHandle,
|
if(NT_SUCCESS(Status))
|
||||||
ProcessSessionInformation,
|
{
|
||||||
& SessionId,
|
*pSessionId = SessionInformation.SessionId;
|
||||||
sizeof SessionId,
|
return TRUE;
|
||||||
NULL);
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
else
|
||||||
{
|
{
|
||||||
NtClose (ProcessHandle);
|
SetLastErrorByStatus(Status);
|
||||||
goto ProcessIdToSessionId_FAIL;
|
}
|
||||||
}
|
}
|
||||||
NtClose (ProcessHandle);
|
else
|
||||||
*pSessionId = SessionId;
|
{
|
||||||
return TRUE;
|
SetLastErrorByStatus(Status);
|
||||||
|
}
|
||||||
ProcessIdToSessionId_FAIL:
|
|
||||||
SetLastErrorByStatus(Status);
|
return FALSE;
|
||||||
ProcessIdToSessionId_FAIL_EXIT:
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue