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
;
36 Params
= NtCurrentPeb()->ProcessParameters
;
37 RtlNormalizeProcessParams (Params
);
39 // initialize command line buffers
40 CommandLineStringW
.Length
= Params
->CommandLine
.Length
;
41 CommandLineStringW
.MaximumLength
= CommandLineStringW
.Length
+ sizeof(WCHAR
);
42 CommandLineStringW
.Buffer
= RtlAllocateHeap(GetProcessHeap(),
43 HEAP_GENERATE_EXCEPTIONS
|HEAP_ZERO_MEMORY
,
44 CommandLineStringW
.MaximumLength
);
46 RtlInitAnsiString(&CommandLineStringA
, NULL
);
49 RtlCopyUnicodeString (&CommandLineStringW
,
50 &(Params
->CommandLine
));
51 CommandLineStringW
.Buffer
[CommandLineStringW
.Length
/ sizeof(WCHAR
)] = 0;
53 /* convert unicode string to ansi (or oem) */
55 RtlUnicodeStringToAnsiString (&CommandLineStringA
,
59 RtlUnicodeStringToOemString (&CommandLineStringA
,
63 CommandLineStringA
.Buffer
[CommandLineStringA
.Length
] = 0;
65 bCommandLineInitialized
= TRUE
;
72 LPSTR STDCALL
GetCommandLineA(VOID
)
74 if (bCommandLineInitialized
== FALSE
)
79 DPRINT ("CommandLine \'%s\'\n", CommandLineStringA
.Buffer
);
81 return(CommandLineStringA
.Buffer
);
88 LPWSTR STDCALL
GetCommandLineW (VOID
)
90 if (bCommandLineInitialized
== FALSE
)
95 DPRINT ("CommandLine \'%S\'\n", CommandLineStringW
.Buffer
);
97 return(CommandLineStringW
.Buffer
);