Author: jmorlan
Date: Sun May 23 01:47:54 2010
New Revision: 47314
URL:
http://svn.reactos.org/svn/reactos?rev=47314&view=rev
Log:
[CSRSRV], [WIN32CSR]
- Move code for managing console handles from csrsrv to win32csr, where the rest of the
console code is. No changes in functionality intended.
- Unify the csrsrv->win32csr callbacks (now numbering 4) into one table to avoid
excessive code duplication.
Added:
trunk/reactos/subsystems/win32/csrss/win32csr/conio.h
- copied unchanged from r47308,
trunk/reactos/subsystems/win32/csrss/include/conio.h
trunk/reactos/subsystems/win32/csrss/win32csr/handle.c
- copied, changed from r47313,
trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h
- copied unchanged from r47313,
trunk/reactos/subsystems/win32/csrss/include/win32csr.h
Removed:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
trunk/reactos/subsystems/win32/csrss/include/conio.h
trunk/reactos/subsystems/win32/csrss/include/win32csr.h
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
trunk/reactos/subsystems/win32/csrss/include/api.h
trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.spec
Removed: trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c (removed)
@@ -1,292 +1,0 @@
-/* $Id$
- *
- * reactos/subsys/csrss/api/handle.c
- *
- * CSRSS handle functions
- *
- * ReactOS Operating System
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <srv.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-static unsigned ObjectDefinitionsCount = 0;
-static PCSRSS_OBJECT_DEFINITION ObjectDefinitions = NULL;
-
-static
-BOOL
-CsrIsConsoleHandle(HANDLE Handle)
-{
- return ((ULONG_PTR)Handle & 0x10000003) == 0x3;
-}
-
-
-NTSTATUS
-FASTCALL
-CsrRegisterObjectDefinitions(
- PCSRSS_OBJECT_DEFINITION NewDefinitions)
-{
- unsigned NewCount;
- PCSRSS_OBJECT_DEFINITION Scan;
- PCSRSS_OBJECT_DEFINITION New;
-
- NewCount = 0;
- for (Scan = NewDefinitions; 0 != Scan->Type; Scan++)
- {
- NewCount++;
- }
-
- New = RtlAllocateHeap(CsrssApiHeap,
- 0,
- (ObjectDefinitionsCount + NewCount)
- * sizeof(CSRSS_OBJECT_DEFINITION));
- if (NULL == New)
- {
- DPRINT1("Unable to allocate memory\n");
- return STATUS_NO_MEMORY;
- }
-
- if (0 != ObjectDefinitionsCount)
- {
- RtlCopyMemory(New,
- ObjectDefinitions,
- ObjectDefinitionsCount * sizeof(CSRSS_OBJECT_DEFINITION));
- RtlFreeHeap(CsrssApiHeap, 0, ObjectDefinitions);
- }
-
- RtlCopyMemory(New + ObjectDefinitionsCount,
- NewDefinitions,
- NewCount * sizeof(CSRSS_OBJECT_DEFINITION));
- ObjectDefinitions = New;
- ObjectDefinitionsCount += NewCount;
-
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-WINAPI
-CsrGetObject(
- PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle,
- Object_t **Object,
- DWORD Access )
-{
- ULONG_PTR h = (ULONG_PTR)Handle >> 2;
-
- DPRINT("CsrGetObject, Object: %x, %x, %x\n",
- Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
-
- RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- if (!CsrIsConsoleHandle(Handle) || h >= ProcessData->HandleTableSize
- || (*Object = ProcessData->HandleTable[h].Object) == NULL
- || ~ProcessData->HandleTable[h].Access & Access)
- {
- DPRINT1("CsrGetObject returning invalid handle (%x)\n", Handle);
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return STATUS_INVALID_HANDLE;
- }
- _InterlockedIncrement(&(*Object)->ReferenceCount);
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- // DbgPrint( "CsrGetObject returning\n" );
- return STATUS_SUCCESS;
-}
-
-
-NTSTATUS
-WINAPI
-CsrReleaseObjectByPointer(
- Object_t *Object)
-{
- unsigned DefIndex;
-
- /* dec ref count */
- if (_InterlockedDecrement(&Object->ReferenceCount) == 0)
- {
- for (DefIndex = 0; DefIndex < ObjectDefinitionsCount; DefIndex++)
- {
- if (Object->Type == ObjectDefinitions[DefIndex].Type)
- {
- (ObjectDefinitions[DefIndex].CsrCleanupObjectProc)(Object);
- return STATUS_SUCCESS;
- }
- }
-
- DPRINT1("CSR: Error: releasing unknown object type 0x%x",
Object->Type);
- }
-
- return STATUS_SUCCESS;
-}
-
-
-NTSTATUS
-WINAPI
-CsrReleaseObject(
- PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle)
-{
- ULONG_PTR h = (ULONG_PTR)Handle >> 2;
- Object_t *Object;
-
- RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- if (h >= ProcessData->HandleTableSize
- || (Object = ProcessData->HandleTable[h].Object) == NULL)
- {
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return STATUS_INVALID_HANDLE;
- }
- ProcessData->HandleTable[h].Object = NULL;
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
-
- return CsrReleaseObjectByPointer(Object);
-}
-
-NTSTATUS
-WINAPI
-CsrReleaseConsole(
- 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;
- ProcessData->HandleTableSize = 0;
- ProcessData->HandleTable = NULL;
- ProcessData->Console = NULL;
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
-
- for (i = 0; i < HandleTableSize; i++)
- {
- if (HandleTable[i].Object != NULL)
- CsrReleaseObjectByPointer(HandleTable[i].Object);
- }
- RtlFreeHeap(CsrssApiHeap, 0, HandleTable);
-
- if (Console != NULL)
- {
- RtlEnterCriticalSection((PRTL_CRITICAL_SECTION)&Console->Header.Lock);
- RemoveEntryList(&ProcessData->ProcessEntry);
- RtlLeaveCriticalSection((PRTL_CRITICAL_SECTION)&Console->Header.Lock);
- CsrReleaseObjectByPointer(&Console->Header);
- return STATUS_SUCCESS;
- }
-
- return STATUS_INVALID_PARAMETER;
-}
-
-NTSTATUS
-WINAPI
-CsrInsertObject(
- PCSRSS_PROCESS_DATA ProcessData,
- PHANDLE Handle,
- Object_t *Object,
- DWORD Access,
- BOOL Inheritable)
-{
- ULONG i;
- PVOID* Block;
-
- RtlEnterCriticalSection(&ProcessData->HandleTableLock);
-
- for (i = 0; i < ProcessData->HandleTableSize; i++)
- {
- if (ProcessData->HandleTable[i].Object == NULL)
- {
- break;
- }
- }
- if (i >= ProcessData->HandleTableSize)
- {
- Block = RtlAllocateHeap(CsrssApiHeap,
- HEAP_ZERO_MEMORY,
- (ProcessData->HandleTableSize + 64) *
sizeof(CSRSS_HANDLE));
- if (Block == NULL)
- {
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return(STATUS_UNSUCCESSFUL);
- }
- RtlCopyMemory(Block,
- ProcessData->HandleTable,
- ProcessData->HandleTableSize * sizeof(CSRSS_HANDLE));
- Block = _InterlockedExchangePointer((void*
volatile)&ProcessData->HandleTable, Block);
- RtlFreeHeap( CsrssApiHeap, 0, Block );
- ProcessData->HandleTableSize += 64;
- }
- ProcessData->HandleTable[i].Object = Object;
- ProcessData->HandleTable[i].Access = Access;
- ProcessData->HandleTable[i].Inheritable = Inheritable;
- *Handle = UlongToHandle((i << 2) | 0x3);
- _InterlockedIncrement( &Object->ReferenceCount );
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return(STATUS_SUCCESS);
-}
-
-NTSTATUS
-WINAPI
-CsrDuplicateHandleTable(
- PCSRSS_PROCESS_DATA SourceProcessData,
- PCSRSS_PROCESS_DATA TargetProcessData)
-{
- ULONG i;
-
- if (TargetProcessData->HandleTableSize)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- RtlEnterCriticalSection(&SourceProcessData->HandleTableLock);
-
- /* we are called from CreateProcessData, it isn't necessary to lock the target
process data */
-
- TargetProcessData->HandleTable = RtlAllocateHeap(CsrssApiHeap,
- HEAP_ZERO_MEMORY,
-
SourceProcessData->HandleTableSize
- * sizeof(CSRSS_HANDLE));
- if (TargetProcessData->HandleTable == NULL)
- {
- RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock);
- return(STATUS_UNSUCCESSFUL);
- }
- TargetProcessData->HandleTableSize = SourceProcessData->HandleTableSize;
- for (i = 0; i < SourceProcessData->HandleTableSize; i++)
- {
- if (SourceProcessData->HandleTable[i].Object != NULL &&
- SourceProcessData->HandleTable[i].Inheritable)
- {
- TargetProcessData->HandleTable[i] = SourceProcessData->HandleTable[i];
- _InterlockedIncrement(
&SourceProcessData->HandleTable[i].Object->ReferenceCount );
- }
- }
- RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock);
- return(STATUS_SUCCESS);
-}
-
-NTSTATUS
-WINAPI
-CsrVerifyObject(
- PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle)
-{
- ULONG_PTR h = (ULONG_PTR)Handle >> 2;
-
- if (h >= ProcessData->HandleTableSize ||
- ProcessData->HandleTable[h].Object == NULL)
- {
- return STATUS_INVALID_HANDLE;
- }
-
- return STATUS_SUCCESS;
-}
-
-/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Sun May 23
01:47:54 2010
@@ -17,6 +17,9 @@
#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock)
#define CsrAcquireProcessLock() LOCK
#define CsrReleaseProcessLock() UNLOCK
+
+extern NTSTATUS CallProcessInherit(PCSRSS_PROCESS_DATA, PCSRSS_PROCESS_DATA);
+extern NTSTATUS CallProcessDeleted(PCSRSS_PROCESS_DATA);
/* GLOBALS *******************************************************************/
@@ -157,7 +160,7 @@
{
DPRINT("CsrFreeProcessData pid: %d\n", Pid);
Process = pProcessData->Process;
- CsrReleaseConsole(pProcessData);
+ CallProcessDeleted(pProcessData);
if (pProcessData->CsrSectionViewBase)
{
NtUnmapViewOfSection(NtCurrentProcess(), pProcessData->CsrSectionViewBase);
@@ -205,7 +208,7 @@
NewProcessData->bInheritHandles =
Request->Data.CreateProcessRequest.bInheritHandles;
if (Request->Data.CreateProcessRequest.bInheritHandles)
{
- Status = CsrDuplicateHandleTable(ProcessData, NewProcessData);
+ Status = CallProcessInherit(ProcessData, NewProcessData);
}
}
@@ -343,134 +346,4 @@
return(STATUS_SUCCESS);
}
-CSR_API(CsrGetInputHandle)
-{
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- if (ProcessData->Console)
- {
- Request->Status = CsrInsertObject(ProcessData,
- &Request->Data.GetInputHandleRequest.InputHandle,
- (Object_t *)ProcessData->Console,
- Request->Data.GetInputHandleRequest.Access,
- Request->Data.GetInputHandleRequest.Inheritable);
- }
- else
- {
- Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE;
- Request->Status = STATUS_SUCCESS;
- }
-
- return Request->Status;
-}
-
-CSR_API(CsrGetOutputHandle)
-{
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- if (ProcessData->Console)
- {
- RtlEnterCriticalSection(&ProcessDataLock);
- Request->Status = CsrInsertObject(ProcessData,
-
&Request->Data.GetOutputHandleRequest.OutputHandle,
-
&ProcessData->Console->ActiveBuffer->Header,
- Request->Data.GetOutputHandleRequest.Access,
-
Request->Data.GetOutputHandleRequest.Inheritable);
- RtlLeaveCriticalSection(&ProcessDataLock);
- }
- else
- {
- Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE;
- Request->Status = STATUS_SUCCESS;
- }
-
- return Request->Status;
-}
-
-CSR_API(CsrCloseHandle)
-{
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- return CsrReleaseObject(ProcessData, Request->Data.CloseHandleRequest.Handle);
-}
-
-CSR_API(CsrVerifyHandle)
-{
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- Request->Status = CsrVerifyObject(ProcessData,
Request->Data.VerifyHandleRequest.Handle);
- if (!NT_SUCCESS(Request->Status))
- {
- DPRINT("CsrVerifyObject failed, status=%x\n", Request->Status);
- }
-
- return Request->Status;
-}
-
-CSR_API(CsrDuplicateHandle)
-{
- ULONG_PTR Index;
- PCSRSS_HANDLE Entry;
- DWORD DesiredAccess;
-
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
-
- Index = (ULONG_PTR)Request->Data.DuplicateHandleRequest.Handle >> 2;
- RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- if (Index >= ProcessData->HandleTableSize
- || (Entry = &ProcessData->HandleTable[Index])->Object == NULL)
- {
- DPRINT1("Couldn't dup invalid handle %p\n",
Request->Data.DuplicateHandleRequest.Handle);
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return STATUS_INVALID_HANDLE;
- }
-
- if (Request->Data.DuplicateHandleRequest.Options & DUPLICATE_SAME_ACCESS)
- {
- DesiredAccess = Entry->Access;
- }
- else
- {
- DesiredAccess = Request->Data.DuplicateHandleRequest.Access;
- /* Make sure the source handle has all the desired flags */
- if (~Entry->Access & DesiredAccess)
- {
- DPRINT1("Handle %p only has access %X; requested %X\n",
- Request->Data.DuplicateHandleRequest.Handle, Entry->Access,
DesiredAccess);
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return STATUS_INVALID_PARAMETER;
- }
- }
-
- Request->Status = CsrInsertObject(ProcessData,
-
&Request->Data.DuplicateHandleRequest.Handle,
- Entry->Object,
- DesiredAccess,
-
Request->Data.DuplicateHandleRequest.Inheritable);
- if (NT_SUCCESS(Request->Status)
- && Request->Data.DuplicateHandleRequest.Options &
DUPLICATE_CLOSE_SOURCE)
- {
- /* Close the original handle. This cannot drop the count to 0, since a new handle
now exists */
- _InterlockedDecrement(&Entry->Object->ReferenceCount);
- Entry->Object = NULL;
- }
-
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return Request->Status;
-}
-
-CSR_API(CsrGetInputWaitHandle)
-{
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- Request->Data.GetConsoleInputWaitHandle.InputWaitHandle =
ProcessData->ConsoleEvent;
- return STATUS_SUCCESS;
-}
-
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] Sun May 23
01:47:54 2010
@@ -10,7 +10,6 @@
<library>pseh</library>
<library>smdll</library>
<directory name="api">
- <file>handle.c</file>
<file>process.c</file>
<file>user.c</file>
<file>wapi.c</file>
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Sun May 23 01:47:54
2010
@@ -18,10 +18,8 @@
HANDLE CsrObjectDirectory = (HANDLE) 0;
UNICODE_STRING CsrDirectoryName;
extern HANDLE CsrssApiHeap;
-static unsigned InitCompleteProcCount;
-static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
-static unsigned HardErrorProcCount;
-static CSRPLUGIN_HARDERROR_PROC *HardErrorProcs = NULL;
+static unsigned ServerProcCount;
+static CSRPLUGIN_SERVER_PROCS *ServerProcs = NULL;
HANDLE hSbApiPort = (HANDLE) 0;
HANDLE hBootstrapOk = (HANDLE) 0;
HANDLE hSmApiPort = (HANDLE) 0;
@@ -124,58 +122,30 @@
static NTSTATUS FASTCALL
-CsrpAddInitCompleteProc(CSRPLUGIN_INIT_COMPLETE_PROC Proc)
-{
- CSRPLUGIN_INIT_COMPLETE_PROC *NewProcs;
+CsrpAddServerProcs(CSRPLUGIN_SERVER_PROCS *Procs)
+{
+ CSRPLUGIN_SERVER_PROCS *NewProcs;
DPRINT("CSR: %s called\n", __FUNCTION__);
NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
- (InitCompleteProcCount + 1)
- * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
+ (ServerProcCount + 1)
+ * sizeof(CSRPLUGIN_SERVER_PROCS));
if (NULL == NewProcs)
{
return STATUS_NO_MEMORY;
}
- if (0 != InitCompleteProcCount)
- {
- RtlCopyMemory(NewProcs, InitCompleteProcs,
- InitCompleteProcCount * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
- RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
- }
- NewProcs[InitCompleteProcCount] = Proc;
- InitCompleteProcs = NewProcs;
- InitCompleteProcCount++;
+ if (0 != ServerProcCount)
+ {
+ RtlCopyMemory(NewProcs, ServerProcs,
+ ServerProcCount * sizeof(CSRPLUGIN_SERVER_PROCS));
+ RtlFreeHeap(CsrssApiHeap, 0, ServerProcs);
+ }
+ NewProcs[ServerProcCount] = *Procs;
+ ServerProcs = NewProcs;
+ ServerProcCount++;
return STATUS_SUCCESS;
-}
-
-static NTSTATUS FASTCALL
-CsrpAddHardErrorProc(CSRPLUGIN_HARDERROR_PROC Proc)
-{
- CSRPLUGIN_HARDERROR_PROC *NewProcs;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
- (HardErrorProcCount + 1)
- * sizeof(CSRPLUGIN_HARDERROR_PROC));
- if (NULL == NewProcs)
- {
- return STATUS_NO_MEMORY;
- }
- if (0 != HardErrorProcCount)
- {
- RtlCopyMemory(NewProcs, HardErrorProcs,
- HardErrorProcCount * sizeof(CSRPLUGIN_HARDERROR_PROC));
- RtlFreeHeap(CsrssApiHeap, 0, HardErrorProcs);
- }
-
- NewProcs[HardErrorProcCount] = Proc;
- HardErrorProcs = NewProcs;
- HardErrorProcCount++;
-
- return STATUS_SUCCESS;
}
/**********************************************************************
@@ -190,13 +160,9 @@
DPRINT("CSR: %s called\n", __FUNCTION__);
Ok = TRUE;
- if (0 != InitCompleteProcCount)
- {
- for (i = 0; i < InitCompleteProcCount && Ok; i++)
- {
- Ok = (*(InitCompleteProcs[i]))();
- }
- RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
+ for (i = 0; i < ServerProcCount && Ok; i++)
+ {
+ Ok = (*ServerProcs[i].InitCompleteProc)();
}
return Ok;
@@ -212,16 +178,43 @@
DPRINT("CSR: %s called\n", __FUNCTION__);
Ok = TRUE;
- if (0 != HardErrorProcCount)
- {
- for (i = 0; i < HardErrorProcCount && Ok; i++)
- {
- Ok = (*(HardErrorProcs[i]))(ProcessData, HardErrorMessage);
- }
+ for (i = 0; i < ServerProcCount && Ok; i++)
+ {
+ Ok = (*ServerProcs[i].HardErrorProc)(ProcessData, HardErrorMessage);
}
return Ok;
}
+
+NTSTATUS
+CallProcessInherit(IN PCSRSS_PROCESS_DATA SourceProcessData,
+ IN PCSRSS_PROCESS_DATA TargetProcessData)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ unsigned i;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ for (i = 0; i < ServerProcCount && NT_SUCCESS(Status); i++)
+ Status = (*ServerProcs[i].ProcessInheritProc)(SourceProcessData,
TargetProcessData);
+
+ return Status;
+}
+
+NTSTATUS
+CallProcessDeleted(IN PCSRSS_PROCESS_DATA ProcessData)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ unsigned i;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ for (i = 0; i < ServerProcCount && NT_SUCCESS(Status); i++)
+ Status = (*ServerProcs[i].ProcessDeletedProc)(ProcessData);
+
+ return Status;
+}
+
ULONG
InitializeVideoAddressSpace(VOID);
@@ -313,9 +306,7 @@
CSRPLUGIN_INITIALIZE_PROC InitProc;
CSRSS_EXPORTED_FUNCS Exports;
PCSRSS_API_DEFINITION ApiDefinitions;
- PCSRSS_OBJECT_DEFINITION ObjectDefinitions;
- CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
- CSRPLUGIN_HARDERROR_PROC HardErrorProc;
+ CSRPLUGIN_SERVER_PROCS ServerProcs;
DPRINT("CSR: %s called\n", __FUNCTION__);
@@ -331,14 +322,8 @@
{
return Status;
}
- Exports.CsrInsertObjectProc = CsrInsertObject;
- Exports.CsrGetObjectProc = CsrGetObject;
- Exports.CsrReleaseObjectByPointerProc = CsrReleaseObjectByPointer;
- Exports.CsrReleaseObjectProc = CsrReleaseObject;
- Exports.CsrReleaseConsoleProc = CsrReleaseConsole;
Exports.CsrEnumProcessesProc = CsrEnumProcesses;
- if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
- &HardErrorProc, &Exports, CsrssApiHeap))
+ if (! (*InitProc)(&ApiDefinitions, &ServerProcs, &Exports, CsrssApiHeap))
{
return STATUS_UNSUCCESSFUL;
}
@@ -348,17 +333,7 @@
{
return Status;
}
- Status = CsrRegisterObjectDefinitions(ObjectDefinitions);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- if (NULL != InitCompleteProc)
- {
- Status = CsrpAddInitCompleteProc(InitCompleteProc);
- }
- if (HardErrorProc) Status = CsrpAddHardErrorProc(HardErrorProc);
-
+ Status = CsrpAddServerProcs(&ServerProcs);
return Status;
}
@@ -371,12 +346,6 @@
CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, CsrRegisterServicesProcess),
CSRSS_DEFINE_API(GET_SHUTDOWN_PARAMETERS, CsrGetShutdownParameters),
CSRSS_DEFINE_API(SET_SHUTDOWN_PARAMETERS, CsrSetShutdownParameters),
- CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle),
- CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle),
- CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle),
- CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle),
- CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle),
- CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
{ 0, 0, NULL }
};
Modified: trunk/reactos/subsystems/win32/csrss/include/api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Sun May 23 01:47:54
2010
@@ -71,8 +71,8 @@
typedef struct _CSRSS_PROCESS_DATA
{
- PCSRSS_CONSOLE Console;
- PCSRSS_CONSOLE ParentConsole;
+ struct tagCSRSS_CONSOLE *Console;
+ struct tagCSRSS_CONSOLE *ParentConsole;
BOOL bInheritHandles;
RTL_CRITICAL_SECTION HandleTableLock;
ULONG HandleTableSize;
Removed: trunk/reactos/subsystems/win32/csrss/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/conio.h (removed)
@@ -1,181 +1,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: subsys/csrss/include/conio.h
- * PURPOSE: CSRSS internal console I/O interface
- */
-
-#pragma once
-
-#include "api.h"
-#include "win32csr.h"
-
-#define CSR_DEFAULT_CURSOR_SIZE 25
-
-/* Object type magic numbers */
-
-#define CONIO_CONSOLE_MAGIC 0x00000001
-#define CONIO_SCREEN_BUFFER_MAGIC 0x00000002
-
-/************************************************************************
- * Screen buffer structure represents the win32 screen buffer object. *
- * Internally, the portion of the buffer being shown CAN loop past the *
- * bottom of the virtual buffer and wrap around to the top. Win32 does *
- * not do this. I decided to do this because it eliminates the need to *
- * do a massive memcpy() to scroll the contents of the buffer up to *
- * scroll the screen on output, instead I just shift down the position *
- * to be displayed, and let it wrap around to the top again. *
- * The VirtualY member keeps track of the top Y coord that win32 *
- * clients THINK is currently being displayed, because they think that *
- * when the display reaches the bottom of the buffer and another line *
- * being printed causes another line to scroll down, that the buffer IS *
- * memcpy()'s up, and the bottom of the buffer is still displayed, but *
- * internally, I just wrap back to the top of the buffer. *
- ***********************************************************************/
-
-typedef struct tagCSRSS_SCREEN_BUFFER
-{
- Object_t Header; /* Object header */
- BYTE *Buffer; /* pointer to screen buffer */
- USHORT MaxX, MaxY; /* size of the entire scrollback buffer */
- USHORT ShowX, ShowY; /* beginning offset for the actual display area */
- ULONG CurrentX; /* Current X cursor position */
- ULONG CurrentY; /* Current Y cursor position */
- WORD DefaultAttrib; /* default char attribute */
- USHORT VirtualY; /* top row of buffer being displayed, reported to
callers */
- CONSOLE_CURSOR_INFO CursorInfo;
- USHORT Mode;
-} CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
-
-typedef struct tagCSRSS_CONSOLE_VTBL
-{
- VOID (WINAPI *InitScreenBuffer)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER
ScreenBuffer);
- VOID (WINAPI *WriteStream)(PCSRSS_CONSOLE Console, RECT *Block, LONG CursorStartX, LONG
CursorStartY,
- UINT ScrolledLines, CHAR *Buffer, UINT Length);
- VOID (WINAPI *DrawRegion)(PCSRSS_CONSOLE Console, RECT *Region);
- BOOL (WINAPI *SetCursorInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER
ScreenBuffer);
- BOOL (WINAPI *SetScreenInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER
ScreenBuffer,
- UINT OldCursorX, UINT OldCursorY);
- BOOL (WINAPI *UpdateScreenInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER
ScreenBuffer);
- BOOL (WINAPI *ChangeTitle)(PCSRSS_CONSOLE Console);
- VOID (WINAPI *CleanupConsole)(PCSRSS_CONSOLE Console);
- BOOL (WINAPI *ChangeIcon)(PCSRSS_CONSOLE Console, HICON hWindowIcon);
- NTSTATUS (WINAPI *ResizeBuffer)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER
ScreenBuffer, COORD Size);
-} CSRSS_CONSOLE_VTBL, *PCSRSS_CONSOLE_VTBL;
-
-typedef struct tagCSRSS_CONSOLE
-{
- Object_t Header; /* Object header */
- PCSRSS_CONSOLE Prev, Next; /* Next and Prev consoles in console wheel */
- HANDLE ActiveEvent;
- LIST_ENTRY InputEvents; /* List head for input event queue */
- WORD WaitingChars;
- WORD WaitingLines; /* number of chars and lines in input queue */
- PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
- WORD Mode; /* Console mode flags */
- WORD EchoCount; /* count of chars to echo, in line buffered mode
*/
- UNICODE_STRING Title; /* Title of console */
- BOOL EarlyReturn; /* wake client and return data, even if we are in
line buffered mode, and we don't have a complete line */
- DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
- HWND hWindow;
- COORD Size;
- PVOID PrivateData;
- UINT CodePage;
- UINT OutputCodePage;
- PCSRSS_CONSOLE_VTBL Vtbl;
- LIST_ENTRY ProcessList;
- struct tagALIAS_HEADER *Aliases;
-} CSRSS_CONSOLE;
-
-NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData,
PCSRSS_CONSOLE *Console);
-VOID WINAPI ConioDeleteConsole(Object_t *Object);
-VOID WINAPI ConioDeleteScreenBuffer(Object_t *Buffer);
-void WINAPI ConioProcessKey(MSG *msg, PCSRSS_CONSOLE Console, BOOL TextMode);
-PBYTE FASTCALL ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buf, ULONG X, ULONG Y);
-VOID FASTCALL ConioDrawConsole(PCSRSS_CONSOLE Console);
-VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCSRSS_PROCESS_DATA ProcessData);
-VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSRSS_PROCESS_DATA ProcessData,
- DWORD Timeout);
-
-/* api/conio.c */
-CSR_API(CsrWriteConsole);
-CSR_API(CsrAllocConsole);
-CSR_API(CsrFreeConsole);
-CSR_API(CsrReadConsole);
-CSR_API(CsrConnectProcess);
-CSR_API(CsrGetScreenBufferInfo);
-CSR_API(CsrSetCursor);
-CSR_API(CsrFillOutputChar);
-CSR_API(CsrReadInputEvent);
-CSR_API(CsrWriteConsoleOutputChar);
-CSR_API(CsrWriteConsoleOutputAttrib);
-CSR_API(CsrFillOutputAttrib);
-CSR_API(CsrGetCursorInfo);
-CSR_API(CsrSetCursorInfo);
-CSR_API(CsrSetTextAttrib);
-CSR_API(CsrSetConsoleMode);
-CSR_API(CsrGetConsoleMode);
-CSR_API(CsrCreateScreenBuffer);
-CSR_API(CsrSetScreenBuffer);
-CSR_API(CsrSetTitle);
-CSR_API(CsrGetTitle);
-CSR_API(CsrWriteConsoleOutput);
-CSR_API(CsrFlushInputBuffer);
-CSR_API(CsrScrollConsoleScreenBuffer);
-CSR_API(CsrReadConsoleOutputChar);
-CSR_API(CsrReadConsoleOutputAttrib);
-CSR_API(CsrGetNumberOfConsoleInputEvents);
-CSR_API(CsrPeekConsoleInput);
-CSR_API(CsrReadConsoleOutput);
-CSR_API(CsrWriteConsoleInput);
-CSR_API(CsrHardwareStateProperty);
-CSR_API(CsrGetConsoleWindow);
-CSR_API(CsrSetConsoleIcon);
-CSR_API(CsrGetConsoleCodePage);
-CSR_API(CsrSetConsoleCodePage);
-CSR_API(CsrGetConsoleOutputCodePage);
-CSR_API(CsrSetConsoleOutputCodePage);
-CSR_API(CsrGetProcessList);
-CSR_API(CsrGenerateCtrlEvent);
-CSR_API(CsrSetScreenBufferSize);
-
-#define ConioInitScreenBuffer(Console, Buff)
(Console)->Vtbl->InitScreenBuffer((Console), (Buff))
-#define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console),
(Region))
-#define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer,
Length) \
- (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX),
(CurStartY), \
- (ScrolledLines), (Buffer), (Length))
-#define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console),
(Buff))
-#define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
- (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX),
(OldCursorY))
-#define ConioUpdateScreenInfo(Console, Buff) \
- (Console)->Vtbl->UpdateScreenInfo(Console, Buff)
-#define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
-#define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
-#define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon(Console,
hWindowIcon)
-#define ConioResizeBuffer(Console, Buff, Size)
(Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
-
-#define ConioRectHeight(Rect) \
- (((Rect)->top) > ((Rect)->bottom) ? 0 : ((Rect)->bottom) -
((Rect)->top) + 1)
-#define ConioRectWidth(Rect) \
- (((Rect)->left) > ((Rect)->right) ? 0 : ((Rect)->right) -
((Rect)->left) + 1)
-
-#define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
- Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access,
CONIO_CONSOLE_MAGIC)
-#define ConioUnlockConsole(Console) \
- Win32CsrUnlockObject((Object_t *) Console)
-#define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
- Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access,
CONIO_SCREEN_BUFFER_MAGIC)
-#define ConioUnlockScreenBuffer(Buff) \
- Win32CsrUnlockObject((Object_t *) Buff)
-
-/* alias.c */
-VOID IntDeleteAllAliases(struct tagALIAS_HEADER *RootHeader);
-CSR_API(CsrAddConsoleAlias);
-CSR_API(CsrGetConsoleAlias);
-CSR_API(CsrGetAllConsoleAliases);
-CSR_API(CsrGetAllConsoleAliasesLength);
-CSR_API(CsrGetConsoleAliasesExes);
-CSR_API(CsrGetConsoleAliasesExesLength);
-
-/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/csrplugin.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/csrplugin.h [iso-8859-1] Sun May 23
01:47:54 2010
@@ -21,29 +21,11 @@
#include <windows.h>
#include "api.h"
-typedef NTSTATUS (WINAPI *CSRSS_INSERT_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessData,
- PHANDLE Handle,
- Object_t *Object,
- DWORD Access,
- BOOL Inheritable);
-typedef NTSTATUS (WINAPI *CSRSS_GET_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle,
- Object_t **Object,
- DWORD Access);
-typedef NTSTATUS (WINAPI *CSRSS_RELEASE_OBJECT_BY_POINTER_PROC)(Object_t *Object);
-typedef NTSTATUS (WINAPI *CSRSS_RELEASE_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Object );
-typedef NTSTATUS (WINAPI *CSRSS_RELEASE_CONSOLE_PROC)(PCSRSS_PROCESS_DATA ProcessData);
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc,
PVOID Context);
typedef struct tagCSRSS_EXPORTED_FUNCS
{
- CSRSS_INSERT_OBJECT_PROC CsrInsertObjectProc;
- CSRSS_GET_OBJECT_PROC CsrGetObjectProc;
- CSRSS_RELEASE_OBJECT_BY_POINTER_PROC CsrReleaseObjectByPointerProc;
- CSRSS_RELEASE_OBJECT_PROC CsrReleaseObjectProc;
- CSRSS_RELEASE_CONSOLE_PROC CsrReleaseConsoleProc;
CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc;
} CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS;
@@ -52,10 +34,21 @@
typedef BOOL (WINAPI *CSRPLUGIN_HARDERROR_PROC)(IN PCSRSS_PROCESS_DATA ProcessData,
IN PHARDERROR_MSG HardErrorMessage);
+typedef NTSTATUS (WINAPI *CSRPLUGIN_PROCESS_INHERIT_PROC)(IN PCSRSS_PROCESS_DATA
SourceProcessData,
+ IN PCSRSS_PROCESS_DATA
TargetProcessData);
+
+typedef NTSTATUS (WINAPI *CSRPLUGIN_PROCESS_DELETED_PROC)(IN PCSRSS_PROCESS_DATA
ProcessData);
+
+typedef struct tagCSRSS_SERVER_PROCS
+{
+ CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
+ CSRPLUGIN_HARDERROR_PROC HardErrorProc;
+ CSRPLUGIN_PROCESS_INHERIT_PROC ProcessInheritProc;
+ CSRPLUGIN_PROCESS_DELETED_PROC ProcessDeletedProc;
+} CSRPLUGIN_SERVER_PROCS, *PCSRPLUGIN_SERVER_PROCS;
+
typedef BOOL (WINAPI *CSRPLUGIN_INITIALIZE_PROC)(PCSRSS_API_DEFINITION *ApiDefinitions,
- PCSRSS_OBJECT_DEFINITION
*ObjectDefinitions,
- CSRPLUGIN_INIT_COMPLETE_PROC
*InitCompleteProc,
- CSRPLUGIN_HARDERROR_PROC
*HardErrorProc,
+ PCSRPLUGIN_SERVER_PROCS ServerProcs,
PCSRSS_EXPORTED_FUNCS Exports,
HANDLE CsrssApiHeap);
Removed: trunk/reactos/subsystems/win32/csrss/include/win32csr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/win32csr.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/win32csr.h (removed)
@@ -1,40 +1,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: subsys/csrss/win32csr/win32csr.h
- * PURPOSE: Interface to win32csr.dll
- */
-
-#pragma once
-
-#include <windows.h>
-#include <commctrl.h>
-
-extern HANDLE Win32CsrApiHeap;
-extern HINSTANCE Win32CsrDllHandle;
-
-NTSTATUS FASTCALL Win32CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData,
- PHANDLE Handle,
- Object_t *Object,
- DWORD Access,
- BOOL Inheritable);
-NTSTATUS FASTCALL Win32CsrLockObject(PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle,
- Object_t **Object,
- DWORD Access,
- long Type);
-VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
-
-NTSTATUS FASTCALL Win32CsrGetObject(PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Handle,
- Object_t **Object,
- DWORD Access);
-NTSTATUS FASTCALL Win32CsrReleaseObjectByPointer(Object_t *Object);
-NTSTATUS FASTCALL Win32CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
- HANDLE Object);
-NTSTATUS FASTCALL Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData);
-NTSTATUS FASTCALL Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
- PVOID Context);
-
-/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sun May 23
01:47:54 2010
@@ -24,6 +24,12 @@
static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
{
+ CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle),
+ CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle),
+ CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle),
+ CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle),
+ CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle),
+ CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
CSRSS_DEFINE_API(WRITE_CONSOLE, CsrWriteConsole),
CSRSS_DEFINE_API(READ_CONSOLE, CsrReadConsole),
CSRSS_DEFINE_API(ALLOC_CONSOLE, CsrAllocConsole),
@@ -108,7 +114,7 @@
DWORD Access,
BOOL Inheritable)
{
- return (CsrExports.CsrInsertObjectProc)(ProcessData, Handle, Object, Access,
Inheritable);
+ return CsrInsertObject(ProcessData, Handle, Object, Access, Inheritable);
}
NTSTATUS FASTCALL
@@ -117,7 +123,7 @@
Object_t **Object,
DWORD Access)
{
- return (CsrExports.CsrGetObjectProc)(ProcessData, Handle, Object, Access);
+ return CsrGetObject(ProcessData, Handle, Object, Access);
}
NTSTATUS FASTCALL
@@ -129,7 +135,7 @@
{
NTSTATUS Status;
- Status = (CsrExports.CsrGetObjectProc)(ProcessData, Handle, Object, Access);
+ Status = CsrGetObject(ProcessData, Handle, Object, Access);
if (! NT_SUCCESS(Status))
{
return Status;
@@ -137,7 +143,7 @@
if ((*Object)->Type != Type)
{
- (CsrExports.CsrReleaseObjectByPointerProc)(*Object);
+ CsrReleaseObjectByPointer(*Object);
return STATUS_INVALID_HANDLE;
}
@@ -150,26 +156,26 @@
Win32CsrUnlockObject(Object_t *Object)
{
LeaveCriticalSection(&(Object->Lock));
- (CsrExports.CsrReleaseObjectByPointerProc)(Object);
+ CsrReleaseObjectByPointer(Object);
}
NTSTATUS FASTCALL
Win32CsrReleaseObjectByPointer(Object_t *Object)
{
- return (CsrExports.CsrReleaseObjectByPointerProc)(Object);
+ return CsrReleaseObjectByPointer(Object);
}
NTSTATUS FASTCALL
Win32CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
HANDLE Object)
{
- return (CsrExports.CsrReleaseObjectProc)(ProcessData, Object);
+ return CsrReleaseObject(ProcessData, Object);
}
NTSTATUS FASTCALL
Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData)
{
- return (CsrExports.CsrReleaseConsoleProc)(ProcessData);
+ return CsrReleaseConsole(ProcessData);
}
NTSTATUS FASTCALL
@@ -189,9 +195,7 @@
BOOL WINAPI
Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
- PCSRSS_OBJECT_DEFINITION *ObjectDefinitions,
- CSRPLUGIN_INIT_COMPLETE_PROC *InitComplete,
- CSRPLUGIN_HARDERROR_PROC *HardError,
+ PCSRPLUGIN_SERVER_PROCS ServerProcs,
PCSRSS_EXPORTED_FUNCS Exports,
HANDLE CsrssApiHeap)
{
@@ -203,11 +207,13 @@
PrivateCsrssManualGuiCheck(0);
CsrInitConsoleSupport();
+ CsrRegisterObjectDefinitions(Win32CsrObjectDefinitions);
*ApiDefinitions = Win32CsrApiDefinitions;
- *ObjectDefinitions = Win32CsrObjectDefinitions;
- *InitComplete = Win32CsrInitComplete;
- *HardError = Win32CsrHardError;
+ ServerProcs->InitCompleteProc = Win32CsrInitComplete;
+ ServerProcs->HardErrorProc = Win32CsrHardError;
+ ServerProcs->ProcessInheritProc = CsrDuplicateHandleTable;
+ ServerProcs->ProcessDeletedProc = CsrReleaseConsole;
return TRUE;
}
Copied: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c (from r47313,
trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Sun May 23
01:47:54 2010
@@ -9,7 +9,7 @@
/* INCLUDES ******************************************************************/
-#include <srv.h>
+#include <w32csr.h>
#define NDEBUG
#include <debug.h>
@@ -42,7 +42,7 @@
NewCount++;
}
- New = RtlAllocateHeap(CsrssApiHeap,
+ New = RtlAllocateHeap(Win32CsrApiHeap,
0,
(ObjectDefinitionsCount + NewCount)
* sizeof(CSRSS_OBJECT_DEFINITION));
@@ -57,7 +57,7 @@
RtlCopyMemory(New,
ObjectDefinitions,
ObjectDefinitionsCount * sizeof(CSRSS_OBJECT_DEFINITION));
- RtlFreeHeap(CsrssApiHeap, 0, ObjectDefinitions);
+ RtlFreeHeap(Win32CsrApiHeap, 0, ObjectDefinitions);
}
RtlCopyMemory(New + ObjectDefinitionsCount,
@@ -171,7 +171,7 @@
if (HandleTable[i].Object != NULL)
CsrReleaseObjectByPointer(HandleTable[i].Object);
}
- RtlFreeHeap(CsrssApiHeap, 0, HandleTable);
+ RtlFreeHeap(Win32CsrApiHeap, 0, HandleTable);
if (Console != NULL)
{
@@ -208,7 +208,7 @@
}
if (i >= ProcessData->HandleTableSize)
{
- Block = RtlAllocateHeap(CsrssApiHeap,
+ Block = RtlAllocateHeap(Win32CsrApiHeap,
HEAP_ZERO_MEMORY,
(ProcessData->HandleTableSize + 64) *
sizeof(CSRSS_HANDLE));
if (Block == NULL)
@@ -220,7 +220,7 @@
ProcessData->HandleTable,
ProcessData->HandleTableSize * sizeof(CSRSS_HANDLE));
Block = _InterlockedExchangePointer((void*
volatile)&ProcessData->HandleTable, Block);
- RtlFreeHeap( CsrssApiHeap, 0, Block );
+ RtlFreeHeap( Win32CsrApiHeap, 0, Block );
ProcessData->HandleTableSize += 64;
}
ProcessData->HandleTable[i].Object = Object;
@@ -249,7 +249,7 @@
/* we are called from CreateProcessData, it isn't necessary to lock the target
process data */
- TargetProcessData->HandleTable = RtlAllocateHeap(CsrssApiHeap,
+ TargetProcessData->HandleTable = RtlAllocateHeap(Win32CsrApiHeap,
HEAP_ZERO_MEMORY,
SourceProcessData->HandleTableSize
* sizeof(CSRSS_HANDLE));
@@ -289,4 +289,132 @@
return STATUS_SUCCESS;
}
+CSR_API(CsrGetInputHandle)
+{
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ if (ProcessData->Console)
+ {
+ Request->Status = CsrInsertObject(ProcessData,
+
&Request->Data.GetInputHandleRequest.InputHandle,
+ (Object_t *)ProcessData->Console,
+ Request->Data.GetInputHandleRequest.Access,
+
Request->Data.GetInputHandleRequest.Inheritable);
+ }
+ else
+ {
+ Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE;
+ Request->Status = STATUS_SUCCESS;
+ }
+
+ return Request->Status;
+}
+
+CSR_API(CsrGetOutputHandle)
+{
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ if (ProcessData->Console)
+ {
+ Request->Status = CsrInsertObject(ProcessData,
+
&Request->Data.GetOutputHandleRequest.OutputHandle,
+
&ProcessData->Console->ActiveBuffer->Header,
+
Request->Data.GetOutputHandleRequest.Access,
+
Request->Data.GetOutputHandleRequest.Inheritable);
+ }
+ else
+ {
+ Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE;
+ Request->Status = STATUS_SUCCESS;
+ }
+
+ return Request->Status;
+}
+
+CSR_API(CsrCloseHandle)
+{
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ return CsrReleaseObject(ProcessData, Request->Data.CloseHandleRequest.Handle);
+}
+
+CSR_API(CsrVerifyHandle)
+{
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ Request->Status = CsrVerifyObject(ProcessData,
Request->Data.VerifyHandleRequest.Handle);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ DPRINT("CsrVerifyObject failed, status=%x\n", Request->Status);
+ }
+
+ return Request->Status;
+}
+
+CSR_API(CsrDuplicateHandle)
+{
+ ULONG_PTR Index;
+ PCSRSS_HANDLE Entry;
+ DWORD DesiredAccess;
+
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ Index = (ULONG_PTR)Request->Data.DuplicateHandleRequest.Handle >> 2;
+ RtlEnterCriticalSection(&ProcessData->HandleTableLock);
+ if (Index >= ProcessData->HandleTableSize
+ || (Entry = &ProcessData->HandleTable[Index])->Object == NULL)
+ {
+ DPRINT1("Couldn't dup invalid handle %p\n",
Request->Data.DuplicateHandleRequest.Handle);
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+ return STATUS_INVALID_HANDLE;
+ }
+
+ if (Request->Data.DuplicateHandleRequest.Options & DUPLICATE_SAME_ACCESS)
+ {
+ DesiredAccess = Entry->Access;
+ }
+ else
+ {
+ DesiredAccess = Request->Data.DuplicateHandleRequest.Access;
+ /* Make sure the source handle has all the desired flags */
+ if (~Entry->Access & DesiredAccess)
+ {
+ DPRINT1("Handle %p only has access %X; requested %X\n",
+ Request->Data.DuplicateHandleRequest.Handle, Entry->Access,
DesiredAccess);
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+ return STATUS_INVALID_PARAMETER;
+ }
+ }
+
+ Request->Status = CsrInsertObject(ProcessData,
+
&Request->Data.DuplicateHandleRequest.Handle,
+ Entry->Object,
+ DesiredAccess,
+
Request->Data.DuplicateHandleRequest.Inheritable);
+ if (NT_SUCCESS(Request->Status)
+ && Request->Data.DuplicateHandleRequest.Options &
DUPLICATE_CLOSE_SOURCE)
+ {
+ /* Close the original handle. This cannot drop the count to 0, since a new handle
now exists */
+ _InterlockedDecrement(&Entry->Object->ReferenceCount);
+ Entry->Object = NULL;
+ }
+
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+ return Request->Status;
+}
+
+CSR_API(CsrGetInputWaitHandle)
+{
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
+
+ Request->Data.GetConsoleInputWaitHandle.InputWaitHandle =
ProcessData->ConsoleEvent;
+ return STATUS_SUCCESS;
+}
+
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] Sun May 23
01:47:54 2010
@@ -22,6 +22,7 @@
<file>dllmain.c</file>
<file>exitros.c</file>
<file>guiconsole.c</file>
+ <file>handle.c</file>
<file>harderror.c</file>
<file>tuiconsole.c</file>
<file>appswitch.c</file>
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.spec [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.spec [iso-8859-1] Sun May 23
01:47:54 2010
@@ -1,1 +1,1 @@
-@ stdcall Win32CsrInitialization(ptr ptr ptr ptr ptr ptr)
+@ stdcall Win32CsrInitialization(ptr ptr ptr ptr)