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 ****************************************************************/
17 #include "../include/debug.h"
20 /* GLOBALS ******************************************************************/
22 static UNICODE_STRING CommandLineStringW
;
23 static ANSI_STRING CommandLineStringA
;
25 static BOOL bCommandLineInitialized
= FALSE
;
28 /* FUNCTIONS ****************************************************************/
31 InitCommandLines (VOID
)
33 PRTL_USER_PROCESS_PARAMETERS Params
;
35 /* FIXME - not thread-safe! */
38 Params
= NtCurrentPeb()->ProcessParameters
;
39 RtlNormalizeProcessParams (Params
);
41 // initialize command line buffers
42 CommandLineStringW
.Length
= Params
->CommandLine
.Length
;
43 CommandLineStringW
.MaximumLength
= CommandLineStringW
.Length
+ sizeof(WCHAR
);
44 CommandLineStringW
.Buffer
= RtlAllocateHeap(GetProcessHeap(),
45 HEAP_GENERATE_EXCEPTIONS
|HEAP_ZERO_MEMORY
,
46 CommandLineStringW
.MaximumLength
);
47 if (CommandLineStringW
.Buffer
== NULL
)
52 RtlInitAnsiString(&CommandLineStringA
, NULL
);
55 RtlCopyUnicodeString (&CommandLineStringW
,
56 &(Params
->CommandLine
));
57 CommandLineStringW
.Buffer
[CommandLineStringW
.Length
/ sizeof(WCHAR
)] = 0;
59 /* convert unicode string to ansi (or oem) */
61 RtlUnicodeStringToAnsiString (&CommandLineStringA
,
65 RtlUnicodeStringToOemString (&CommandLineStringA
,
69 CommandLineStringA
.Buffer
[CommandLineStringA
.Length
] = 0;
71 bCommandLineInitialized
= TRUE
;
78 LPSTR STDCALL
GetCommandLineA(VOID
)
80 if (bCommandLineInitialized
== FALSE
)
85 DPRINT ("CommandLine \'%s\'\n", CommandLineStringA
.Buffer
);
87 return(CommandLineStringA
.Buffer
);
94 LPWSTR STDCALL
GetCommandLineW (VOID
)
96 if (bCommandLineInitialized
== FALSE
)
101 DPRINT ("CommandLine \'%S\'\n", CommandLineStringW
.Buffer
);
103 return(CommandLineStringW
.Buffer
);