mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:16:07 +00:00
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) svn path=/trunk/; revision=17323
This commit is contained in:
parent
65c59875e1
commit
6d095fd4bb
32 changed files with 2244 additions and 0 deletions
126
reactos/subsys/csr/args.c
Normal file
126
reactos/subsys/csr/args.c
Normal file
|
@ -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 */
|
34
reactos/subsys/csr/csr.h
Normal file
34
reactos/subsys/csr/csr.h
Normal file
|
@ -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 */
|
||||||
|
|
4
reactos/subsys/csr/csr.rc
Normal file
4
reactos/subsys/csr/csr.rc
Normal file
|
@ -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>
|
14
reactos/subsys/csr/csr.xml
Normal file
14
reactos/subsys/csr/csr.xml
Normal file
|
@ -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>
|
37
reactos/subsys/csr/csrsrv/csrsrv.def
Normal file
37
reactos/subsys/csr/csrsrv/csrsrv.def
Normal file
|
@ -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
|
5
reactos/subsys/csr/csrsrv/csrsrv.rc
Normal file
5
reactos/subsys/csr/csrsrv/csrsrv.rc
Normal file
|
@ -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>
|
17
reactos/subsys/csr/csrsrv/csrsrv.xml
Normal file
17
reactos/subsys/csr/csrsrv/csrsrv.xml
Normal file
|
@ -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>
|
53
reactos/subsys/csr/csrsrv/debug.c
Normal file
53
reactos/subsys/csr/csrsrv/debug.c
Normal file
|
@ -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 */
|
33
reactos/subsys/csr/csrsrv/dllmain.c
Normal file
33
reactos/subsys/csr/csrsrv/dllmain.c
Normal file
|
@ -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 */
|
427
reactos/subsys/csr/csrsrv/init.c
Normal file
427
reactos/subsys/csr/csrsrv/init.c
Normal file
|
@ -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 */
|
135
reactos/subsys/csr/csrsrv/process.c
Normal file
135
reactos/subsys/csr/csrsrv/process.c
Normal file
|
@ -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 */
|
364
reactos/subsys/csr/csrsrv/server.c
Normal file
364
reactos/subsys/csr/csrsrv/server.c
Normal file
|
@ -0,0 +1,364 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* subsys/csr/csrsrv/server.c - CSR server - subsystem default server
|
||||||
|
*
|
||||||
|
* 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 struct _CSRSRV_SERVER_DLL
|
||||||
|
{
|
||||||
|
USHORT ServerIndex;
|
||||||
|
USHORT Sequence; // initialization order
|
||||||
|
UNICODE_STRING DllName;
|
||||||
|
UNICODE_STRING DllEntryPoint;
|
||||||
|
CSR_SERVER_THREAD ServerThread; // NULL ==> inactive
|
||||||
|
|
||||||
|
} CSRSRV_SERVER_DLL, *PCSRSRV_SERVER_DLL;
|
||||||
|
|
||||||
|
/*=====================================================================
|
||||||
|
* GLOBALS
|
||||||
|
*===================================================================*/
|
||||||
|
|
||||||
|
CSRSRV_OPTION CsrSrvOption;
|
||||||
|
|
||||||
|
HANDLE CsrSrvApiPortHandle = (HANDLE) 0;
|
||||||
|
|
||||||
|
/*=====================================================================
|
||||||
|
* LOCALS
|
||||||
|
*===================================================================*/
|
||||||
|
|
||||||
|
static HANDLE CsrSrvSbApiPortHandle = (HANDLE) 0;
|
||||||
|
|
||||||
|
static CSRSRV_SERVER_DLL ServerThread [CSR_SERVER_DLL_MAX];
|
||||||
|
|
||||||
|
VOID CALLBACK CsrSrvServerThread (PVOID);
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSrvRegisterServerDll/1
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrSrvRegisterServerDll (PCSR_SERVER_DLL pServerDll)
|
||||||
|
{
|
||||||
|
static USHORT NextInSequence = 0;
|
||||||
|
USHORT ServerIndex = 0;
|
||||||
|
|
||||||
|
// 1st call?
|
||||||
|
if (0 == NextInSequence)
|
||||||
|
{
|
||||||
|
RtlZeroMemory (ServerThread, sizeof ServerThread);
|
||||||
|
}
|
||||||
|
// We can not register more than CSR_SERVER_DLL_MAX servers.
|
||||||
|
// Note: # servers >= # DLLs (MS Win32 has 3 servers in 2 DLLs).
|
||||||
|
if (NextInSequence >= CSR_SERVER_DLL_MAX)
|
||||||
|
{
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
// Validate the ServerIndex from the command line:
|
||||||
|
// it may be 0, 1, 2, or 3.
|
||||||
|
ServerIndex = pServerDll->ServerIndex;
|
||||||
|
if (ServerIndex >= CSR_SERVER_DLL_MAX)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
// Register the DLL server.
|
||||||
|
ServerThread [ServerIndex].ServerIndex = ServerIndex;
|
||||||
|
ServerThread [ServerIndex].Sequence = NextInSequence ++;
|
||||||
|
if (0 != ServerIndex)
|
||||||
|
{
|
||||||
|
RtlDuplicateUnicodeString (1, & pServerDll->DllName, & ServerThread [ServerIndex].DllName);
|
||||||
|
RtlDuplicateUnicodeString (1, & pServerDll->DllEntryPoint, & ServerThread [ServerIndex].DllEntryPoint);
|
||||||
|
} else {
|
||||||
|
// CSRSRV.DLL own static server thread
|
||||||
|
ServerThread [ServerIndex].ServerThread = CsrSrvServerThread;
|
||||||
|
}
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrpCreateObjectDirectory/1 PRIVATE
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrpCreateObjectDirectory (PUNICODE_STRING pObjectDirectory)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
OBJECT_ATTRIBUTES DirectoryAttributes;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV:%s(%S) called\n", __FUNCTION__, pObjectDirectory->Buffer);
|
||||||
|
|
||||||
|
InitializeObjectAttributes (& DirectoryAttributes,
|
||||||
|
pObjectDirectory,
|
||||||
|
OBJ_OPENIF,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtCreateDirectoryObject (& CsrSrvOption.NameSpace.RootHandle,
|
||||||
|
(DIRECTORY_CREATE_OBJECT|DIRECTORY_CREATE_SUBDIRECTORY),
|
||||||
|
& DirectoryAttributes);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = RtlDuplicateUnicodeString (0, pObjectDirectory, & CsrSrvOption.NameSpace.Root);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV:%s: RtlDuplicateUnicodeString failed (Status=0x%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DPRINT1("CSRSRV:%s: fatal: NtCreateDirectoryObject failed (Status=0x%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSrvBootstrap/0
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
* This is where a subsystem begins living.
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrSrvBootstrap (VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
ULONG ServerIndex = 0;
|
||||||
|
ULONG ServerSequence = 0;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
CsrSrvSbApiPortHandle = CsrSrvSbApiPortHandle; //FIXME
|
||||||
|
|
||||||
|
// OBJECT DIRECTORY
|
||||||
|
Status = CsrpCreateObjectDirectory (& CsrSrvOption.NameSpace.Root);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV:%s: CsrpCreateObjectDirectory failed (Status=%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
// SESSIONS
|
||||||
|
Status = CsrSrvInitializeSession ();
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV:%s: CsrSrvInitializeSession failed (Status=%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
// PROCESSES
|
||||||
|
// TODO
|
||||||
|
// THREADS
|
||||||
|
// TODO
|
||||||
|
// WAITS
|
||||||
|
// TODO
|
||||||
|
// Hosted servers
|
||||||
|
for (ServerSequence = 0; ServerSequence < CSR_SERVER_DLL_MAX; ServerSequence ++)
|
||||||
|
{
|
||||||
|
for (ServerIndex = 0; (ServerIndex < CSR_SERVER_DLL_MAX); ++ ServerIndex)
|
||||||
|
{
|
||||||
|
if (ServerSequence == ServerThread [ServerIndex].Sequence)
|
||||||
|
{
|
||||||
|
if (NULL == ServerThread [ServerIndex].ServerThread)
|
||||||
|
{
|
||||||
|
//TODO: load DLL and call ServerDllInitialize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSrvServerThread/1
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
* This is actually a function called by the CsrSrvMainServerThread
|
||||||
|
* when the server index is 0. Other server DLLs register their
|
||||||
|
* function with CsrAddStaticServerThread.
|
||||||
|
*/
|
||||||
|
VOID STDCALL CsrSrvServerThread (PVOID x)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
|
||||||
|
PPORT_MESSAGE Reply = NULL;
|
||||||
|
ULONG MessageType = 0;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
MessageType = Request->u2.s2.Type;
|
||||||
|
DPRINT("CSRSRV: %s received a message (Type=%d)\n",
|
||||||
|
__FUNCTION__, MessageType);
|
||||||
|
switch (MessageType)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
default:
|
||||||
|
Reply = Request;
|
||||||
|
Status = NtReplyPort (CsrSrvApiPortHandle, Reply);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* PUBLIC API
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrAddStaticServerThread/1
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrAddStaticServerThread (CSR_SERVER_THREAD ServerThread)
|
||||||
|
{
|
||||||
|
static ULONG StaticServerThreadCount = 0;
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, ServerThread);
|
||||||
|
|
||||||
|
if (StaticServerThreadCount > CSR_SERVER_DLL_MAX)
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV: subsystem tries to add mode than %d static threads!\n",
|
||||||
|
CSR_SERVER_DLL_MAX);
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
// FIXME: do we need to make it reentrant?
|
||||||
|
++ StaticServerThreadCount;
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrCallServerFromServer
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrCallServerFromServer ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrExecServerThread
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrExecServerThread ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrImpersonateClient
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrImpersonateClient ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrQueryApiPort/0
|
||||||
|
*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
HANDLE STDCALL CsrQueryApiPort (VOID)
|
||||||
|
{
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return CsrSrvApiPortHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrRevertToSelf
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrRevertToSelf ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSetBackgroundPriority
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrSetBackgroundPriority ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSetCallingSpooler
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrSetCallingSpooler ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrSetForegroundPriority
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrSetForegroundPriority ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrUnhandledExceptionFilter
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrUnhandledExceptionFilter ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrValidateMessageBuffer
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrValidateMessageBuffer ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrValidateMessageString
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL CsrValidateMessageString ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
178
reactos/subsys/csr/csrsrv/session.c
Normal file
178
reactos/subsys/csr/csrsrv/session.c
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* subsys/csr/csrsrv/session.c - CSR server - session 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>
|
||||||
|
|
||||||
|
//TODO: when CsrSrvSessionsFlag is FALSE, create just one session and
|
||||||
|
//TODO: fail for more sessions requests.
|
||||||
|
|
||||||
|
/* LOCALS */
|
||||||
|
|
||||||
|
struct {
|
||||||
|
RTL_CRITICAL_SECTION Lock;
|
||||||
|
HANDLE Heap;
|
||||||
|
ULONG LastUnusedId;
|
||||||
|
} Session;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrSrvInitializeSession (VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
Status = RtlInitializeCriticalSection (& Session.Lock);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Session.Heap = RtlCreateHeap (HEAP_GROWABLE,
|
||||||
|
NULL,
|
||||||
|
65536,
|
||||||
|
65536,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (NULL == Session.Heap)
|
||||||
|
{
|
||||||
|
RtlDeleteCriticalSection (& Session.Lock);
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
Session.LastUnusedId = 0;
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS STDCALL CsrpCreateSessionDirectories (PCSR_SESSION pCsrSession)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
CHAR SessionIdBuffer [8];
|
||||||
|
ANSI_STRING SessionIdNameA;
|
||||||
|
UNICODE_STRING SessionIdNameW;
|
||||||
|
UNICODE_STRING SessionDirectoryName;
|
||||||
|
OBJECT_ATTRIBUTES DirectoryAttributes;
|
||||||
|
HANDLE DirectoryHAndle;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, pCsrSession);
|
||||||
|
|
||||||
|
sprintf (SessionIdBuffer, "\\Sessions\\%ld", pCsrSession->SessionId);
|
||||||
|
RtlInitAnsiString (& SessionIdNameA, SessionIdBuffer);
|
||||||
|
RtlAnsiStringToUnicodeString (& SessionIdNameW, & SessionIdNameA, TRUE);
|
||||||
|
RtlCopyUnicodeString (& SessionDirectoryName, & CsrSrvOption.NameSpace.Root);
|
||||||
|
RtlAppendUnicodeStringToString (& SessionDirectoryName, & SessionIdNameW);
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s(%08lx): %S\n", __FUNCTION__, pCsrSession,
|
||||||
|
SessionDirectoryName.Buffer);
|
||||||
|
|
||||||
|
InitializeObjectAttributes (& DirectoryAttributes,
|
||||||
|
& SessionDirectoryName,
|
||||||
|
OBJ_OPENIF,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = NtCreateDirectoryObject (& DirectoryHAndle,
|
||||||
|
(DIRECTORY_CREATE_OBJECT|DIRECTORY_CREATE_SUBDIRECTORY),
|
||||||
|
& DirectoryAttributes);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV: session %ld root directory not created (Status=%08lx)\n",
|
||||||
|
pCsrSession->SessionId, Status);
|
||||||
|
}
|
||||||
|
// TODO
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS STDCALL CsrpDestroySessionDirectories (PCSR_SESSION pCsrSession)
|
||||||
|
{
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=====================================================================
|
||||||
|
* PUBLIC API
|
||||||
|
*===================================================================*/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrDestroySession (PCSR_SESSION pCsrSession)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, pCsrSession);
|
||||||
|
|
||||||
|
if (NULL == pCsrSession)
|
||||||
|
{
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
|
} else {
|
||||||
|
Status = CsrShutdownProcesses (pCsrSession);
|
||||||
|
Status = CsrpDestroySessionDirectories (pCsrSession);
|
||||||
|
RtlDestroyHeap (pCsrSession->Heap);
|
||||||
|
RtlFreeHeap (Session.Heap, 0, pCsrSession);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrCreateSession (PCSR_SESSION * ppCsrSession)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
PCSR_SESSION pCsrSession = NULL;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if (NULL == ppCsrSession)
|
||||||
|
{
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
|
} else {
|
||||||
|
RtlEnterCriticalSection (& Session.Lock);
|
||||||
|
pCsrSession = RtlAllocateHeap (Session.Heap,
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
sizeof (CSR_SESSION));
|
||||||
|
if (NULL == pCsrSession)
|
||||||
|
{
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
} else {
|
||||||
|
pCsrSession->SessionId = Session.LastUnusedId ++;
|
||||||
|
Status = CsrpCreateSessionDirectories (pCsrSession);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
pCsrSession->Heap = RtlCreateHeap(HEAP_GROWABLE,
|
||||||
|
NULL,
|
||||||
|
65536,
|
||||||
|
65536,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (NULL == pCsrSession->Heap)
|
||||||
|
{
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
CsrpDestroySessionDirectories (pCsrSession);
|
||||||
|
-- Session.LastUnusedId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RtlLeaveCriticalSection (& Session.Lock);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
72
reactos/subsys/csr/csrsrv/srv.h
Normal file
72
reactos/subsys/csr/csrsrv/srv.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#if !defined(_INCLUDE_CSR_CSRSRV_SRV_H)
|
||||||
|
#define _INCLUDE_CSR_CSRSRV_SRV_H
|
||||||
|
|
||||||
|
/* PSDK/NDK Headers */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
|
/* CSR Headers */
|
||||||
|
#include <csr/server.h>
|
||||||
|
|
||||||
|
/* Maximum number of hosted servers, included the one in csrsrv.dll */
|
||||||
|
#define CSR_SERVER_DLL_MAX 4
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CSRSST_NONE=0,
|
||||||
|
CSRSST_TEXT,
|
||||||
|
CSRSST_WINDOWS,
|
||||||
|
CSRSST_MAX
|
||||||
|
|
||||||
|
} CSR_SUBSYSTEM_TYPE, * PCSR_SUBSYSTEM_TYPE;
|
||||||
|
|
||||||
|
typedef struct _CSR_SERVER_DLL
|
||||||
|
{
|
||||||
|
USHORT ServerIndex;
|
||||||
|
USHORT Unused;
|
||||||
|
UNICODE_STRING DllName;
|
||||||
|
UNICODE_STRING DllEntryPoint;
|
||||||
|
} CSR_SERVER_DLL, * PCSR_SERVER_DLL;
|
||||||
|
|
||||||
|
/* dllmain.c */
|
||||||
|
extern HANDLE CsrSrvDllHandle;
|
||||||
|
|
||||||
|
/* process.c */
|
||||||
|
|
||||||
|
/* server.c */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
UNICODE_STRING Root;
|
||||||
|
HANDLE RootHandle;
|
||||||
|
} NameSpace;
|
||||||
|
CSR_SUBSYSTEM_TYPE SubSystemType;
|
||||||
|
struct {
|
||||||
|
USHORT RequestCount;
|
||||||
|
USHORT MaxRequestCount;
|
||||||
|
} Threads;
|
||||||
|
struct {
|
||||||
|
BOOL ProfileControl;
|
||||||
|
BOOL Windows;
|
||||||
|
BOOL Sessions;
|
||||||
|
} Flag;
|
||||||
|
USHORT PortSharedSectionSize;
|
||||||
|
struct {
|
||||||
|
USHORT InteractiveDesktopHeapSize;
|
||||||
|
USHORT NonInteractiveDesktopHeapSize;
|
||||||
|
} Heap;
|
||||||
|
} CSRSRV_OPTION, * PCSRSRV_OPTION;
|
||||||
|
|
||||||
|
extern CSRSRV_OPTION CsrSrvOption;
|
||||||
|
extern HANDLE CsrSrvApiPortHandle;
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrSrvRegisterServerDll (PCSR_SERVER_DLL);
|
||||||
|
NTSTATUS STDCALL CsrSrvBootstrap (VOID);
|
||||||
|
|
||||||
|
/* session.c */
|
||||||
|
NTSTATUS STDCALL CsrSrvInitializeSession (VOID);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !def _INCLUDE_CSR_CSRSRV_SRV_H */
|
115
reactos/subsys/csr/csrsrv/thread.c
Normal file
115
reactos/subsys/csr/csrsrv/thread.c
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* subsys/csr/csrsrv/thread.c - CSR server - thread 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 CsrCreateRemoteThread ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrCreateThread (PCSR_PROCESS pCsrProcess, PCSR_THREAD *ppCsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
PCSR_THREAD pCsrThread = NULL;
|
||||||
|
PCSR_SESSION pCsrSession = NULL;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if (NULL == pCsrProcess || NULL == ppCsrThread)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
pCsrSession = pCsrProcess->CsrSession;
|
||||||
|
pCsrThread = RtlAllocateHeap (pCsrSession->Heap,
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
sizeof (CSR_THREAD));
|
||||||
|
if (NULL == pCsrThread)
|
||||||
|
{
|
||||||
|
DPRINT1("CSRSRV:%s: out of memory!\n", __FUNCTION__);
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
pCsrThread->CsrSession = pCsrSession;
|
||||||
|
pCsrThread->CsrProcess = pCsrProcess;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrDereferenceThread (PCSR_THREAD pCsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrDestroyThread (PCSR_THREAD pCsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrLockThreadByClientId ()
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrReferenceThread (PCSR_THREAD pCsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrUnlockThread (PCSR_THREAD pCsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
72
reactos/subsys/csr/csrsrv/wait.c
Normal file
72
reactos/subsys/csr/csrsrv/wait.c
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* subsys/csr/csrsrv/wait.c - CSR server - wait 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 CsrCreateWait (PCSR_THREAD pCsrThread, PCSR_WAIT * ppCsrWait)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrDereferenceWait (PCSR_WAIT pCsrWait)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrMoveSatisfiedWait (PCSR_WAIT pCsrWait)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL CsrNotifyWait (PCSR_WAIT pCsrWait)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
104
reactos/subsys/csr/main.c
Normal file
104
reactos/subsys/csr/main.c
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* main.c - Client/Server Runtime - entry point
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* --------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* 19990417 (Emanuele Aliberti)
|
||||||
|
* Do nothing native application skeleton
|
||||||
|
* 19990528 (Emanuele Aliberti)
|
||||||
|
* Compiled successfully with egcs 1.1.2
|
||||||
|
* 19990605 (Emanuele Aliberti)
|
||||||
|
* First standalone run under ReactOS (it
|
||||||
|
* actually does nothing but running).
|
||||||
|
* 20050329 (Emanuele Aliberti)
|
||||||
|
* C/S run-time moved to CSRSRV.DLL
|
||||||
|
* Win32 emulation moved to server DLLs basesrv+winsrv
|
||||||
|
* (previously code was already in win32csr.dll)
|
||||||
|
*/
|
||||||
|
#include "csr.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
COMMAND_LINE_ARGUMENT Argument;
|
||||||
|
|
||||||
|
/* never fail or so */
|
||||||
|
|
||||||
|
VOID STDCALL CsrpSetDefaultProcessHardErrorMode (VOID)
|
||||||
|
{
|
||||||
|
DWORD DefaultHardErrorMode = 0;
|
||||||
|
NtSetInformationProcess (NtCurrentProcess(),
|
||||||
|
ProcessDefaultHardErrorMode,
|
||||||
|
& DefaultHardErrorMode,
|
||||||
|
sizeof DefaultHardErrorMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Native process' entry point */
|
||||||
|
|
||||||
|
VOID STDCALL NtProcessStartup (PPEB Peb)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the command line.
|
||||||
|
*/
|
||||||
|
Status = CsrParseCommandLine (Peb, & Argument);
|
||||||
|
if (STATUS_SUCCESS != Status)
|
||||||
|
{
|
||||||
|
DPRINT1("CSR: %s: CsrParseCommandLine failed (Status=0x%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Initialize the environment subsystem server.
|
||||||
|
*/
|
||||||
|
Status = CsrServerInitialization (Argument.Count, Argument.Vector);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* FATAL! */
|
||||||
|
DPRINT1("CSR: %s: CSRSRV!CsrServerInitialization failed (Status=0x%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
|
||||||
|
CsrFreeCommandLine (Peb, & Argument);
|
||||||
|
/*
|
||||||
|
* Tell the SM we failed. If we are a required
|
||||||
|
* subsystem, SM will halt the system.
|
||||||
|
*/
|
||||||
|
NtTerminateProcess (NtCurrentProcess(), Status);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* The server booted OK: never stop on error!
|
||||||
|
*/
|
||||||
|
CsrpSetDefaultProcessHardErrorMode ();
|
||||||
|
/*
|
||||||
|
* Cleanup command line
|
||||||
|
*/
|
||||||
|
CsrFreeCommandLine (Peb, & Argument);
|
||||||
|
/*
|
||||||
|
* Terminate the current thread only (server's
|
||||||
|
* threads that serve the LPC port continue
|
||||||
|
* running and keep the process alive).
|
||||||
|
*/
|
||||||
|
NtTerminateThread (NtCurrentThread(), Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
6
reactos/subsys/win/basesrv/basesrv.def
Normal file
6
reactos/subsys/win/basesrv/basesrv.def
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
; $Id$
|
||||||
|
LIBRARY basesrv.dll
|
||||||
|
EXPORTS
|
||||||
|
BaseSetProcessCreateNotify@4
|
||||||
|
ServerDllInitialization@8
|
||||||
|
; EOF
|
14
reactos/subsys/win/basesrv/basesrv.h
Normal file
14
reactos/subsys/win/basesrv/basesrv.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef _BASESRV_H_INCLUDED_
|
||||||
|
#define _BASESRV_H_INCLUDED_
|
||||||
|
|
||||||
|
/* PSDK/NDK Headers */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
|
#include <csr/server.h>
|
||||||
|
#include <win/base.h>
|
||||||
|
|
||||||
|
#endif /* ndef _BASESRV_H_INCLUDED_ */
|
5
reactos/subsys/win/basesrv/basesrv.rc
Normal file
5
reactos/subsys/win/basesrv/basesrv.rc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#define REACTOS_VERSION_DLL
|
||||||
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS/Win32 base usermode server\0"
|
||||||
|
#define REACTOS_STR_INTERNAL_NAME "basesrv\0"
|
||||||
|
#define REACTOS_STR_ORIGINAL_FILENAME "basesrv.dll\0"
|
||||||
|
#include <reactos/version.rc>
|
12
reactos/subsys/win/basesrv/basesrv.xml
Normal file
12
reactos/subsys/win/basesrv/basesrv.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<module name="basesrv" type="win32dll">
|
||||||
|
<importlibrary definition="basesrv.def" />
|
||||||
|
<include base="basesrv">.</include>
|
||||||
|
<include base="csr">include</include>
|
||||||
|
<define name="__USE_W32API" />
|
||||||
|
<library>ntdll</library>
|
||||||
|
<library>csrsrv</library>
|
||||||
|
<file>main.c</file>
|
||||||
|
<file>init.c</file>
|
||||||
|
<file>server.c</file>
|
||||||
|
<file>basesrv.rc</file>
|
||||||
|
</module>
|
74
reactos/subsys/win/basesrv/init.c
Normal file
74
reactos/subsys/win/basesrv/init.c
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* init.c - ReactOS/Win32 base enviroment subsystem server
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 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 "basesrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
HANDLE BaseApiPort = (HANDLE) 0;
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME PRIVATE
|
||||||
|
* BaseStaticServerThread/1
|
||||||
|
*/
|
||||||
|
VOID STDCALL BaseStaticServerThread (PVOID x)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
|
||||||
|
PPORT_MESSAGE Reply = NULL;
|
||||||
|
ULONG MessageType = 0;
|
||||||
|
|
||||||
|
DPRINT("BASESRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
MessageType = Request->u2.s2.Type;
|
||||||
|
DPRINT("BASESRV: %s received a message (Type=%d)\n",
|
||||||
|
__FUNCTION__, MessageType);
|
||||||
|
switch (MessageType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
Reply = Request;
|
||||||
|
Status = NtReplyPort (BaseApiPort, Reply);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ServerDllInitialization (ULONG ArgumentCount, LPWSTR *Argument)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DPRINT("BASSRV: %s(%ld,...) called\n", __FUNCTION__, ArgumentCount);
|
||||||
|
|
||||||
|
BaseApiPort = CsrQueryApiPort ();
|
||||||
|
Status = CsrAddStaticServerThread (BaseStaticServerThread);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
//TODO initialize the BASE server
|
||||||
|
}
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
45
reactos/subsys/win/basesrv/main.c
Normal file
45
reactos/subsys/win/basesrv/main.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* dllmain.c - ReactOS/Win32 base enviroment subsystem server
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 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 "basesrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
HANDLE DllHandle = 0;
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
BOOL STDCALL DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
if (DLL_PROCESS_ATTACH == dwReason)
|
||||||
|
{
|
||||||
|
DllHandle = hDll;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
43
reactos/subsys/win/basesrv/server.c
Normal file
43
reactos/subsys/win/basesrv/server.c
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* server.c - ReactOS/Win32 base enviroment subsystem server
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 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 "basesrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/*=====================================================================
|
||||||
|
* PUBLIC API
|
||||||
|
*===================================================================*/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL BaseSetProcessCreateNotify (BASE_PROCESS_CREATE_NOTIFY_ROUTINE ProcessCreateNotifyProc)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
DPRINT("BASESRV: %s(%08lx) called\n", __FUNCTION__, ProcessCreateNotifyProc);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
6
reactos/subsys/win/directory.xml
Normal file
6
reactos/subsys/win/directory.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<directory name="basesrv">
|
||||||
|
<xi:include href="basesrv/basesrv.xml" />
|
||||||
|
</directory>
|
||||||
|
<directory name="winsrv">
|
||||||
|
<xi:include href="winsrv/winsrv.xml" />
|
||||||
|
</directory>
|
45
reactos/subsys/win/winsrv/dllmain.c
Normal file
45
reactos/subsys/win/winsrv/dllmain.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* dllmain.c - ReactOS/Win32 Console+User Enviroment Subsystem Server
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 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 "winsrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
HANDLE DllHandle = 0;
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
BOOL STDCALL DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
if (DLL_PROCESS_ATTACH == dwReason)
|
||||||
|
{
|
||||||
|
DllHandle = hDll;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
131
reactos/subsys/win/winsrv/init.c
Normal file
131
reactos/subsys/win/winsrv/init.c
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* init.c - ReactOS/Win32 Console+User Enviroment Subsystem 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
|
||||||
|
* 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 "winsrv.h"
|
||||||
|
|
||||||
|
//#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
HANDLE WinSrvApiPort = NULL;
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME PRIVATE
|
||||||
|
* ConStaticServerThread/1
|
||||||
|
*/
|
||||||
|
VOID STDCALL ConStaticServerThread (PVOID x)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
|
||||||
|
PPORT_MESSAGE Reply = NULL;
|
||||||
|
ULONG MessageType = 0;
|
||||||
|
|
||||||
|
DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
|
||||||
|
|
||||||
|
MessageType = Request->u2.s2.Type;
|
||||||
|
DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
|
||||||
|
__FUNCTION__, x, MessageType);
|
||||||
|
switch (MessageType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
Reply = Request;
|
||||||
|
Status = NtReplyPort (WinSrvApiPort, Reply);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME PRIVATE
|
||||||
|
* UserStaticServerThread/1
|
||||||
|
*/
|
||||||
|
VOID STDCALL UserStaticServerThread (PVOID x)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
|
||||||
|
PPORT_MESSAGE Reply = NULL;
|
||||||
|
ULONG MessageType = 0;
|
||||||
|
|
||||||
|
DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
|
||||||
|
|
||||||
|
MessageType = Request->u2.s2.Type;
|
||||||
|
DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
|
||||||
|
__FUNCTION__, x, MessageType);
|
||||||
|
switch (MessageType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
Reply = Request;
|
||||||
|
Status = NtReplyPort (WinSrvApiPort, Reply);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=====================================================================
|
||||||
|
* PUBLIC API
|
||||||
|
*===================================================================*/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ConServerDllInitialization (ULONG ArgumentCount,
|
||||||
|
LPWSTR *Argument)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DPRINT("WINSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
// Get the listening port from csrsrv.dll
|
||||||
|
WinSrvApiPort = CsrQueryApiPort ();
|
||||||
|
if (NULL == WinSrvApiPort)
|
||||||
|
{
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
// Register our message dispatcher
|
||||||
|
Status = CsrAddStaticServerThread (ConStaticServerThread);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
//TODO: perform the real console server internal initialization here
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL UserServerDllInitialization (ULONG ArgumentCount,
|
||||||
|
LPWSTR *Argument)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DPRINT("WINSRV: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
// Get the listening port from csrsrv.dll
|
||||||
|
WinSrvApiPort = CsrQueryApiPort ();
|
||||||
|
if (NULL == WinSrvApiPort)
|
||||||
|
{
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
// Register our message dispatcher
|
||||||
|
Status = CsrAddStaticServerThread (UserStaticServerThread);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
//TODO: perform the real user server internal initialization here
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
32
reactos/subsys/win/winsrv/server.c
Normal file
32
reactos/subsys/win/winsrv/server.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* server.c - ReactOS/Win32 Console+User Enviroment Subsystem 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
|
||||||
|
* 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 "winsrv.h"
|
||||||
|
|
||||||
|
//#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
6
reactos/subsys/win/winsrv/winsrv.def
Normal file
6
reactos/subsys/win/winsrv/winsrv.def
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
; $Id$
|
||||||
|
LIBRARY winsrv.dll
|
||||||
|
EXPORTS
|
||||||
|
ConServerDllInitialization@8
|
||||||
|
UserServerDllInitialization@8
|
||||||
|
; EOF
|
15
reactos/subsys/win/winsrv/winsrv.h
Normal file
15
reactos/subsys/win/winsrv/winsrv.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef _WINSRV_H_INCLUDED_
|
||||||
|
#define _WINSRV_H_INCLUDED_
|
||||||
|
|
||||||
|
/* PSDK/NDK Headers */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
|
#include <csr/server.h>
|
||||||
|
#include <win/base.h>
|
||||||
|
#include <win/windows.h>
|
||||||
|
|
||||||
|
#endif /* ndef _WINSRV_H_INCLUDED_ */
|
4
reactos/subsys/win/winsrv/winsrv.rc
Normal file
4
reactos/subsys/win/winsrv/winsrv.rc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS/VMS Environment Subsystem Server\0"
|
||||||
|
#define REACTOS_STR_INTERNAL_NAME "vmsss\0"
|
||||||
|
#define REACTOS_STR_ORIGINAL_FILENAME "vmsss.exe\0"
|
||||||
|
#include <reactos/version.rc>
|
16
reactos/subsys/win/winsrv/winsrv.xml
Normal file
16
reactos/subsys/win/winsrv/winsrv.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<module name="winsrv" type="win32dll">
|
||||||
|
<importlibrary definition="winsrv.def" />
|
||||||
|
<include base="winsrv">.</include>
|
||||||
|
<include base="csr">include</include>
|
||||||
|
<define name="__USE_W32API" />
|
||||||
|
<library>ntdll</library>
|
||||||
|
<library>csrsrv</library>
|
||||||
|
<library>kernel32</library>
|
||||||
|
<library>user32</library>
|
||||||
|
<library>gdi32</library>
|
||||||
|
<file>dllmain.c</file>
|
||||||
|
<file>init.c</file>
|
||||||
|
<file>server.c</file>
|
||||||
|
<file>winsrv.rc</file>
|
||||||
|
</module>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue