2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
1999-06-08 22:50:59 +00:00
|
|
|
*
|
|
|
|
* reactos/subsys/csrss/init.c
|
|
|
|
*
|
|
|
|
* Initialize the CSRSS subsystem server process.
|
|
|
|
*
|
|
|
|
* ReactOS Operating System
|
|
|
|
*
|
|
|
|
*/
|
1999-12-22 14:48:30 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2004-04-09 20:03:21 +00:00
|
|
|
#include <csrss/csrss.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
2003-12-02 11:38:47 +00:00
|
|
|
#include <ntdll/csr.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ntdll/rtl.h>
|
2003-12-02 11:38:47 +00:00
|
|
|
#include <ntdll/ldr.h>
|
2002-10-31 01:50:00 +00:00
|
|
|
#include <win32k/win32k.h>
|
2003-11-17 02:12:52 +00:00
|
|
|
#include <rosrtl/string.h>
|
2005-02-19 22:56:59 +00:00
|
|
|
#include <sm/helper.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
#include "api.h"
|
2003-12-02 11:38:47 +00:00
|
|
|
#include "csrplugin.h"
|
1999-06-08 22:50:59 +00:00
|
|
|
|
2005-02-19 23:07:22 +00:00
|
|
|
#define NDEBUG
|
2003-08-11 18:50:12 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
1999-06-08 22:50:59 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE CsrHeap = (HANDLE) 0;
|
2000-02-27 02:12:07 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE CsrObjectDirectory = (HANDLE) 0;
|
2000-02-27 02:12:07 +00:00
|
|
|
|
|
|
|
UNICODE_STRING CsrDirectoryName;
|
|
|
|
|
2000-04-23 17:44:53 +00:00
|
|
|
extern HANDLE CsrssApiHeap;
|
2000-02-27 02:12:07 +00:00
|
|
|
|
2004-05-28 21:33:41 +00:00
|
|
|
static unsigned InitCompleteProcCount;
|
|
|
|
static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE hSbApiPort = (HANDLE) 0;
|
|
|
|
|
|
|
|
HANDLE hBootstrapOk = (HANDLE) 0;
|
|
|
|
|
|
|
|
HANDLE hSmApiPort = (HANDLE) 0;
|
|
|
|
|
|
|
|
HANDLE hApiPort = (HANDLE) 0;
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpAddInitCompleteProc/1
|
|
|
|
*/
|
2004-05-28 21:33:41 +00:00
|
|
|
static NTSTATUS FASTCALL
|
2005-03-20 22:55:05 +00:00
|
|
|
CsrpAddInitCompleteProc(CSRPLUGIN_INIT_COMPLETE_PROC Proc)
|
2004-05-28 21:33:41 +00:00
|
|
|
{
|
|
|
|
CSRPLUGIN_INIT_COMPLETE_PROC *NewProcs;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
2004-05-28 21:33:41 +00:00
|
|
|
NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
|
|
|
|
(InitCompleteProcCount + 1)
|
|
|
|
* sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
|
|
|
|
if (NULL == NewProcs)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
if (0 != InitCompleteProcCount)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(NewProcs, InitCompleteProcs,
|
|
|
|
InitCompleteProcCount * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
|
|
|
|
}
|
|
|
|
NewProcs[InitCompleteProcCount] = Proc;
|
|
|
|
InitCompleteProcs = NewProcs;
|
|
|
|
InitCompleteProcCount++;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CallInitComplete/0
|
|
|
|
*/
|
2004-05-28 21:33:41 +00:00
|
|
|
static BOOL FASTCALL
|
|
|
|
CallInitComplete(void)
|
|
|
|
{
|
|
|
|
BOOL Ok;
|
|
|
|
unsigned i;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
2004-05-28 21:33:41 +00:00
|
|
|
Ok = TRUE;
|
|
|
|
if (0 != InitCompleteProcCount)
|
|
|
|
{
|
|
|
|
for (i = 0; i < InitCompleteProcCount && Ok; i++)
|
|
|
|
{
|
|
|
|
Ok = (*(InitCompleteProcs[i]))();
|
|
|
|
}
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2001-03-25 03:34:30 +00:00
|
|
|
ULONG
|
|
|
|
InitializeVideoAddressSpace(VOID);
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpParseCommandLine/2
|
|
|
|
*/
|
2000-02-27 02:12:07 +00:00
|
|
|
static NTSTATUS
|
2005-03-20 22:55:05 +00:00
|
|
|
CsrpParseCommandLine (
|
2000-02-27 02:12:07 +00:00
|
|
|
ULONG ArgumentCount,
|
|
|
|
PWSTR *ArgumentArray
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
OBJECT_ATTRIBUTES Attributes;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
2000-02-27 02:12:07 +00:00
|
|
|
|
2000-05-26 05:43:33 +00:00
|
|
|
/* DbgPrint ("Arguments: %ld\n", ArgumentCount);
|
2000-02-27 02:12:07 +00:00
|
|
|
for (i = 0; i < ArgumentCount; i++)
|
|
|
|
{
|
|
|
|
DbgPrint ("Argument %ld: %S\n", i, ArgumentArray[i]);
|
2000-05-26 05:43:33 +00:00
|
|
|
}*/
|
2000-02-27 02:12:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* create object directory ('\Windows') */
|
|
|
|
RtlCreateUnicodeString (&CsrDirectoryName,
|
|
|
|
L"\\Windows");
|
|
|
|
|
|
|
|
InitializeObjectAttributes (&Attributes,
|
|
|
|
&CsrDirectoryName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2005-04-08 20:29:30 +00:00
|
|
|
Status = NtOpenDirectoryObject(&CsrObjectDirectory,
|
|
|
|
0xF000F, /* ea:??? */
|
|
|
|
&Attributes);
|
2000-02-27 02:12:07 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpInitVideo/0
|
|
|
|
*
|
|
|
|
* TODO: we need a virtual device for sessions other than
|
|
|
|
* TODO: the console one
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpInitVideo (ULONG argc, PWSTR* argv)
|
2002-06-14 14:23:14 +00:00
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
IO_STATUS_BLOCK Iosb;
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE VideoHandle = (HANDLE) 0;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
2002-06-14 14:23:14 +00:00
|
|
|
|
2003-06-17 13:55:16 +00:00
|
|
|
InitializeVideoAddressSpace();
|
|
|
|
|
2003-11-17 02:12:52 +00:00
|
|
|
RtlRosInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1");
|
2002-06-14 14:23:14 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&DeviceName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = NtOpenFile(&VideoHandle,
|
|
|
|
FILE_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&Iosb,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
NtClose(VideoHandle);
|
|
|
|
}
|
2005-03-20 22:55:05 +00:00
|
|
|
return Status;
|
2002-06-14 14:23:14 +00:00
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpInitWin32Csr/0
|
|
|
|
*
|
|
|
|
* TODO: this function should be turned more general to load an
|
|
|
|
* TODO: hosted server DLL as received from the command line;
|
|
|
|
* TODO: for instance: ServerDll=winsrv:ConServerDllInitialization,2
|
|
|
|
* TODO: ^method ^dll ^api ^sid
|
|
|
|
* TODO:
|
|
|
|
* TODO: CsrpHostServerDll (LPWSTR DllName,
|
|
|
|
* TODO: LPWSTR ApiName,
|
|
|
|
* TODO: DWORD ServerId)
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpInitWin32Csr (ULONG argc, PWSTR* argv)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
UNICODE_STRING DllName;
|
|
|
|
HINSTANCE hInst;
|
|
|
|
ANSI_STRING ProcName;
|
|
|
|
CSRPLUGIN_INITIALIZE_PROC InitProc;
|
|
|
|
CSRSS_EXPORTED_FUNCS Exports;
|
|
|
|
PCSRSS_API_DEFINITION ApiDefinitions;
|
|
|
|
PCSRSS_OBJECT_DEFINITION ObjectDefinitions;
|
2004-05-28 21:33:41 +00:00
|
|
|
CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
RtlInitUnicodeString(&DllName, L"win32csr.dll");
|
|
|
|
Status = LdrLoadDll(NULL, 0, &DllName, (PVOID *) &hInst);
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
RtlInitAnsiString(&ProcName, "Win32CsrInitialization");
|
|
|
|
Status = LdrGetProcedureAddress(hInst, &ProcName, 0, (PVOID *) &InitProc);
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
Exports.CsrInsertObjectProc = CsrInsertObject;
|
|
|
|
Exports.CsrGetObjectProc = CsrGetObject;
|
|
|
|
Exports.CsrReleaseObjectProc = CsrReleaseObject;
|
2004-05-28 21:33:41 +00:00
|
|
|
if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
|
|
|
|
&Exports, CsrssApiHeap))
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = CsrApiRegisterDefinitions(ApiDefinitions);
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
Status = CsrRegisterObjectDefinitions(ObjectDefinitions);
|
2004-05-28 21:33:41 +00:00
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
if (NULL != InitCompleteProc)
|
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
Status = CsrpAddInitCompleteProc(InitCompleteProc);
|
2004-05-28 21:33:41 +00:00
|
|
|
}
|
2003-12-02 11:38:47 +00:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSRSS_API_DEFINITION NativeDefinitions[] =
|
|
|
|
{
|
|
|
|
CSRSS_DEFINE_API(CSRSS_CREATE_PROCESS, CsrCreateProcess),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_TERMINATE_PROCESS, CsrTerminateProcess),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_CONNECT_PROCESS, CsrConnectProcess),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_REGISTER_SERVICES_PROCESS, CsrRegisterServicesProcess),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_GET_SHUTDOWN_PARAMETERS, CsrGetShutdownParameters),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_SET_SHUTDOWN_PARAMETERS, CsrSetShutdownParameters),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_GET_INPUT_HANDLE, CsrGetInputHandle),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_GET_OUTPUT_HANDLE, CsrGetOutputHandle),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_CLOSE_HANDLE, CsrCloseHandle),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_VERIFY_HANDLE, CsrVerifyHandle),
|
|
|
|
CSRSS_DEFINE_API(CSRSS_DUPLICATE_HANDLE, CsrDuplicateHandle),
|
2004-11-14 18:47:10 +00:00
|
|
|
CSRSS_DEFINE_API(CSRSS_GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
|
2003-12-02 11:38:47 +00:00
|
|
|
{ 0, 0, 0, NULL }
|
|
|
|
};
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
static NTSTATUS STDCALL
|
|
|
|
CsrpCreateListenPort (IN LPWSTR Name,
|
|
|
|
IN OUT PHANDLE Port,
|
|
|
|
IN PTHREAD_START_ROUTINE ListenThread)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
OBJECT_ATTRIBUTES PortAttributes;
|
|
|
|
UNICODE_STRING PortName;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
RtlInitUnicodeString (& PortName, Name);
|
|
|
|
InitializeObjectAttributes (& PortAttributes,
|
|
|
|
& PortName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = NtCreatePort ( Port,
|
|
|
|
& PortAttributes,
|
|
|
|
260, /* TODO: make caller set it*/
|
|
|
|
328, /* TODO: make caller set it*/
|
|
|
|
0); /* TODO: make caller set it*/
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtCreatePort failed (Status=%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
Status = RtlCreateUserThread(NtCurrentProcess(),
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(PTHREAD_START_ROUTINE) ListenThread,
|
|
|
|
Port,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* === INIT ROUTINES === */
|
|
|
|
|
2005-02-19 22:56:59 +00:00
|
|
|
/**********************************************************************
|
2005-03-20 22:55:05 +00:00
|
|
|
* CsrpCreateCallbackPort/0
|
2005-02-19 22:56:59 +00:00
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
static NTSTATUS
|
|
|
|
CsrpCreateHeap (ULONG argc, PWSTR* argv)
|
2005-02-19 22:56:59 +00:00
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
|
|
|
|
NULL,
|
|
|
|
65536,
|
|
|
|
65536,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (CsrssApiHeap == NULL)
|
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-02-19 22:56:59 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCreateCallbackPort/0
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpCreateCallbackPort (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
return CsrpCreateListenPort (L"\\Windows\\SbApiPort",
|
|
|
|
& hSbApiPort,
|
|
|
|
ServerSbApiPortThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpRegisterSubsystem/2
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpRegisterSubsystem (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
OBJECT_ATTRIBUTES BootstrapOkAttributes;
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the event object the callback port
|
|
|
|
* thread will signal *if* the SM will
|
|
|
|
* authorize us to bootstrap.
|
|
|
|
*/
|
|
|
|
RtlInitUnicodeString (& Name, L"\\CsrssBooting");
|
|
|
|
InitializeObjectAttributes(& BootstrapOkAttributes,
|
|
|
|
& Name,
|
|
|
|
0, NULL, NULL);
|
|
|
|
Status = NtCreateEvent (& hBootstrapOk,
|
|
|
|
EVENT_ALL_ACCESS,
|
|
|
|
& BootstrapOkAttributes,
|
|
|
|
SynchronizationEvent,
|
|
|
|
FALSE);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT("CSR: %s: NtCreateEvent failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Let's tell the SM a new environment
|
|
|
|
* subsystem server is in the system.
|
|
|
|
*/
|
|
|
|
RtlInitUnicodeString (& Name, L"\\Windows\\SbApiPort");
|
|
|
|
DPRINT("CSR: %s: registering with SM for\n IMAGE_SUBSYSTEM_WINDOWS_CUI == 3\n", __FUNCTION__);
|
|
|
|
Status = SmConnectApiPort (& Name,
|
|
|
|
hSbApiPort,
|
2005-02-19 22:56:59 +00:00
|
|
|
IMAGE_SUBSYSTEM_WINDOWS_CUI,
|
2005-03-20 22:55:05 +00:00
|
|
|
& hSmApiPort);
|
2005-02-19 22:56:59 +00:00
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s unable to connect to the SM (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
NtClose (hBootstrapOk);
|
2005-02-19 22:56:59 +00:00
|
|
|
return Status;
|
|
|
|
}
|
2005-03-20 22:55:05 +00:00
|
|
|
/*
|
|
|
|
* Wait for SM to reply OK... If the SM
|
|
|
|
* won't answer, we hang here forever!
|
|
|
|
*/
|
|
|
|
DPRINT("CSR: %s: waiting for SM to OK boot...\n", __FUNCTION__);
|
|
|
|
Status = NtWaitForSingleObject (hBootstrapOk,
|
|
|
|
FALSE,
|
|
|
|
NULL);
|
|
|
|
NtClose (hBootstrapOk);
|
2005-02-19 22:56:59 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCreateApiPort/0
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpCreateApiPort (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
return CsrpCreateListenPort (L"\\Windows\\ApiPort",
|
|
|
|
& hApiPort,
|
|
|
|
ServerApiPortThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpApiRegisterDef/0
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpApiRegisterDef (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
return CsrApiRegisterDefinitions(NativeDefinitions);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCCTS/2
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpCCTS (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
return CsrClientConnectToServer();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpRunWinlogon/0
|
|
|
|
*
|
|
|
|
* Start the logon process (winlogon.exe).
|
|
|
|
*
|
|
|
|
* TODO: this should be moved in CsrpCreateSession/x (one per session)
|
|
|
|
* TODO: in its own desktop (one logon desktop per winstation).
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpRunWinlogon (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
UNICODE_STRING ImagePath;
|
|
|
|
UNICODE_STRING CommandLine;
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
|
|
|
|
RTL_PROCESS_INFO ProcessInfo;
|
|
|
|
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
/* initialize the process parameters */
|
|
|
|
RtlInitUnicodeString (& ImagePath, L"\\SystemRoot\\system32\\winlogon.exe");
|
|
|
|
RtlInitUnicodeString (& CommandLine, L"");
|
|
|
|
RtlCreateProcessParameters(& ProcessParameters,
|
|
|
|
& ImagePath,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
& CommandLine,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
/* Create the winlogon process */
|
|
|
|
Status = RtlCreateUserProcess (& ImagePath,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
ProcessParameters,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
& ProcessInfo);
|
|
|
|
/* Cleanup */
|
|
|
|
RtlDestroyProcessParameters (ProcessParameters);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2005-04-02 00:18:46 +00:00
|
|
|
DPRINT1("SM: %s: loading winlogon.exe failed (Status=%08lx)\n",
|
2005-03-20 22:55:05 +00:00
|
|
|
__FUNCTION__, Status);
|
|
|
|
}
|
2005-04-02 00:18:46 +00:00
|
|
|
ZwResumeThread(ProcessInfo.ThreadHandle, NULL);
|
2005-03-20 22:55:05 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef NTSTATUS (* CSR_INIT_ROUTINE)(ULONG, PWSTR*);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
BOOL Required;
|
|
|
|
CSR_INIT_ROUTINE EntryPoint;
|
|
|
|
PCHAR ErrorMessage;
|
|
|
|
} InitRoutine [] = {
|
|
|
|
{TRUE, CsrpCreateCallbackPort, "create the callback port \\Windows\\SbApiPort"},
|
|
|
|
{TRUE, CsrpRegisterSubsystem, "register with SM"},
|
|
|
|
{TRUE, CsrpCreateHeap, "create the CSR heap"},
|
|
|
|
{TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
|
|
|
|
{TRUE, CsrpParseCommandLine, "parse the command line"},
|
|
|
|
{TRUE, CsrpInitVideo, "initialize video"},
|
|
|
|
{TRUE, CsrpApiRegisterDef, "initialize api definitions"},
|
|
|
|
{TRUE, CsrpCCTS, "connect client to server"},
|
|
|
|
{TRUE, CsrpInitWin32Csr, "load usermode dll"},
|
|
|
|
{TRUE, CsrpRunWinlogon, "run WinLogon"},
|
|
|
|
};
|
2002-06-14 14:23:14 +00:00
|
|
|
|
1999-07-17 23:10:31 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
2000-02-27 02:12:07 +00:00
|
|
|
* CsrServerInitialization
|
1999-07-17 23:10:31 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
2005-03-20 22:55:05 +00:00
|
|
|
* Initialize the Win32 environment subsystem server.
|
1999-07-17 23:10:31 +00:00
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
* TRUE: Initialization OK; otherwise FALSE.
|
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
BOOL STDCALL
|
2000-02-27 02:12:07 +00:00
|
|
|
CsrServerInitialization (
|
|
|
|
ULONG ArgumentCount,
|
|
|
|
PWSTR *ArgumentArray
|
|
|
|
)
|
1999-06-08 22:50:59 +00:00
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
INT i = 0;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
|
|
|
|
{
|
|
|
|
Status = InitRoutine[i].EntryPoint(ArgumentCount,ArgumentArray);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: failed to %s (Status=%08lx)\n",
|
|
|
|
__FUNCTION__,
|
|
|
|
InitRoutine[i].ErrorMessage,
|
|
|
|
Status);
|
|
|
|
if (InitRoutine[i].Required)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CallInitComplete())
|
|
|
|
{
|
|
|
|
Status = SmCompleteSession (hSmApiPort,hSbApiPort,hApiPort);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
1999-06-08 22:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|