CSR Reloaded... well, split. - almost do-nothing base source code for new CSR server DLLs host - base source code for the core CSR server DLL 'csrsrv.dll' (server 0) - base source code for the base WIN server DLL 'basesrv.dll' (server 1) - base source code for the console+user WIN server DLL 'winsrv.dll' (servers 3 and 2)
NOTES - At present, nothing works, but compilation is OK, sorry. - The program is temporarily named 'csr.exe' to coexist with current monolithic 'csrss.exe'. - Code, hints, suggestions, and migration plans welcome! (post 0.3) Added: trunk/reactos/subsys/csr/ Added: trunk/reactos/subsys/csr/args.c Added: trunk/reactos/subsys/csr/csr.h Added: trunk/reactos/subsys/csr/csr.rc Added: trunk/reactos/subsys/csr/csr.xml Added: trunk/reactos/subsys/csr/csrsrv/ Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.def Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.rc Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.xml Added: trunk/reactos/subsys/csr/csrsrv/debug.c Added: trunk/reactos/subsys/csr/csrsrv/dllmain.c Added: trunk/reactos/subsys/csr/csrsrv/init.c Added: trunk/reactos/subsys/csr/csrsrv/process.c Added: trunk/reactos/subsys/csr/csrsrv/server.c Added: trunk/reactos/subsys/csr/csrsrv/session.c Added: trunk/reactos/subsys/csr/csrsrv/srv.h Added: trunk/reactos/subsys/csr/csrsrv/thread.c Added: trunk/reactos/subsys/csr/csrsrv/wait.c Added: trunk/reactos/subsys/csr/main.c Added: trunk/reactos/subsys/win/ Added: trunk/reactos/subsys/win/basesrv/ Added: trunk/reactos/subsys/win/basesrv/basesrv.def Added: trunk/reactos/subsys/win/basesrv/basesrv.h Added: trunk/reactos/subsys/win/basesrv/basesrv.rc Added: trunk/reactos/subsys/win/basesrv/basesrv.xml Added: trunk/reactos/subsys/win/basesrv/init.c Added: trunk/reactos/subsys/win/basesrv/main.c Added: trunk/reactos/subsys/win/basesrv/server.c Added: trunk/reactos/subsys/win/directory.xml Added: trunk/reactos/subsys/win/winsrv/ Added: trunk/reactos/subsys/win/winsrv/dllmain.c Added: trunk/reactos/subsys/win/winsrv/init.c Added: trunk/reactos/subsys/win/winsrv/server.c Added: trunk/reactos/subsys/win/winsrv/winsrv.def Added: trunk/reactos/subsys/win/winsrv/winsrv.h Added: trunk/reactos/subsys/win/winsrv/winsrv.rc Added: trunk/reactos/subsys/win/winsrv/winsrv.xml _____
Added: trunk/reactos/subsys/csr/args.c --- trunk/reactos/subsys/csr/args.c 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/args.c 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,126 @@
+/* $Id$ + * + * args.c - Client/Server Runtime - command line parsing + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "csr.h" + +#define NDEBUG +#include <debug.h> + +/********************************************************************** + * NAME PRIVATE + * CsrParseCommandLine/2 + */ +NTSTATUS FASTCALL CsrParseCommandLine (PPEB Peb, + PCOMMAND_LINE_ARGUMENT Argument) +{ + HANDLE ProcessHeap = Peb->ProcessHeap; + PRTL_USER_PROCESS_PARAMETERS RtlProcessParameters = RtlNormalizeProcessParams (Peb->ProcessParameters); + INT i = 0; + INT afterlastspace = 0; + + + DPRINT("CSR: %s called\n", __FUNCTION__); + + RtlZeroMemory (Argument, sizeof (COMMAND_LINE_ARGUMENT)); + + Argument->Vector = (PWSTR *) RtlAllocateHeap (ProcessHeap, + 0, + (CSRP_MAX_ARGUMENT_COUNT * sizeof Argument->Vector[0])); + if(NULL == Argument->Vector) + { + DPRINT("CSR: %s: no memory for Argument->Vector\n", __FUNCTION__); + return STATUS_NO_MEMORY; + } + + Argument->Buffer.Length = + Argument->Buffer.MaximumLength = + RtlProcessParameters->CommandLine.Length + + sizeof Argument->Buffer.Buffer [0]; /* zero terminated */ + Argument->Buffer.Buffer = + (PWSTR) RtlAllocateHeap (ProcessHeap, + 0, + Argument->Buffer.MaximumLength); + if(NULL == Argument->Buffer.Buffer) + { + DPRINT("CSR: %s: no memory for Argument->Buffer.Buffer\n", __FUNCTION__); + return STATUS_NO_MEMORY; + } + + RtlCopyMemory (Argument->Buffer.Buffer, + RtlProcessParameters->CommandLine.Buffer, + RtlProcessParameters->CommandLine.Length); + + while (Argument->Buffer.Buffer [i]) + { + if (Argument->Buffer.Buffer[i] == L' ') + { + Argument->Count ++; + Argument->Buffer.Buffer [i] = L'\0'; + Argument->Vector [Argument->Count - 1] = & (Argument->Buffer.Buffer [afterlastspace]); + i++; + while (Argument->Buffer.Buffer [i] == L' ') + { + i++; + } + afterlastspace = i; + } + else + { + i++; + } + } + + if (Argument->Buffer.Buffer [afterlastspace] != L'\0') + { + Argument->Count ++; + Argument->Buffer.Buffer [i] = L'\0'; + Argument->Vector [Argument->Count - 1] = & (Argument->Buffer.Buffer [afterlastspace]); + } +#if !defined(NDEBUG) + for (i=0; i<Argument->Count; i++) + { + DPRINT("CSR: Argument[%d] = '%S'\n", i, Argument->Vector [i]); + } +#endif + return STATUS_SUCCESS; +} +/********************************************************************** + * NAME PRIVATE + * CsrFreeCommandLine/2 + */ + +VOID FASTCALL CsrFreeCommandLine (PPEB Peb, + PCOMMAND_LINE_ARGUMENT Argument) +{ + DPRINT("CSR: %s called\n", __FUNCTION__); + + RtlFreeHeap (Peb->ProcessHeap, + 0, + Argument->Vector); + RtlFreeHeap (Peb->ProcessHeap, + 0, + Argument->Buffer.Buffer); +} +/* EOF */ Property changes on: trunk/reactos/subsys/csr/args.c ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csr.h --- trunk/reactos/subsys/csr/csr.h 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csr.h 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,34 @@
+#if !defined(_INCLUDE_CSR_H) +#define _INCLUDE_CSR_H + +/* PSDK/NDK Headers */ +#include <stdio.h> +#include <windows.h> + +#define NTOS_MODE_USER +#include <ndk/ntndk.h> + +#include <csr/server.h> + + +#define CSRSS_ARGUMENT_SIZE 16 + +/* args.c */ +#define CSRP_MAX_ARGUMENT_COUNT 512 + +typedef struct _COMMAND_LINE_ARGUMENT +{ + ULONG Count; + UNICODE_STRING Buffer; + PWSTR * Vector; + +} COMMAND_LINE_ARGUMENT, *PCOMMAND_LINE_ARGUMENT; + +NTSTATUS FASTCALL CsrParseCommandLine (PPEB,PCOMMAND_LINE_ARGUMENT); +VOID FASTCALL CsrFreeCommandLine (PPEB,PCOMMAND_LINE_ARGUMENT); + +/* csrsrv.dll */ +NTSTATUS STDCALL CsrServerInitialization (ULONG,LPWSTR*); + +#endif /* !def _INCLUDE_CSR_H */ + Property changes on: trunk/reactos/subsys/csr/csr.h ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csr.rc --- trunk/reactos/subsys/csr/csr.rc 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csr.rc 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,4 @@
+#define REACTOS_STR_FILE_DESCRIPTION "Client/Server Runtime Process\0" +#define REACTOS_STR_INTERNAL_NAME "csrss\0" +#define REACTOS_STR_ORIGINAL_FILENAME "csrss.exe\0" +#include <reactos/version.rc> Property changes on: trunk/reactos/subsys/csr/csr.rc ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csr.xml --- trunk/reactos/subsys/csr/csr.xml 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csr.xml 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,14 @@
+<module name="csr" type="nativecui" installbase="system32" installname="csr.exe"> + <include base="csr">.</include> + <define name="__USE_W32API" /> + <define name="_WIN32_WINNT">0x0600</define> + <define name="WINVER">0x0501</define> + <library>ntdll</library> + <library>csrsrv</library> + <file>main.c</file> + <file>args.c</file> + <file>csr.rc</file> +</module> +<directory name="csrsrv"> + <xi:include href="csrsrv/csrsrv.xml" /> +</directory> Property changes on: trunk/reactos/subsys/csr/csr.xml ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.def --- trunk/reactos/subsys/csr/csrsrv/csrsrv.def 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/csrsrv.def 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,37 @@
+; $Id$ +LIBRARY csrsrv.dll +EXPORTS +CsrAddStaticServerThread@4 +CsrCallServerFromServer@0 +CsrCreateProcess@8 +CsrCreateRemoteThread@0 +CsrCreateThread@8 +CsrCreateWait@8 +CsrDebugProcess@4 +CsrDebugProcessStop@4 +CsrDereferenceProcess@4 +CsrDereferenceThread@4 +CsrDereferenceWait@4 +CsrDestroyProcess@4 +CsrDestroyThread@4 +CsrExecServerThread@0 +CsrGetProcessLuid@8 +CsrImpersonateClient@0 +CsrLockProcessByClientId@0 +CsrLockThreadByClientId@0 +CsrMoveSatisfiedWait@4 +CsrNotifyWait@4 +CsrQueryApiPort@0 +CsrReferenceThread@4 +CsrRevertToSelf@0 +CsrServerInitialization@8 +CsrSetBackgroundPriority@0 +CsrSetCallingSpooler@0 +CsrSetForegroundPriority@0 +CsrShutdownProcesses@4 +CsrUnhandledExceptionFilter@0 +CsrUnlockProcess@4 +CsrUnlockThread@4 +CsrValidateMessageBuffer@0 +CsrValidateMessageString@0 +; EOF Property changes on: trunk/reactos/subsys/csr/csrsrv/csrsrv.def ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.rc --- trunk/reactos/subsys/csr/csrsrv/csrsrv.rc 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/csrsrv.rc 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS CSR Core Server\0" +#define REACTOS_STR_INTERNAL_NAME "csrsrv\0" +#define REACTOS_STR_ORIGINAL_FILENAME "csrsrv.dll\0" +#include <reactos/version.rc> Property changes on: trunk/reactos/subsys/csr/csrsrv/csrsrv.rc ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/csrsrv.xml --- trunk/reactos/subsys/csr/csrsrv/csrsrv.xml 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/csrsrv.xml 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,17 @@
+<module name="csrsrv" type="nativedll"> + <importlibrary definition="csrsrv.def" /> + <include base="csrsrv">.</include> + <include base="csr">.</include> + <define name="_DISABLE_TIDENTS" /> + <define name="__USE_W32API" /> + <library>ntdll</library> + <file>debug.c</file> + <file>dllmain.c</file> + <file>init.c</file> + <file>process.c</file> + <file>server.c</file> + <file>session.c</file> + <file>thread.c</file> + <file>wait.c</file> + <file>csrsrv.rc</file> +</module> Property changes on: trunk/reactos/subsys/csr/csrsrv/csrsrv.xml ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/debug.c --- trunk/reactos/subsys/csr/csrsrv/debug.c 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/debug.c 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,53 @@
+/* $Id$ + * + * subsys/csr/csrsrv/debug.c - CSR server - debugging management + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "srv.h" + +//#define NDEBUG +#include <debug.h> + +/*===================================================================== + * PUBLIC API + *===================================================================*/ + +NTSTATUS STDCALL CsrDebugProcess (PCSR_PROCESS pCsrProcess) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, pCsrProcess); + + return Status; +} + +NTSTATUS STDCALL CsrDebugProcessStop (PCSR_PROCESS pCsrProcess) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, pCsrProcess); + + return Status; +} + +/* EOF */ Property changes on: trunk/reactos/subsys/csr/csrsrv/debug.c ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/dllmain.c --- trunk/reactos/subsys/csr/csrsrv/dllmain.c 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/dllmain.c 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,33 @@
+/* $Id$ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: subsys/csr/csrsrv/dllmain.c + * PURPOSE: DLL entry point + */ + +/* INCLUDES ******************************************************************/ + +#include "srv.h" + +#define NDEBUG +#include <debug.h> + +HANDLE CsrSrvDllHandle = 0; + +/* FUNCTIONS *****************************************************************/ + +BOOL STDCALL +DllMain(HANDLE hDll, + DWORD dwReason, + LPVOID lpReserved) +{ + if (DLL_PROCESS_ATTACH == dwReason) + { + CsrSrvDllHandle = hDll; + } + + return TRUE; +} + +/* EOF */ Property changes on: trunk/reactos/subsys/csr/csrsrv/dllmain.c ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/init.c --- trunk/reactos/subsys/csr/csrsrv/init.c 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/init.c 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,427 @@
+/* $Id$ + * + * subsys/csr/csrsrv/init.c - CSR server - initialization + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "srv.h" + +//#define NDEBUG +#include <debug.h> + + +typedef enum { + CSRAT_UNKNOWN=0, + CSRAT_OBJECT_DIRECTORY, + CSRAT_SUBSYSTEM_TYPE, + CSRAT_REQUEST_THREADS, /* ReactOS extension */ + CSRAT_REQUEST_THREADS_MAX, + CSRAT_PROFILE_CONTROL, + CSRAT_SHARED_SECTION, + CSRAT_SERVER_DLL, + CSRAT_WINDOWS, + CSRAT_SESSIONS, /* ReactOS extension */ + CSRAT_MAX +} CSR_ARGUMENT_TYPE, *PCSR_ARGUMENT_TYPE; + +typedef struct _CSR_ARGUMENT_ITEM +{ + CSR_ARGUMENT_TYPE Type; + UNICODE_STRING Data; + union { + UNICODE_STRING ObjectDirectory; + CSR_SUBSYSTEM_TYPE SubSystemType; + USHORT RequestThreads; + USHORT MaxRequestThreads; + BOOL ProfileControl; + BOOL Windows; + BOOL Sessions; + CSR_SERVER_DLL ServerDll; + struct { + USHORT PortSectionSize; // 1024k; 128k..? + USHORT InteractiveDesktopHeapSize; // 3072k; 128k.. + USHORT NonInteractiveDesktopHeapSize; // (InteractiveDesktopHeapSize); 128k.. + USHORT Reserved; /* unused */ + } SharedSection; + } Item; + +} CSR_ARGUMENT_ITEM, * PCSR_ARGUMENT_ITEM; + +/********************************************************************** + * CsrpStringToBool/3 PRIVATE + */ +static BOOL STDCALL CsrpStringToBool (LPWSTR TestString, LPWSTR TrueString, LPWSTR FalseString) +{ + if((0 == wcscmp(TestString, TrueString))) + { + return TRUE; + } + if((0 == wcscmp(TestString, FalseString))) + { + return FALSE; + } + DPRINT1("CSRSRV:%s: replacing invalid value '%S' with '%S'!\n", + __FUNCTION__, TestString, FalseString); + return FALSE; +} +/********************************************************************** + * CsrpSplitServerDll/2 PRIVATE + * + * RETURN VALUE + * 0: syntax error + * 2: ServerDll=="basesrv,1" + * 3: ServerDll=="winsrv:UserServerDllInitialization,3" + */ +static INT STDCALL CsrpSplitServerDll (LPWSTR ServerDll, PCSR_ARGUMENT_ITEM pItem) +{ + LPWSTR DllName = NULL; + LPWSTR DllEntryPoint = NULL; + LPWSTR DllId = NULL; + static LPWSTR DefaultDllEntryPoint = L"ServerDllInitialization"; + LPWSTR tmp = NULL; + INT rc = 0; + PCSR_SERVER_DLL pCsrServerDll = & pItem->Item.ServerDll; + + if (L'\0' == *ServerDll) + { + return 0; + } + /* + * DllName (required) + */ + DllName = ServerDll; + if (NULL == DllName) + { + return 0; + } + /* + * DllEntryPoint (optional) + */ + DllEntryPoint = wcschr (ServerDll, L':'); + if (NULL == DllEntryPoint) + { + DllEntryPoint = DefaultDllEntryPoint; + tmp = ServerDll; + rc = 2; + } else { + tmp = ++DllEntryPoint; + rc = 3; + } + /* + * DllId (required) + */ + DllId = wcschr (tmp, L','); + if (NULL == DllId) + { + return 0; + } + *DllId++ = L'\0'; + // OK + pCsrServerDll->ServerIndex = wcstoul (DllId, NULL, 10); + pCsrServerDll->Unused = 0; + RtlInitUnicodeString (& pCsrServerDll->DllName, DllName); + RtlInitUnicodeString (& pCsrServerDll->DllEntryPoint, DllEntryPoint); + return rc; +} +/********************************************************************** + * CsrpSplitSharedSection/2 PRIVATE + * + * RETURN VALUE + * 0: syntax error + * 1: PortSectionSize (required) + * 2: PortSection,InteractiveDesktopHeap + * 3: PortSection,InteractiveDesktopHeap,NonInteractiveDesktopHeap + */ +static INT STDCALL CsrpSplitSharedSection (LPWSTR SharedSection, PCSR_ARGUMENT_ITEM pItem) +{ + LPWSTR PortSectionSize = NULL; + LPWSTR InteractiveDesktopHeapSize = NULL; + LPWSTR NonInteractiveDesktopHeapSize = NULL; + INT rc = 1; + + DPRINT("CSRSRV:%s(%S) called\n", __FUNCTION__, SharedSection); + + if(L'\0' == *SharedSection) + { + DPRINT("CSRSRV:%s(%S): *SharedSection == L'\0'\n", __FUNCTION__, SharedSection); + return 0; + } + + // PortSectionSize (required) + PortSectionSize = SharedSection; + // InteractiveDesktopHeapSize (optional) + InteractiveDesktopHeapSize = wcschr (PortSectionSize, L','); + if (NULL == InteractiveDesktopHeapSize) + { + // Default value is 128k + InteractiveDesktopHeapSize = L"128"; + } else { + rc = 2; + } + // NonInteractiveDesktopHeapSize (optional) + NonInteractiveDesktopHeapSize = wcschr (InteractiveDesktopHeapSize, L','); + if (NULL == NonInteractiveDesktopHeapSize) + { + // Default value equals interactive one + NonInteractiveDesktopHeapSize = InteractiveDesktopHeapSize; + } else { + rc = 3; + } + // OK - normalization + pItem->Item.SharedSection.PortSectionSize = wcstoul (PortSectionSize, NULL, 10); + if (pItem->Item.SharedSection.PortSectionSize < 64) + { + pItem->Item.SharedSection.PortSectionSize = 64; + } + pItem->Item.SharedSection.InteractiveDesktopHeapSize = wcstoul (InteractiveDesktopHeapSize, NULL, 10); + if (pItem->Item.SharedSection.InteractiveDesktopHeapSize < 128) + { + pItem->Item.SharedSection.InteractiveDesktopHeapSize = 128; + } + pItem->Item.SharedSection.NonInteractiveDesktopHeapSize = wcstoul (NonInteractiveDesktopHeapSize, NULL, 10); + if (pItem->Item.SharedSection.NonInteractiveDesktopHeapSize < 128) + { + pItem->Item.SharedSection.NonInteractiveDesktopHeapSize = 128; + } + // done + return rc; +} +/********************************************************************** + * CsrpParseArgumentItem/1 PRIVATE + * + * DESCRIPTION + * + * ARGUMENTS + * Argument: argument to decode; + * + * RETURN VALUE + * STATUS_SUCCESS; otherwise, STATUS_UNSUCCESSFUL and + * pItem->Type = CSRAT_UNKNOWN. + * + * NOTE + * The command line could be as complex as the following one, + * which is the original command line for the Win32 subsystem + * in NT 5.1: + * + * %SystemRoot%\system32\csrss.exe + * ObjectDirectory=\Windows + * SharedSection=1024,3072,512 + * Windows=On + * SubSystemType=Windows + * ServerDll=basesrv,1 + * ServerDll=winsrv:UserServerDllInitialization,3 + * ServerDll=winsrv:ConServerDllInitialization,2 + * ProfileControl=Off + * MaxRequestThreads=16 + */ +static NTSTATUS FASTCALL CsrpParseArgumentItem (IN OUT PCSR_ARGUMENT_ITEM pItem) +{ + NTSTATUS Status = STATUS_SUCCESS; + LPWSTR ParameterName = NULL; + LPWSTR ParameterValue = NULL; + + pItem->Type = CSRAT_UNKNOWN; + + if(0 == pItem->Data.Length) + { + DPRINT1("CSRSRV:%s: (0 == Data.Length)!\n", __FUNCTION__); + return STATUS_INVALID_PARAMETER; + } + //--- Seek '=' to split name and value + ParameterName = pItem->Data.Buffer; + ParameterValue = wcschr (ParameterName, L'='); + if (NULL == ParameterValue) + { + DPRINT1("CSRSRV:%s: (NULL == ParameterValue)!\n", __FUNCTION__); + return STATUS_INVALID_PARAMETER; + } + *ParameterValue++ = L'\0'; + DPRINT("Name=%S, Value=%S\n", ParameterName, ParameterValue); + //--- + if(0 == wcscmp(ParameterName, L"ObjectDirectory")) + { + RtlInitUnicodeString (& pItem->Item.ObjectDirectory, ParameterValue); + pItem->Type = CSRAT_OBJECT_DIRECTORY; + } + else if(0 == wcscmp(ParameterName, L"SubSystemType")) + { + pItem->Type = CSRAT_SUBSYSTEM_TYPE; + pItem->Item.Windows = CsrpStringToBool (ParameterValue, L"Windows", L"Text"); + } + else if(0 == wcscmp(ParameterName, L"MaxRequestThreads")) + { + pItem->Item.MaxRequestThreads = (USHORT) wcstoul (ParameterValue, NULL, 10); + pItem->Type = CSRAT_REQUEST_THREADS_MAX; + } + else if(0 == wcscmp(ParameterName, L"RequestThreads")) + { + // ROS Extension + pItem->Item.RequestThreads = (USHORT) wcstoul (ParameterValue, NULL, 10); + pItem->Type = CSRAT_REQUEST_THREADS; + } + else if(0 == wcscmp(ParameterName, L"ProfileControl")) + { + pItem->Item.ProfileControl = CsrpStringToBool (ParameterValue, L"On", L"Off"); + pItem->Type = CSRAT_PROFILE_CONTROL; + } + else if(0 == wcscmp(ParameterName, L"SharedSection")) + { + if (0 != CsrpSplitSharedSection(ParameterValue, pItem)) + { + pItem->Type = CSRAT_SHARED_SECTION; + } else { + pItem->Type = CSRAT_UNKNOWN; + return STATUS_INVALID_PARAMETER; + } + } + else if(0 == wcscmp(ParameterName, L"ServerDll")) + { + if (0 != CsrpSplitServerDll(ParameterValue, pItem)) + { + pItem->Type = CSRAT_SERVER_DLL; + } else { + pItem->Type = CSRAT_UNKNOWN; + return STATUS_INVALID_PARAMETER; + } + } + else if(0 == wcscmp(ParameterName, L"Windows")) + { + pItem->Item.Windows = CsrpStringToBool (ParameterValue, L"On", L"Off"); + pItem->Type = CSRAT_WINDOWS; + } + else if(0 == wcscmp(ParameterName, L"Sessions")) + { + // ROS Extension + pItem->Item.Sessions = CsrpStringToBool (ParameterValue, L"On", L"Off"); + pItem->Type = CSRAT_SESSIONS; + } + else + { + DPRINT1("CSRSRV:%s: unknown parameter '%S'!\n", __FUNCTION__, ParameterName); + pItem->Type = CSRAT_UNKNOWN; + Status = STATUS_INVALID_PARAMETER; + } + return Status; +} +/********************************************************************** + * CsrServerInitialization/2 + * + * DESCRIPTION + * Every environment subsystem implicitly starts where this + * routines stops. This routine is called by CSR on startup + * and then it calls the entry points in the following server + * DLLs, as per command line. + * + * ARGUMENTS + * ArgumentCount: + * Argument: + * + * RETURN VALUE + * STATUS_SUCCESS if it succeeds. Otherwise a status code. + * + * NOTE + * This is the only function explicitly called by csr.exe. + */ +NTSTATUS STDCALL CsrServerInitialization (ULONG ArgumentCount, + LPWSTR *Argument) +{ + NTSTATUS Status = STATUS_SUCCESS; + ULONG ArgumentIndex = 0; + CSR_ARGUMENT_ITEM ArgumentItem = {CSRAT_UNKNOWN,}; + + // get registry bootstrap options + for (ArgumentIndex = 0; ArgumentIndex < ArgumentCount; ArgumentIndex++) + { + RtlInitUnicodeString (& ArgumentItem.Data, Argument[ArgumentIndex]); + Status = CsrpParseArgumentItem (& ArgumentItem); + if (NT_SUCCESS(Status)) + { + switch (ArgumentItem.Type) + { + case CSRAT_UNKNOWN: + // ignore unknown parameters + DPRINT1("CSRSRV: ignoring param '%s'\n", Argument[ArgumentIndex]); + break; + case CSRAT_OBJECT_DIRECTORY: + RtlDuplicateUnicodeString (1, & ArgumentItem.Item.ObjectDirectory, & CsrSrvOption.NameSpace.Root); + DPRINT("ObjectDirectory: '%S'\n", CsrSrvOption.NameSpace.Root.Buffer); + break; + case CSRAT_SUBSYSTEM_TYPE: + CsrSrvOption.SubSystemType = ArgumentItem.Item.SubSystemType; + DPRINT("SubSystemType: %u\n", CsrSrvOption.SubSystemType); + break; + case CSRAT_REQUEST_THREADS: + CsrSrvOption.Threads.RequestCount = ArgumentItem.Item.RequestThreads; + DPRINT("RequestThreads: %u\n", CsrSrvOption.Threads.RequestCount); + break; + case CSRAT_REQUEST_THREADS_MAX: + CsrSrvOption.Threads.MaxRequestCount = ArgumentItem.Item.MaxRequestThreads; + DPRINT("MaxRequestThreads: %u\n", CsrSrvOption.Threads.MaxRequestCount); + break; + case CSRAT_PROFILE_CONTROL: + CsrSrvOption.Flag.ProfileControl = ArgumentItem.Item.ProfileControl; + DPRINT("ProfileControl: %u \n", CsrSrvOption.Flag.ProfileControl); + break; + case CSRAT_SHARED_SECTION: + CsrSrvOption.PortSharedSectionSize = ArgumentItem.Item.SharedSection.PortSectionSize; + CsrSrvOption.Heap.InteractiveDesktopHeapSize = ArgumentItem.Item.SharedSection.InteractiveDesktopHeapSize; + CsrSrvOption.Heap.NonInteractiveDesktopHeapSize = ArgumentItem.Item.SharedSection.NonInteractiveDesktopHeapSize; + DPRINT("SharedSection: %u-%u-%u\n", + CsrSrvOption.PortSharedSectionSize, + CsrSrvOption.Heap.InteractiveDesktopHeapSize, + CsrSrvOption.Heap.NonInteractiveDesktopHeapSize); + break; + case CSRAT_SERVER_DLL: + Status = CsrSrvRegisterServerDll (& ArgumentItem.Item.ServerDll); + if(!NT_SUCCESS(Status)) + { + DPRINT1("CSRSRV: CsrSrvRegisterServerDll(%S) failed!\n", + Argument[ArgumentIndex]); + } else { + DPRINT("ServerDll: DLL='%S' Entrypoint='%S' ID=%u\n", + ArgumentItem.Item.ServerDll.DllName.Buffer, + ArgumentItem.Item.ServerDll.DllEntryPoint.Buffer, + ArgumentItem.Item.ServerDll.ServerIndex); + } + break; + case CSRAT_WINDOWS: + CsrSrvOption.Flag.Windows = ArgumentItem.Item.Windows; + DPRINT("Windows: %d\n", CsrSrvOption.Flag.Windows); + break; + case CSRAT_SESSIONS: + CsrSrvOption.Flag.Sessions = ArgumentItem.Item.Sessions; + DPRINT("Sessions: %d\n", CsrSrvOption.Flag.Sessions); + break; + default: + DPRINT("CSRSRV: unknown ArgumentItem->Type=%ld!\n", ArgumentItem.Type); + } + } else { + DPRINT1("CSRSRV:%s: CsrpParseArgumentItem(%S) failed with Status = %08lx\n", + __FUNCTION__, Argument[ArgumentIndex], Status); + } + } + // TODO: verify required + Status = CsrSrvBootstrap (); + return Status; +} +/* EOF */ Property changes on: trunk/reactos/subsys/csr/csrsrv/init.c ___________________________________________________________________ Name: svn:keywords + author date id revision Name: svn:eol-style + native _____
Added: trunk/reactos/subsys/csr/csrsrv/process.c --- trunk/reactos/subsys/csr/csrsrv/process.c 2005-08-12 12:10:33 UTC (rev 17322) +++ trunk/reactos/subsys/csr/csrsrv/process.c 2005-08-12 12:22:02 UTC (rev 17323) @@ -0,0 +1,135 @@
+/* $Id$ + * + * subsys/csr/csrsrv/process.c - CSR server - process management + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "srv.h" + +//#define NDEBUG +#include <debug.h> + +/* LOCALS */ + +struct { + RTL_CRITICAL_SECTION Lock; +} Process; + + + +NTSTATUS STDCALL CsrSrvInitializeProcess (VOID) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + + Status = RtlInitializeCriticalSection (& Process.Lock); + if(NT_SUCCESS(Status)) + { + // more process management initialization + } + return Status; +} + +/*===================================================================== + * PUBLIC API + *===================================================================*/ + +NTSTATUS STDCALL CsrCreateProcess (PCSR_SESSION pCsrSession, PCSR_PROCESS * ppCsrProcess) +{ + NTSTATUS Status = STATUS_SUCCESS; + PCSR_PROCESS pCsrProcess = NULL; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + + pCsrProcess = RtlAllocateHeap (pCsrSession->Heap, + HEAP_ZERO_MEMORY, + sizeof (CSR_PROCESS)); + if (NULL == pCsrProcess) + { + Status = STATUS_NO_MEMORY; + } else { + pCsrProcess->CsrSession = pCsrSession; + if (NULL != ppCsrProcess) + { + *ppCsrProcess = pCsrProcess; + } + } + return Status; +} + +NTSTATUS STDCALL CsrDereferenceProcess (PCSR_PROCESS pCsrProcess) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + return Status; +} + +NTSTATUS STDCALL CsrDestroyProcess (PCSR_PROCESS pCsrProcess) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + return Status; +} + +NTSTATUS STDCALL CsrGetProcessLuid (PCSR_PROCESS pCsrProcess, PLUID pLuid) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + return Status; +} + +NTSTATUS STDCALL CsrLockProcessByClientId () +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + return Status; +} + +NTSTATUS STDCALL CsrShutdownProcesses (PCSR_SESSION pCsrSession OPTIONAL) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + + if (NULL == pCsrSession) + { + // TODO: shutdown every session + } else { + // TODO: shutdown every process in pCsrSession + } + return Status; +} + +NTSTATUS STDCALL CsrUnlockProcess (PCSR_PROCESS pCsrProcess) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + + DPRINT("CSRSRV: %s called\n", __FUNCTION__); + return Status; +} + +/* EOF */ [truncated at 1000 lines; 1596 more skipped]