diff --git a/reactos/subsys/csrss/api/process.c b/reactos/subsys/csrss/api/process.c index 9ccd15c5508..24dacee8f9d 100644 --- a/reactos/subsys/csrss/api/process.c +++ b/reactos/subsys/csrss/api/process.c @@ -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); diff --git a/reactos/subsys/csrss/win32csr/conio.c b/reactos/subsys/csrss/win32csr/conio.c index 4dfac19dc95..da5c7a38657 100644 --- a/reactos/subsys/csrss/win32csr/conio.c +++ b/reactos/subsys/csrss/win32csr/conio.c @@ -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);