Added help command to shell.exe.
[reactos.git] / reactos / subsys / csrss / init.c
1 /* $Id: init.c,v 1.6 2000/02/29 23:57:45 ea Exp $
2 *
3 * reactos/subsys/csrss/init.c
4 *
5 * Initialize the CSRSS subsystem server process.
6 *
7 * ReactOS Operating System
8 *
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #include <ddk/ntddk.h>
14 #include <ntdll/rtl.h>
15 #include <csrss/csrss.h>
16
17 #include "api.h"
18
19 /* GLOBALS ******************************************************************/
20
21 /*
22 * Server's named ports.
23 */
24 static HANDLE ApiPortHandle;
25
26
27 HANDLE CsrInitEvent = INVALID_HANDLE_VALUE;
28 HANDLE CsrHeap = INVALID_HANDLE_VALUE;
29
30 HANDLE CsrObjectDirectory = INVALID_HANDLE_VALUE;
31 HANDLE CsrApiPort = INVALID_HANDLE_VALUE;
32 HANDLE CsrSbApiPort = INVALID_HANDLE_VALUE;
33
34 UNICODE_STRING CsrDirectoryName;
35
36
37 static NTSTATUS
38 CsrParseCommandLine (
39 ULONG ArgumentCount,
40 PWSTR *ArgumentArray
41 )
42 {
43 NTSTATUS Status;
44 OBJECT_ATTRIBUTES Attributes;
45 ANSI_STRING AnsiString;
46
47 ULONG i;
48
49 DbgPrint ("Arguments: %ld\n", ArgumentCount);
50 for (i = 0; i < ArgumentCount; i++)
51 {
52 DbgPrint ("Argument %ld: %S\n", i, ArgumentArray[i]);
53 }
54
55
56 /* create object directory ('\Windows') */
57 RtlCreateUnicodeString (&CsrDirectoryName,
58 L"\\Windows");
59
60 InitializeObjectAttributes (&Attributes,
61 &CsrDirectoryName,
62 0,
63 NULL,
64 NULL);
65
66 Status = NtCreateDirectoryObject(&CsrObjectDirectory,
67 0xF000F,
68 &Attributes);
69
70 return Status;
71 }
72
73
74 /**********************************************************************
75 * NAME
76 * CsrServerInitialization
77 *
78 * DESCRIPTION
79 * Create a directory object (\windows) and two named LPC ports:
80 *
81 * 1. \windows\ApiPort
82 * 2. \windows\SbApiPort
83 *
84 * RETURN VALUE
85 * TRUE: Initialization OK; otherwise FALSE.
86 */
87 BOOL
88 STDCALL
89 CsrServerInitialization (
90 ULONG ArgumentCount,
91 PWSTR *ArgumentArray
92 )
93 {
94 NTSTATUS Status;
95 OBJECT_ATTRIBUTES ObAttributes;
96 UNICODE_STRING PortName;
97
98 Status = CsrParseCommandLine (ArgumentCount, ArgumentArray);
99 if (!NT_SUCCESS(Status))
100 {
101 PrintString("CSR: Unable to parse the command line (Status: %x)\n", Status);
102 return(FALSE);
103 }
104
105 /* NEW NAMED PORT: \ApiPort */
106 RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
107 InitializeObjectAttributes(&ObAttributes,
108 &PortName,
109 0,
110 NULL,
111 NULL);
112
113 Status = NtCreatePort(&ApiPortHandle,
114 &ObAttributes,
115 260,
116 328,
117 0);
118 if (!NT_SUCCESS(Status))
119 {
120 PrintString("CSR: Unable to create \\ApiPort (Status %x)\n", Status);
121 return(FALSE);
122 }
123
124 Status = RtlCreateUserThread(NtCurrentProcess(),
125 NULL,
126 FALSE,
127 0,
128 NULL,
129 NULL,
130 (PTHREAD_START_ROUTINE)Thread_Api,
131 ApiPortHandle,
132 NULL,
133 NULL);
134 if (!NT_SUCCESS(Status))
135 {
136 PrintString("CSR: Unable to create server thread\n");
137 NtClose(ApiPortHandle);
138 return FALSE;
139 }
140
141 return TRUE;
142 }
143
144 /* EOF */