mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Protected the handle table.
svn path=/trunk/; revision=15526
This commit is contained in:
parent
7d4d22763c
commit
deab50cb8b
3 changed files with 26 additions and 19 deletions
|
@ -123,8 +123,10 @@ CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
|
|||
}
|
||||
|
||||
Status = CsrReleaseObjectByPointer(ProcessData->HandleTable[h]);
|
||||
ProcessData->HandleTable[h] = 0;
|
||||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
ProcessData->HandleTable[h] = 0;
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -138,22 +140,23 @@ NTSTATUS STDCALL CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handl
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
||||
for (i = 0; i < ProcessData->HandleTableSize; i++)
|
||||
{
|
||||
if (ProcessData->HandleTable[i] == NULL)
|
||||
{
|
||||
ProcessData->HandleTable[i] = Object;
|
||||
*Handle = (HANDLE)(((i + 1) << 2) | 0x3);
|
||||
InterlockedIncrement( &Object->ReferenceCount );
|
||||
return(STATUS_SUCCESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= ProcessData->HandleTableSize)
|
||||
{
|
||||
NewBlock = RtlAllocateHeap(CsrssApiHeap,
|
||||
HEAP_ZERO_MEMORY,
|
||||
(ProcessData->HandleTableSize + 64) *
|
||||
sizeof(HANDLE));
|
||||
(ProcessData->HandleTableSize + 64) * sizeof(HANDLE));
|
||||
if (NewBlock == NULL)
|
||||
{
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
RtlCopyMemory(NewBlock,
|
||||
|
@ -161,10 +164,12 @@ NTSTATUS STDCALL CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handl
|
|||
ProcessData->HandleTableSize * sizeof(HANDLE));
|
||||
RtlFreeHeap( CsrssApiHeap, 0, ProcessData->HandleTable );
|
||||
ProcessData->HandleTable = (Object_t **)NewBlock;
|
||||
ProcessData->HandleTableSize += 64;
|
||||
}
|
||||
ProcessData->HandleTable[i] = Object;
|
||||
*Handle = (HANDLE)(((i + 1) << 2) | 0x3);
|
||||
InterlockedIncrement( &Object->ReferenceCount );
|
||||
ProcessData->HandleTableSize = ProcessData->HandleTableSize + 64;
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(HANDLE ProcessId)
|
|||
RtlFreeHeap(CsrssApiHeap, 0, pProcessData);
|
||||
pProcessData = NULL;
|
||||
}
|
||||
RtlInitializeCriticalSection(&pProcessData->HandleTableLock);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -160,6 +161,7 @@ NTSTATUS STDCALL CsrFreeProcessData(HANDLE Pid)
|
|||
}
|
||||
RtlFreeHeap(CsrssApiHeap, 0, pProcessData->HandleTable);
|
||||
}
|
||||
RtlDeleteCriticalSection(&pProcessData->HandleTableLock);
|
||||
if (pProcessData->Console)
|
||||
{
|
||||
CsrReleaseObjectByPointer((Object_t *) pProcessData->Console);
|
||||
|
@ -254,7 +256,6 @@ CSR_API(CsrCreateProcess)
|
|||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DbgPrint( "CSR: NtDuplicateObject() failed: %x\n", Status );
|
||||
InterlockedDecrement( &(NewProcessData->Console->Header.ReferenceCount) );
|
||||
CsrFreeProcessData( NewProcessData->ProcessId );
|
||||
Reply->Status = Status;
|
||||
return Status;
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct tagCSRSS_CONSOLE *PCSRSS_CONSOLE;
|
|||
typedef struct _CSRSS_PROCESS_DATA
|
||||
{
|
||||
PCSRSS_CONSOLE Console;
|
||||
RTL_CRITICAL_SECTION HandleTableLock;
|
||||
ULONG HandleTableSize;
|
||||
Object_t ** HandleTable;
|
||||
HANDLE ProcessId;
|
||||
|
|
Loading…
Reference in a new issue