3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/proc/proc.c
6 * PURPOSE: Process functions
7 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
12 /* INCLUDES ****************************************************************/
20 /* GLOBALS ******************************************************************/
22 static UNICODE_STRING CommandLineStringW
;
23 static ANSI_STRING CommandLineStringA
;
25 static BOOL bCommandLineInitialized
= FALSE
;
28 /* FUNCTIONS ****************************************************************/
32 InitCommandLines(VOID
)
34 PRTL_USER_PROCESS_PARAMETERS Params
;
36 /* FIXME - not thread-safe! */
39 Params
= NtCurrentPeb()->ProcessParameters
;
40 RtlNormalizeProcessParams (Params
);
42 // initialize command line buffers
43 CommandLineStringW
.Length
= Params
->CommandLine
.Length
;
44 CommandLineStringW
.MaximumLength
= CommandLineStringW
.Length
+ sizeof(WCHAR
);
45 CommandLineStringW
.Buffer
= RtlAllocateHeap(GetProcessHeap(),
46 HEAP_GENERATE_EXCEPTIONS
| HEAP_ZERO_MEMORY
,
47 CommandLineStringW
.MaximumLength
);
48 if (CommandLineStringW
.Buffer
== NULL
)
53 RtlInitAnsiString(&CommandLineStringA
, NULL
);
55 /* Copy command line */
56 RtlCopyUnicodeString(&CommandLineStringW
,
57 &(Params
->CommandLine
));
58 CommandLineStringW
.Buffer
[CommandLineStringW
.Length
/ sizeof(WCHAR
)] = 0;
60 /* convert unicode string to ansi (or oem) */
62 RtlUnicodeStringToAnsiString(&CommandLineStringA
,
66 RtlUnicodeStringToOemString(&CommandLineStringA
,
70 CommandLineStringA
.Buffer
[CommandLineStringA
.Length
] = 0;
72 bCommandLineInitialized
= TRUE
;
83 if (bCommandLineInitialized
== FALSE
)
88 DPRINT("CommandLine \'%s\'\n", CommandLineStringA
.Buffer
);
90 return CommandLineStringA
.Buffer
;
101 if (bCommandLineInitialized
== FALSE
)
106 DPRINT("CommandLine \'%S\'\n", CommandLineStringW
.Buffer
);
108 return CommandLineStringW
.Buffer
;