1 /* $Id: init.c,v 1.14 2002/08/20 20:37:17 hyperion Exp $
3 * reactos/subsys/csrss/init.c
5 * Initialize the CSRSS subsystem server process.
7 * ReactOS Operating System
11 /* INCLUDES ******************************************************************/
13 #include <ddk/ntddk.h>
14 #include <ntdll/rtl.h>
15 #include <csrss/csrss.h>
19 /* GLOBALS ******************************************************************/
22 * Server's named ports.
24 static HANDLE ApiPortHandle
;
27 HANDLE CsrInitEvent
= INVALID_HANDLE_VALUE
;
28 HANDLE CsrHeap
= INVALID_HANDLE_VALUE
;
30 HANDLE CsrObjectDirectory
= INVALID_HANDLE_VALUE
;
31 HANDLE CsrApiPort
= INVALID_HANDLE_VALUE
;
32 HANDLE CsrSbApiPort
= INVALID_HANDLE_VALUE
;
34 UNICODE_STRING CsrDirectoryName
;
36 extern HANDLE CsrssApiHeap
;
39 InitializeVideoAddressSpace(VOID
);
48 OBJECT_ATTRIBUTES Attributes
;
49 ANSI_STRING AnsiString
;
53 /* DbgPrint ("Arguments: %ld\n", ArgumentCount);
54 for (i = 0; i < ArgumentCount; i++)
56 DbgPrint ("Argument %ld: %S\n", i, ArgumentArray[i]);
60 /* create object directory ('\Windows') */
61 RtlCreateUnicodeString (&CsrDirectoryName
,
64 InitializeObjectAttributes (&Attributes
,
70 Status
= NtCreateDirectoryObject(&CsrObjectDirectory
,
81 OBJECT_ATTRIBUTES ObjectAttributes
;
82 UNICODE_STRING DeviceName
;
87 RtlInitUnicodeStringFromLiteral(&DeviceName
, L
"\\??\\DISPLAY1");
88 InitializeObjectAttributes(&ObjectAttributes
,
93 Status
= NtOpenFile(&VideoHandle
,
99 if (NT_SUCCESS(Status
))
101 NtClose(VideoHandle
);
106 /**********************************************************************
108 * CsrServerInitialization
111 * Create a directory object (\windows) and two named LPC ports:
113 * 1. \windows\ApiPort
114 * 2. \windows\SbApiPort
117 * TRUE: Initialization OK; otherwise FALSE.
121 CsrServerInitialization (
127 OBJECT_ATTRIBUTES ObAttributes
;
128 UNICODE_STRING PortName
;
129 OBJECT_ATTRIBUTES RefreshEventAttr
;
130 UNICODE_STRING RefreshEventName
;
131 HANDLE RefreshEventHandle
;
133 Status
= CsrParseCommandLine (ArgumentCount
, ArgumentArray
);
134 if (!NT_SUCCESS(Status
))
136 PrintString("CSR: Unable to parse the command line (Status: %x)\n", Status
);
142 /* NEW NAMED PORT: \ApiPort */
143 RtlInitUnicodeStringFromLiteral(&PortName
, L
"\\Windows\\ApiPort");
144 InitializeObjectAttributes(&ObAttributes
,
150 Status
= NtCreatePort(&ApiPortHandle
,
155 if (!NT_SUCCESS(Status
))
157 PrintString("CSR: Unable to create \\ApiPort (Status %x)\n", Status
);
160 CsrssApiHeap
= RtlCreateHeap(HEAP_GROWABLE
,
166 if (CsrssApiHeap
== NULL
)
168 PrintString("CSR: Failed to create private heap, aborting\n");
172 CsrInitConsoleSupport();
173 Status
= RtlCreateUserThread(NtCurrentProcess(),
179 (PTHREAD_START_ROUTINE
)Thread_Api
,
183 if (!NT_SUCCESS(Status
))
185 PrintString("CSR: Unable to create server thread\n");
186 NtClose(ApiPortHandle
);
189 RtlInitUnicodeStringFromLiteral( &RefreshEventName
, L
"\\TextConsoleRefreshEvent" );
190 InitializeObjectAttributes( &RefreshEventAttr
, &RefreshEventName
, 0, NULL
, NULL
);
191 Status
= NtCreateEvent( &RefreshEventHandle
, STANDARD_RIGHTS_ALL
, &RefreshEventAttr
, FALSE
, FALSE
);
192 if( !NT_SUCCESS( Status
) )
194 PrintString( "CSR: Unable to create refresh event!\n" );
197 Status
= RtlCreateUserThread( NtCurrentProcess(), NULL
, FALSE
, 0, NULL
, NULL
, (PTHREAD_START_ROUTINE
)Console_Api
, (PVOID
) RefreshEventHandle
, NULL
, NULL
);
198 if( !NT_SUCCESS( Status
) )
200 PrintString( "CSR: Unable to create console thread\n" );
204 InitializeVideoAddressSpace();