1 /* $Id: os2ss.cpp,v 1.1 2002/03/23 19:23:28 robertk Exp $
3 * reactos/subsys/csrss/api/process.c
5 * "\windows\ApiPort" port process management functions
7 * ReactOS Operating System
9 // TODO: Rewrite the whole file. This is just a copy
11 #include <ddk/ntddk.h>
12 #include <ntdll/rtl.h>
15 /* server variables */
21 /* Native image's entry point */
23 void NtProcessStartup (PPEB Peb
)
25 PRTL_USER_PROCESS_PARAMETERS ProcParams
;
30 int afterlastspace
= 0;
31 OBJECT_ATTRIBUTES ObjectAttributes
;
32 HANDLE CsrssInitEvent
;
33 UNICODE_STRING UnicodeString
;
36 ProcParams
= RtlNormalizeProcessParams (Peb
->ProcessParameters
);
38 argv
= (PWSTR
*)RtlAllocateHeap (Peb
->ProcessHeap
,
39 0, 512 * sizeof(PWSTR
));
40 ArgBuffer
= (PWSTR
)RtlAllocateHeap (Peb
->ProcessHeap
,
42 ProcParams
->CommandLine
.Length
+ sizeof(WCHAR
));
44 ProcParams
->CommandLine
.Buffer
,
45 ProcParams
->CommandLine
.Length
+ sizeof(WCHAR
));
49 if (ArgBuffer
[i
] == L
' ')
53 argv
[argc
-1] = &(ArgBuffer
[afterlastspace
]);
55 while (ArgBuffer
[i
] == L
' ')
65 if (ArgBuffer
[afterlastspace
] != L
'\0')
69 argv
[argc
-1] = &(ArgBuffer
[afterlastspace
]);
72 RtlInitUnicodeString(&UnicodeString
,
74 InitializeObjectAttributes(&ObjectAttributes
,
79 Status
= NtOpenEvent(&CsrssInitEvent
,
82 if (!NT_SUCCESS(Status
))
84 DbgPrint("CSR: Failed to open csrss notification event\n");
86 if (CsrServerInitialization (argc
, argv
) == TRUE
)
89 NtSetEvent(CsrssInitEvent
,
92 RtlFreeHeap (Peb
->ProcessHeap
,
94 RtlFreeHeap (Peb
->ProcessHeap
,
98 /* terminate the current thread only */
99 NtTerminateThread( NtCurrentThread(), 0 );
103 DisplayString( L
"CSR: Subsystem initialization failed.\n" );
105 RtlFreeHeap (Peb
->ProcessHeap
,
107 RtlFreeHeap (Peb
->ProcessHeap
,
114 NtTerminateProcess( NtCurrentProcess(), 0 );