2010-03-10 04:59:39 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS CSR Sub System
|
|
|
|
* FILE: subsys/csr/csrsrv/init.c
|
|
|
|
* PURPOSE: CSR Server DLL Initialization
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
1999-06-08 22:50:59 +00:00
|
|
|
*/
|
1999-12-22 14:48:30 +00:00
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
/* INCLUDES *******************************************************************/
|
1999-06-08 22:50:59 +00:00
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
#include "srv.h"
|
2005-02-19 23:07:22 +00:00
|
|
|
#define NDEBUG
|
2003-08-11 18:50:12 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
/* DATA ***********************************************************************/
|
1999-06-08 22:50:59 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE CsrHeap = (HANDLE) 0;
|
|
|
|
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;
|
2010-05-22 23:47:54 +00:00
|
|
|
static unsigned ServerProcCount;
|
|
|
|
static CSRPLUGIN_SERVER_PROCS *ServerProcs = 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;
|
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
|
|
|
|
|
|
|
ULONG
|
|
|
|
InitializeVideoAddressSpace(VOID)
|
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING PhysMemName = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE PhysMemHandle;
|
|
|
|
PVOID BaseAddress;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
SIZE_T ViewSize;
|
|
|
|
CHAR IVTAndBda[1024+256];
|
[SMSS]: Remove the ROS_DOESNT_SUCK hack, and correctly started subsystem processes with the first MB reserved.
[CSRSRV]: CSRSS was started with a free address space, and was able to map 0xA0000 into it by luck, because the ReactOS Mm allocator picks address ranges randomly, and it somehow managed to avoid the low 1MB addresses. Were this algorithm to change, or perhaps, were we to implement VADs for VM allocations, the 0xA0000 region might already be allocated (by an early-process-initialization allocation, such as the heap). This is what the flag referenced above was designed for, but it was not used. Using this flag, on the other hand, now makes CSRSS fail, because it attempts to map the RAM into 0xA0000, which fails since you can map a section on top of reserved memory. To work around this Brobdingnagian annoyance, CSRSS simply releases the first MB of memory that SMSS has nicely reserved for it, and then proceeds with the mapping. This fixes the issue of getting 0xA0000 by luck and now guarantees it can be mapped.
svn path=/trunk/; revision=49133
2010-10-12 21:17:58 +00:00
|
|
|
|
|
|
|
/* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */
|
|
|
|
BaseAddress = 0;
|
|
|
|
ViewSize = 1024 * 1024;
|
|
|
|
Status = ZwFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
&BaseAddress,
|
|
|
|
&ViewSize,
|
|
|
|
MEM_RELEASE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Couldn't unmap reserved memory (%x)\n", Status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
/* Open the physical memory section */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&PhysMemName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = ZwOpenSection(&PhysMemHandle,
|
|
|
|
SECTION_ALL_ACCESS,
|
|
|
|
&ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Couldn't open \\Device\\PhysicalMemory\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map the BIOS and device registers into the address space */
|
|
|
|
Offset.QuadPart = 0xa0000;
|
|
|
|
ViewSize = 0x100000 - 0xa0000;
|
|
|
|
BaseAddress = (PVOID)0xa0000;
|
|
|
|
Status = ZwMapViewOfSection(PhysMemHandle,
|
|
|
|
NtCurrentProcess(),
|
|
|
|
&BaseAddress,
|
|
|
|
0,
|
|
|
|
ViewSize,
|
|
|
|
&Offset,
|
|
|
|
&ViewSize,
|
|
|
|
ViewUnmap,
|
|
|
|
0,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Couldn't map physical memory (%x)\n", Status);
|
|
|
|
ZwClose(PhysMemHandle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close physical memory section handle */
|
|
|
|
ZwClose(PhysMemHandle);
|
|
|
|
|
|
|
|
if (BaseAddress != (PVOID)0xa0000)
|
|
|
|
{
|
|
|
|
DPRINT1("Couldn't map physical memory at the right address (was %x)\n",
|
|
|
|
BaseAddress);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate some low memory to use for the non-BIOS
|
|
|
|
* parts of the v86 mode address space
|
|
|
|
*/
|
|
|
|
BaseAddress = (PVOID)0x1;
|
|
|
|
ViewSize = 0xa0000 - 0x1000;
|
|
|
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
|
|
|
&BaseAddress,
|
|
|
|
0,
|
|
|
|
&ViewSize,
|
2010-10-16 21:04:50 +00:00
|
|
|
MEM_RESERVE | MEM_COMMIT,
|
2010-03-10 04:59:39 +00:00
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Failed to allocate virtual memory (Status %x)\n", Status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (BaseAddress != (PVOID)0x0)
|
|
|
|
{
|
|
|
|
DPRINT1("Failed to allocate virtual memory at right address (was %x)\n",
|
|
|
|
BaseAddress);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the real mode IVT and BDA from the kernel */
|
|
|
|
Status = NtVdmControl(VdmInitialize, IVTAndBda);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtVdmControl failed (status %x)\n", Status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-28 21:33:41 +00:00
|
|
|
static NTSTATUS FASTCALL
|
2010-05-22 23:47:54 +00:00
|
|
|
CsrpAddServerProcs(CSRPLUGIN_SERVER_PROCS *Procs)
|
2004-05-28 21:33:41 +00:00
|
|
|
{
|
2010-05-22 23:47:54 +00:00
|
|
|
CSRPLUGIN_SERVER_PROCS *NewProcs;
|
2004-05-28 21:33:41 +00:00
|
|
|
|
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,
|
2010-05-22 23:47:54 +00:00
|
|
|
(ServerProcCount + 1)
|
|
|
|
* sizeof(CSRPLUGIN_SERVER_PROCS));
|
2004-05-28 21:33:41 +00:00
|
|
|
if (NULL == NewProcs)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2010-05-22 23:47:54 +00:00
|
|
|
if (0 != ServerProcCount)
|
2004-05-28 21:33:41 +00:00
|
|
|
{
|
2010-05-22 23:47:54 +00:00
|
|
|
RtlCopyMemory(NewProcs, ServerProcs,
|
|
|
|
ServerProcCount * sizeof(CSRPLUGIN_SERVER_PROCS));
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, ServerProcs);
|
2004-05-28 21:33:41 +00:00
|
|
|
}
|
2010-05-22 23:47:54 +00:00
|
|
|
NewProcs[ServerProcCount] = *Procs;
|
|
|
|
ServerProcs = NewProcs;
|
|
|
|
ServerProcCount++;
|
2004-05-28 21:33:41 +00:00
|
|
|
|
|
|
|
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;
|
2010-05-22 23:47:54 +00:00
|
|
|
for (i = 0; i < ServerProcCount && Ok; i++)
|
2004-05-28 21:33:41 +00:00
|
|
|
{
|
2010-05-22 23:47:54 +00:00
|
|
|
Ok = (*ServerProcs[i].InitCompleteProc)();
|
2004-05-28 21:33:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2006-10-30 14:20:45 +00:00
|
|
|
BOOL
|
2007-12-22 17:18:32 +00:00
|
|
|
CallHardError(IN PCSRSS_PROCESS_DATA ProcessData,
|
|
|
|
IN PHARDERROR_MSG HardErrorMessage)
|
2006-10-30 14:20:45 +00:00
|
|
|
{
|
|
|
|
BOOL Ok;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
Ok = TRUE;
|
2010-05-22 23:47:54 +00:00
|
|
|
for (i = 0; i < ServerProcCount && Ok; i++)
|
2006-10-30 14:20:45 +00:00
|
|
|
{
|
2010-05-22 23:47:54 +00:00
|
|
|
Ok = (*ServerProcs[i].HardErrorProc)(ProcessData, HardErrorMessage);
|
2006-10-30 14:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2010-05-22 23:47:54 +00:00
|
|
|
NTSTATUS
|
|
|
|
CallProcessInherit(IN PCSRSS_PROCESS_DATA SourceProcessData,
|
|
|
|
IN PCSRSS_PROCESS_DATA TargetProcessData)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
for (i = 0; i < ServerProcCount && NT_SUCCESS(Status); i++)
|
|
|
|
Status = (*ServerProcs[i].ProcessInheritProc)(SourceProcessData, TargetProcessData);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CallProcessDeleted(IN PCSRSS_PROCESS_DATA ProcessData)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
for (i = 0; i < ServerProcCount && NT_SUCCESS(Status); i++)
|
|
|
|
Status = (*ServerProcs[i].ProcessDeletedProc)(ProcessData);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-25 03:34:30 +00:00
|
|
|
ULONG
|
|
|
|
InitializeVideoAddressSpace(VOID);
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
2005-10-08 22:41:49 +00:00
|
|
|
* CsrpCreateObjectDirectory/3
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
2000-02-27 02:12:07 +00:00
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpCreateObjectDirectory (int argc, char ** argv, char ** envp)
|
2000-02-27 02:12:07 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
/* 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,
|
2007-01-20 13:29:04 +00:00
|
|
|
DIRECTORY_ALL_ACCESS,
|
2005-04-08 20:29:30 +00:00
|
|
|
&Attributes);
|
2000-02-27 02:12:07 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
/**********************************************************************
|
2005-10-08 22:41:49 +00:00
|
|
|
* CsrpInitVideo/3
|
2005-03-20 22:55:05 +00:00
|
|
|
*
|
|
|
|
* TODO: we need a virtual device for sessions other than
|
|
|
|
* TODO: the console one
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpInitVideo (int argc, char ** argv, char ** envp)
|
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
|
|
|
/**********************************************************************
|
2005-10-08 22:41:49 +00:00
|
|
|
* CsrpInitWin32Csr/3
|
2005-03-20 22:55:05 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpInitWin32Csr (int argc, char ** argv, char ** envp)
|
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;
|
2010-05-22 23:47:54 +00:00
|
|
|
CSRPLUGIN_SERVER_PROCS ServerProcs;
|
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;
|
|
|
|
}
|
2005-12-01 22:38:03 +00:00
|
|
|
Exports.CsrEnumProcessesProc = CsrEnumProcesses;
|
2010-05-22 23:47:54 +00:00
|
|
|
if (! (*InitProc)(&ApiDefinitions, &ServerProcs, &Exports, CsrssApiHeap))
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = CsrApiRegisterDefinitions(ApiDefinitions);
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
2010-05-22 23:47:54 +00:00
|
|
|
Status = CsrpAddServerProcs(&ServerProcs);
|
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),
|
2010-03-10 06:49:53 +00:00
|
|
|
CSRSS_DEFINE_API(CREATE_THREAD, CsrSrvCreateThread),
|
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(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),
|
|
|
|
{ 0, 0, NULL }
|
2003-12-02 11:38:47 +00:00
|
|
|
};
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
static NTSTATUS WINAPI
|
2005-03-20 22:55:05 +00:00
|
|
|
CsrpCreateListenPort (IN LPWSTR Name,
|
|
|
|
IN OUT PHANDLE Port,
|
|
|
|
IN PTHREAD_START_ROUTINE ListenThread)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
OBJECT_ATTRIBUTES PortAttributes;
|
|
|
|
UNICODE_STRING PortName;
|
2010-03-09 20:23:22 +00:00
|
|
|
HANDLE ServerThread;
|
|
|
|
CLIENT_ID ClientId;
|
2005-03-20 22:55:05 +00:00
|
|
|
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
RtlInitUnicodeString (& PortName, Name);
|
|
|
|
InitializeObjectAttributes (& PortAttributes,
|
|
|
|
& PortName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = NtCreatePort ( Port,
|
|
|
|
& PortAttributes,
|
2005-11-27 13:51:28 +00:00
|
|
|
LPC_MAX_DATA_LENGTH, /* TODO: make caller set it*/
|
|
|
|
LPC_MAX_MESSAGE_LENGTH, /* TODO: make caller set it*/
|
2005-03-20 22:55:05 +00:00
|
|
|
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,
|
2010-03-09 20:23:22 +00:00
|
|
|
TRUE,
|
2005-03-20 22:55:05 +00:00
|
|
|
0,
|
2005-07-12 01:56:14 +00:00
|
|
|
0,
|
|
|
|
0,
|
2005-03-20 22:55:05 +00:00
|
|
|
(PTHREAD_START_ROUTINE) ListenThread,
|
2006-10-30 18:45:22 +00:00
|
|
|
*Port,
|
2010-03-09 20:23:22 +00:00
|
|
|
&ServerThread,
|
|
|
|
&ClientId);
|
|
|
|
|
|
|
|
if (ListenThread == (PVOID)ClientConnectionThread)
|
|
|
|
{
|
|
|
|
CsrAddStaticServerThread(ServerThread, &ClientId, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
NtResumeThread(ServerThread, NULL);
|
|
|
|
NtClose(ServerThread);
|
2005-03-20 22:55:05 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* === INIT ROUTINES === */
|
|
|
|
|
2007-08-29 05:57:00 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCreateBNODirectory/3
|
|
|
|
*
|
|
|
|
* These used to be part of kernel32 startup, but that clearly wasn't a good
|
2007-10-19 23:21:45 +00:00
|
|
|
* idea, as races were definately possible. These are moved (as in the
|
2007-08-29 05:57:00 +00:00
|
|
|
* previous fixmes).
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
|
|
|
CsrpCreateBNODirectory (int argc, char ** argv, char ** envp)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\BaseNamedObjects");
|
|
|
|
UNICODE_STRING SymName = RTL_CONSTANT_STRING(L"Local");
|
|
|
|
UNICODE_STRING SymName2 = RTL_CONSTANT_STRING(L"Global");
|
|
|
|
HANDLE DirHandle, SymHandle;
|
|
|
|
|
|
|
|
/* Seems like a good place to create these objects which are needed by
|
|
|
|
* win32 processes */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&Name,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
Status = NtCreateDirectoryObject(&DirHandle,
|
|
|
|
DIRECTORY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/* Create the "local" Symbolic Link.
|
2007-08-29 05:57:00 +00:00
|
|
|
* FIXME: CSR should do this -- Fixed */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&SymName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
DirHandle,
|
|
|
|
NULL);
|
|
|
|
Status = NtCreateSymbolicLinkObject(&SymHandle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&Name);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-08-29 05:57:00 +00:00
|
|
|
/* Create the "global" Symbolic Link. */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&SymName2,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
DirHandle,
|
|
|
|
NULL);
|
|
|
|
Status = NtCreateSymbolicLinkObject(&SymHandle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&Name);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2005-02-19 22:56:59 +00:00
|
|
|
/**********************************************************************
|
2005-10-08 22:41:49 +00:00
|
|
|
* CsrpCreateHeap/3
|
2005-02-19 22:56:59 +00:00
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpCreateHeap (int argc, char ** argv, char ** envp)
|
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-10-08 22:41:49 +00:00
|
|
|
* CsrpCreateCallbackPort/3
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpCreateCallbackPort (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
return CsrpCreateListenPort (L"\\Windows\\SbApiPort",
|
|
|
|
& hSbApiPort,
|
|
|
|
ServerSbApiPortThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2005-10-08 22:41:49 +00:00
|
|
|
* CsrpRegisterSubsystem/3
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpRegisterSubsystem (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
|
|
|
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-10-08 22:41:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CsrpLoadKernelModeDriver/3
|
2005-06-02 13:17:37 +00:00
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp)
|
2005-06-02 13:17:37 +00:00
|
|
|
{
|
2005-10-08 22:41:49 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
WCHAR Data [MAX_PATH + 1];
|
|
|
|
ULONG DataLength = sizeof Data;
|
|
|
|
ULONG DataType = 0;
|
2010-03-10 04:59:39 +00:00
|
|
|
//UNICODE_STRING Environment;
|
2005-06-02 13:17:37 +00:00
|
|
|
|
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
DPRINT1("SM: %s called\n", __FUNCTION__);
|
2005-06-02 13:17:37 +00:00
|
|
|
|
2005-10-08 22:41:49 +00:00
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
//EnvpToUnicodeString (envp, & Environment);
|
2005-06-02 13:17:37 +00:00
|
|
|
Status = SmLookupSubsystem (L"Kmode",
|
|
|
|
Data,
|
|
|
|
& DataLength,
|
|
|
|
& DataType,
|
2010-03-10 04:59:39 +00:00
|
|
|
NULL);
|
|
|
|
//RtlFreeUnicodeString (& Environment);
|
2005-06-02 13:17:37 +00:00
|
|
|
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
|
|
|
|
2010-03-13 15:59:12 +00:00
|
|
|
wcscpy (ImagePath, L"\\SYSTEMROOT\\system32\\win32k.sys");
|
2010-03-10 04:59:39 +00:00
|
|
|
// 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))
|
|
|
|
{
|
2010-03-10 04:59:39 +00:00
|
|
|
DPRINT1("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
|
2005-06-02 13:17:37 +00:00
|
|
|
__FUNCTION__, Status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCreateApiPort/2
|
2005-03-20 22:55:05 +00:00
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpCreateApiPort (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
2007-06-14 16:47:24 +00:00
|
|
|
CsrInitProcessData();
|
|
|
|
|
2007-06-14 19:09:32 +00:00
|
|
|
return CsrpCreateListenPort(L"\\Windows\\ApiPort", &hApiPort,
|
|
|
|
(PTHREAD_START_ROUTINE)ClientConnectionThread);
|
2005-03-20 22:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpApiRegisterDef/0
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpApiRegisterDef (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
|
|
|
return CsrApiRegisterDefinitions(NativeDefinitions);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CsrpCCTS/2
|
|
|
|
*/
|
|
|
|
static NTSTATUS
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpCCTS (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
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
|
2005-10-08 22:41:49 +00:00
|
|
|
CsrpRunWinlogon (int argc, char ** argv, char ** envp)
|
2005-03-20 22:55:05 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2009-06-12 15:44:21 +00:00
|
|
|
|
2005-04-02 00:18:46 +00:00
|
|
|
ZwResumeThread(ProcessInfo.ThreadHandle, NULL);
|
2005-03-20 22:55:05 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2006-10-26 04:55:34 +00:00
|
|
|
static NTSTATUS
|
|
|
|
CsrpCreateHardErrorPort (int argc, char ** argv, char ** envp)
|
|
|
|
{
|
|
|
|
return NtSetDefaultHardErrorPort(hApiPort);
|
|
|
|
}
|
2005-03-20 22:55:05 +00:00
|
|
|
|
2005-10-08 22:41:49 +00:00
|
|
|
typedef NTSTATUS (* CSR_INIT_ROUTINE)(int,char**,char**);
|
2005-03-20 22:55:05 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
BOOL Required;
|
|
|
|
CSR_INIT_ROUTINE EntryPoint;
|
|
|
|
PCHAR ErrorMessage;
|
|
|
|
} InitRoutine [] = {
|
2007-08-29 05:57:00 +00:00
|
|
|
{TRUE, CsrpCreateBNODirectory, "create base named objects directory"},
|
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"},
|
2006-10-26 04:55:34 +00:00
|
|
|
{TRUE, CsrpCreateHardErrorPort, "create the hard error port"},
|
2005-10-08 22:41:49 +00:00
|
|
|
{TRUE, CsrpCreateObjectDirectory,"create the object directory \\Windows"},
|
2005-06-02 13:17:37 +00:00
|
|
|
{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
|
|
|
|
2010-03-10 04:59:39 +00:00
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrServerInitialization(ULONG ArgumentCount,
|
|
|
|
PCHAR Arguments[])
|
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++)
|
|
|
|
{
|
2010-03-10 04:59:39 +00:00
|
|
|
Status = InitRoutine[i].EntryPoint(ArgumentCount,Arguments,NULL);
|
2005-03-20 22:55:05 +00:00
|
|
|
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);
|
2010-03-10 04:59:39 +00:00
|
|
|
return STATUS_SUCCESS;
|
2005-03-20 22:55:05 +00:00
|
|
|
}
|
2010-03-10 04:59:39 +00:00
|
|
|
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
DllMainCRTStartup(HANDLE hDll,
|
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
/* We don't do much */
|
|
|
|
UNREFERENCED_PARAMETER(hDll);
|
|
|
|
UNREFERENCED_PARAMETER(dwReason);
|
|
|
|
UNREFERENCED_PARAMETER(lpReserved);
|
|
|
|
return TRUE;
|
1999-06-08 22:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|