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 ****************************************************************/
14 #include <ddk/ntddk.h>
16 #include <kernel32/proc.h>
17 #include <kernel32/thread.h>
21 #include <ntdll/rtl.h>
24 #include <kernel32/kernel32.h>
27 /* GLOBALS ******************************************************************/
29 static UNICODE_STRING CommandLineStringW;
30 static ANSI_STRING CommandLineStringA;
32 static WINBOOL bCommandLineInitialized = FALSE;
35 /* FUNCTIONS ****************************************************************/
38 InitCommandLines (VOID)
40 PRTL_USER_PROCESS_PARAMETERS Params;
43 Params = NtCurrentPeb()->ProcessParameters;
44 RtlNormalizeProcessParams (Params);
46 // initialize command line buffers
47 CommandLineStringW.Length = Params->CommandLine.Length;
48 CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
49 CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
50 HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
51 CommandLineStringW.MaximumLength);
53 RtlInitAnsiString(&CommandLineStringA, NULL);
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;
76 LPSTR STDCALL GetCommandLineA(VOID)
78 if (bCommandLineInitialized == FALSE)
83 DPRINT ("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
85 return(CommandLineStringA.Buffer);
88 LPWSTR STDCALL GetCommandLineW (VOID)
90 if (bCommandLineInitialized == FALSE)
95 DPRINT ("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
97 return(CommandLineStringW.Buffer);