1 /* $Id: os2ss.cpp,v 1.2 2003/01/07 16:23:12 robd 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>
13 #include <ntos/synch.h>
16 BOOL
CsrServerInitialization(ULONG ArgumentCount
, PWSTR
*ArgumentArray
);
17 VOID
DisplayString(LPCWSTR lpwString
);
18 //BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
19 //VOID STDCALL DisplayString(LPCWSTR lpwString);
20 //VOID STDCALL PrintString (char* fmt, ...);
21 //NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString);
24 DisplayString(LPCWSTR lpwString
)
28 RtlInitUnicodeString(&us
, lpwString
);
34 PrintString(char* fmt,...)
38 UNICODE_STRING UnicodeString;
39 ANSI_STRING AnsiString;
42 vsprintf(buffer, fmt, ap);
45 RtlInitAnsiString(&AnsiString, buffer);
46 RtlAnsiStringToUnicodeString(&UnicodeString,
49 NtDisplayString(&UnicodeString);
50 RtlFreeUnicodeString(&UnicodeString);
56 /* server variables */
62 /* Native image's entry point */
64 void NtProcessStartup (PPEB Peb
)
66 PRTL_USER_PROCESS_PARAMETERS ProcParams
;
71 int afterlastspace
= 0;
72 OBJECT_ATTRIBUTES ObjectAttributes
;
73 HANDLE CsrssInitEvent
;
74 UNICODE_STRING UnicodeString
;
77 ProcParams
= RtlNormalizeProcessParams (Peb
->ProcessParameters
);
79 argv
= (PWSTR
*)RtlAllocateHeap (Peb
->ProcessHeap
,
80 0, 512 * sizeof(PWSTR
));
81 ArgBuffer
= (PWSTR
)RtlAllocateHeap (Peb
->ProcessHeap
,
83 ProcParams
->CommandLine
.Length
+ sizeof(WCHAR
));
85 ProcParams
->CommandLine
.Buffer
,
86 ProcParams
->CommandLine
.Length
+ sizeof(WCHAR
));
90 if (ArgBuffer
[i
] == L
' ')
94 argv
[argc
-1] = &(ArgBuffer
[afterlastspace
]);
96 while (ArgBuffer
[i
] == L
' ')
106 if (ArgBuffer
[afterlastspace
] != L
'\0')
109 ArgBuffer
[i
] = L
'\0';
110 argv
[argc
-1] = &(ArgBuffer
[afterlastspace
]);
113 RtlInitUnicodeString(&UnicodeString
,
115 InitializeObjectAttributes(&ObjectAttributes
,
120 Status
= NtOpenEvent(&CsrssInitEvent
,
123 if (!NT_SUCCESS(Status
))
125 DbgPrint("CSR: Failed to open csrss notification event\n");
127 if (CsrServerInitialization (argc
, argv
) == TRUE
)
130 NtSetEvent(CsrssInitEvent
,
133 RtlFreeHeap (Peb
->ProcessHeap
,
135 RtlFreeHeap (Peb
->ProcessHeap
,
139 /* terminate the current thread only */
140 NtTerminateThread( NtCurrentThread(), 0 );
144 DisplayString( L
"CSR: Subsystem initialization failed.\n" );
146 RtlFreeHeap (Peb
->ProcessHeap
,
148 RtlFreeHeap (Peb
->ProcessHeap
,
155 NtTerminateProcess( NtCurrentProcess(), 0 );