X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fsubsystems%2Fwin32%2Fcsrss%2Fwin32csr%2Fhandle.c;h=e1afd16b87315b6727a9e41407de7aa68d0d4762;hp=b137c3c66e5b1a8a6dc9a98b7e5aa0edcc81193b;hb=ff2f27f29b9381a364fbb1f5d5e89015a20d59a9;hpb=8686d42f934a81e8758deb57dbbd63959f6071fc diff --git a/reactos/subsystems/win32/csrss/win32csr/handle.c b/reactos/subsystems/win32/csrss/win32csr/handle.c index b137c3c66e5..e1afd16b873 100644 --- a/reactos/subsystems/win32/csrss/win32csr/handle.c +++ b/reactos/subsystems/win32/csrss/win32csr/handle.c @@ -146,28 +146,25 @@ WINAPI Win32CsrReleaseConsole( PCSRSS_PROCESS_DATA ProcessData) { - ULONG HandleTableSize; - PCSRSS_HANDLE HandleTable; PCSRSS_CONSOLE Console; ULONG i; /* Close all console handles and detach process from console */ RtlEnterCriticalSection(&ProcessData->HandleTableLock); - HandleTableSize = ProcessData->HandleTableSize; - HandleTable = ProcessData->HandleTable; - Console = ProcessData->Console; + + for (i = 0; i < ProcessData->HandleTableSize; i++) + { + if (ProcessData->HandleTable[i].Object != NULL) + Win32CsrReleaseObjectByPointer(ProcessData->HandleTable[i].Object); + } ProcessData->HandleTableSize = 0; + RtlFreeHeap(Win32CsrApiHeap, 0, ProcessData->HandleTable); ProcessData->HandleTable = NULL; + + Console = ProcessData->Console; ProcessData->Console = NULL; RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - for (i = 0; i < HandleTableSize; i++) - { - if (HandleTable[i].Object != NULL) - Win32CsrReleaseObjectByPointer(HandleTable[i].Object); - } - RtlFreeHeap(Win32CsrApiHeap, 0, HandleTable); - if (Console != NULL) { EnterCriticalSection(&Console->Header.Lock); @@ -272,6 +269,7 @@ CSR_API(CsrGetInputHandle) Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { Request->Status = Win32CsrInsertObject(ProcessData, @@ -285,6 +283,7 @@ CSR_API(CsrGetInputHandle) Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE; Request->Status = STATUS_SUCCESS; } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Request->Status; } @@ -294,6 +293,7 @@ CSR_API(CsrGetOutputHandle) Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { Request->Status = Win32CsrInsertObject(ProcessData, @@ -307,6 +307,7 @@ CSR_API(CsrGetOutputHandle) Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE; Request->Status = STATUS_SUCCESS; } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Request->Status; }