mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
Removed some calls to NtOpenProcess. They aren't necessary because the process data structure contains already a process handle.
svn path=/trunk/; revision=14480
This commit is contained in:
parent
4e0cf9abb6
commit
f22d019858
2 changed files with 3 additions and 47 deletions
|
@ -95,7 +95,7 @@ PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(HANDLE ProcessId)
|
|||
/* using OpenProcess is not optimal due to HANDLE vs. DWORD PIDs... */
|
||||
Status = NtOpenProcess(&pProcessData->Process,
|
||||
PROCESS_DUP_HANDLE | PROCESS_VM_OPERATION |
|
||||
PROCESS_VM_WRITE | PROCESS_CREATE_THREAD,
|
||||
PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
&ClientId);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -195,7 +195,6 @@ CSR_API(CsrCreateProcess)
|
|||
{
|
||||
PCSRSS_PROCESS_DATA NewProcessData;
|
||||
NTSTATUS Status;
|
||||
HANDLE Process;
|
||||
CSRSS_API_REQUEST ApiRequest;
|
||||
CSRSS_API_REPLY ApiReply;
|
||||
|
||||
|
@ -240,8 +239,6 @@ CSR_API(CsrCreateProcess)
|
|||
}
|
||||
else
|
||||
{
|
||||
CLIENT_ID ClientId;
|
||||
|
||||
NewProcessData->Console = ProcessData->Console;
|
||||
InterlockedIncrement( &(ProcessData->Console->Header.ReferenceCount) );
|
||||
CsrInsertObject(NewProcessData,
|
||||
|
@ -253,27 +250,15 @@ CSR_API(CsrCreateProcess)
|
|||
&(NewProcessData->Console->ActiveBuffer->Header) );
|
||||
|
||||
RtlLeaveCriticalSection(&ProcessDataLock);
|
||||
ClientId.UniqueProcess = (HANDLE)NewProcessData->ProcessId;
|
||||
Status = NtOpenProcess( &Process, PROCESS_DUP_HANDLE, 0, &ClientId );
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DbgPrint( "CSR: NtOpenProcess() failed for handle duplication\n" );
|
||||
InterlockedDecrement( &(NewProcessData->Console->Header.ReferenceCount) );
|
||||
CsrFreeProcessData( NewProcessData->ProcessId );
|
||||
Reply->Status = Status;
|
||||
return Status;
|
||||
}
|
||||
Status = NtDuplicateObject( NtCurrentProcess(), NewProcessData->Console->ActiveEvent, Process, &NewProcessData->ConsoleEvent, SYNCHRONIZE, FALSE, 0 );
|
||||
Status = NtDuplicateObject( NtCurrentProcess(), NewProcessData->Console->ActiveEvent, NewProcessData->Process, &NewProcessData->ConsoleEvent, SYNCHRONIZE, FALSE, 0 );
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DbgPrint( "CSR: NtDuplicateObject() failed: %x\n", Status );
|
||||
NtClose( Process );
|
||||
InterlockedDecrement( &(NewProcessData->Console->Header.ReferenceCount) );
|
||||
CsrFreeProcessData( NewProcessData->ProcessId );
|
||||
Reply->Status = Status;
|
||||
return Status;
|
||||
}
|
||||
NtClose( Process );
|
||||
NewProcessData->CtrlDispatcher = Request->Data.CreateProcessRequest.CtrlDispatcher;
|
||||
RtlEnterCriticalSection(&ProcessDataLock );
|
||||
InsertHeadList(&NewProcessData->Console->ProcessList, &NewProcessData->ProcessEntry);
|
||||
|
|
|
@ -238,9 +238,6 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
|
|||
CSR_API(CsrAllocConsole)
|
||||
{
|
||||
PCSRSS_CONSOLE Console;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
CLIENT_ID ClientId;
|
||||
HANDLE Process;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CsrAllocConsole\n");
|
||||
|
@ -293,35 +290,10 @@ CSR_API(CsrAllocConsole)
|
|||
return Reply->Status = Status;
|
||||
}
|
||||
|
||||
ClientId.UniqueThread = NULL;
|
||||
ClientId.UniqueProcess = ProcessData->ProcessId;
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* using OpenProcess is not optimal due to HANDLE vs. DWORD PIDs... */
|
||||
Status = NtOpenProcess(&Process,
|
||||
PROCESS_DUP_HANDLE,
|
||||
&ObjectAttributes,
|
||||
&ClientId);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtOpenProcess() failed for handle duplication, Status: 0x%x\n", Status);
|
||||
Console->Header.ReferenceCount--;
|
||||
ProcessData->Console = 0;
|
||||
Win32CsrReleaseObject(ProcessData, Reply->Data.AllocConsoleReply.OutputHandle);
|
||||
Win32CsrReleaseObject(ProcessData, Reply->Data.AllocConsoleReply.InputHandle);
|
||||
Reply->Status = Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (! DuplicateHandle(GetCurrentProcess(), ProcessData->Console->ActiveEvent,
|
||||
Process, &ProcessData->ConsoleEvent, EVENT_ALL_ACCESS, FALSE, 0))
|
||||
ProcessData->Process, &ProcessData->ConsoleEvent, EVENT_ALL_ACCESS, FALSE, 0))
|
||||
{
|
||||
DPRINT1("DuplicateHandle() failed: %d\n", GetLastError);
|
||||
CloseHandle(Process);
|
||||
Console->Header.ReferenceCount--;
|
||||
Win32CsrReleaseObject(ProcessData, Reply->Data.AllocConsoleReply.OutputHandle);
|
||||
Win32CsrReleaseObject(ProcessData, Reply->Data.AllocConsoleReply.InputHandle);
|
||||
|
@ -329,7 +301,6 @@ CSR_API(CsrAllocConsole)
|
|||
Reply->Status = Status;
|
||||
return Status;
|
||||
}
|
||||
CloseHandle(Process);
|
||||
ProcessData->CtrlDispatcher = Request->Data.AllocConsoleRequest.CtrlDispatcher;
|
||||
DPRINT("CSRSS:CtrlDispatcher address: %x\n", ProcessData->CtrlDispatcher);
|
||||
InsertHeadList(&ProcessData->Console->ProcessList, &ProcessData->ProcessEntry);
|
||||
|
|
Loading…
Reference in a new issue