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 <kernel32/kernel32.h>
20 /* GLOBALS ******************************************************************/
22 static UNICODE_STRING CommandLineStringW;
23 static ANSI_STRING CommandLineStringA;
25 static WINBOOL 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;
69 LPSTR STDCALL GetCommandLineA(VOID)
71 if (bCommandLineInitialized == FALSE)
76 DPRINT ("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
78 return(CommandLineStringA.Buffer);
81 LPWSTR STDCALL GetCommandLineW (VOID)
83 if (bCommandLineInitialized == FALSE)
88 DPRINT ("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
90 return(CommandLineStringW.Buffer);