2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2005-05-08 04:07:56 +00:00
|
|
|
*
|
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 ******************************************************************/
|
|
|
|
|
2005-07-26 08:55:25 +00:00
|
|
|
#include <csrss.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;
|
2005-06-02 13:17:37 +00:00
|
|
|
extern PRTL_USER_PROCESS_PARAMETERS RtlProcessParameters;
|
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,
|
2005-04-11 22:37:46 +00:00
|
|
|
OBJ_OPENIF,
|
2000-02-27 02:12:07 +00:00
|
|
|
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;
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\??\\DISPLAY1");
|
2002-06-14 14:23:14 +00:00
|
|
|
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();
|
|
|
|
|
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[] =
|
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CSRSS_DEFINE_API(CREATE_PROCESS, CsrCreateProcess),
|
|
|
|
CSRSS_DEFINE_API(TERMINATE_PROCESS, CsrTerminateProcess),
|
|
|
|
CSRSS_DEFINE_API(CONNECT_PROCESS, CsrConnectProcess),
|
|
|
|
CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, CsrRegisterServicesProcess),
|
|
|
|
CSRSS_DEFINE_API(GET_SHUTDOWN_PARAMETERS, CsrGetShutdownParameters),
|
|
|
|
CSRSS_DEFINE_API(SET_SHUTDOWN_PARAMETERS, CsrSetShutdownParameters),
|
|
|
|
CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle),
|
|
|
|
CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle),
|
|
|
|
CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle),
|
|
|
|
CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle),
|
|
|
|
CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle),
|
|
|
|
CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
|
|
|
|
{ 0, 0, NULL }
|
2003-12-02 11:38:47 +00:00
|
|
|
};
|
|
|
|
|
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,
|
2005-07-12 01:56:14 +00:00
|
|
|
0,
|
|
|
|
0,
|
2005-03-20 22:55:05 +00:00
|
|
|
(PTHREAD_START_ROUTINE) ListenThread,
|
|
|
|
Port,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* === INIT ROUTINES === */
|
|
|
|
|
2005-02-19 22:56:59 +00:00
|
|
|
/**********************************************************************
|
2005-06-02 13:17:37 +00:00
|
|
|
* CsrpCreateHeap/2
|
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
|
|
|
/**********************************************************************
|
2005-06-02 13:17:37 +00:00
|
|
|
* CsrpCreateCallbackPort/2
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
|
|
|
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-05-08 04:07:56 +00:00
|
|
|
return Status;
|
2005-02-19 22:56:59 +00:00
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
2005-06-02 13:17:37 +00:00
|
|
|
* CsrpLoadKernelModeDriver/2
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpLoadKernelModeDriver (ULONG argc, PWSTR* argv)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
WCHAR Data [MAX_PATH + 1];
|
|
|
|
ULONG DataLength = sizeof Data;
|
|
|
|
ULONG DataType = 0;
|
|
|
|
|
|
|
|
|
|
|
|
DPRINT("SM: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
Status = SmLookupSubsystem (L"Kmode",
|
|
|
|
Data,
|
|
|
|
& DataLength,
|
|
|
|
& DataType,
|
|
|
|
RtlProcessParameters->Environment);
|
|
|
|
if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
|
|
|
|
{
|
|
|
|
WCHAR ImagePath [MAX_PATH + 1] = {0};
|
2005-06-20 11:56:10 +00:00
|
|
|
UNICODE_STRING ModuleName;
|
2005-06-02 13:17:37 +00:00
|
|
|
|
|
|
|
wcscpy (ImagePath, L"\\??\\");
|
|
|
|
wcscat (ImagePath, Data);
|
2005-06-20 11:56:10 +00:00
|
|
|
RtlInitUnicodeString (& ModuleName, ImagePath);
|
|
|
|
Status = NtSetSystemInformation(/* FIXME: SystemLoadAndCallImage */
|
|
|
|
SystemExtendServiceTableInformation,
|
|
|
|
& ModuleName,
|
|
|
|
sizeof ModuleName);
|
2005-06-02 13:17:37 +00:00
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCreateApiPort/2
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
2005-09-07 19:37:28 +00:00
|
|
|
ULONG Dummy;
|
|
|
|
ULONG DummyLength = sizeof(Dummy);
|
|
|
|
return CsrClientConnectToServer(L"\\Windows",
|
|
|
|
0, &Dummy, &DummyLength, NULL);
|
2005-03-20 22:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* 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;
|
2005-07-12 01:56:14 +00:00
|
|
|
RTL_USER_PROCESS_INFORMATION ProcessInfo;
|
2005-03-20 22:55:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 [] = {
|
2005-06-02 13:17:37 +00:00
|
|
|
{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, CsrpLoadKernelModeDriver, "load Kmode driver"},
|
|
|
|
{TRUE, CsrpInitVideo, "initialize video"},
|
|
|
|
{TRUE, CsrpApiRegisterDef, "initialize api definitions"},
|
|
|
|
{TRUE, CsrpCCTS, "connect client to server"},
|
|
|
|
{TRUE, CsrpInitWin32Csr, "load usermode dll"},
|
|
|
|
{TRUE, CsrpRunWinlogon, "run WinLogon"},
|
2005-03-20 22:55:05 +00:00
|
|
|
};
|
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-07-05 22:35:29 +00:00
|
|
|
UINT i = 0;
|
2005-03-20 22:55:05 +00:00
|
|
|
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))
|
|
|
|
{
|
2005-05-08 04:07:56 +00:00
|
|
|
DPRINT1("CSR: %s: failed to %s (Status=%08lx)\n",
|
2005-03-20 22:55:05 +00:00
|
|
|
__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 */
|