2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
1999-12-10 17:49:21 +00:00
|
|
|
*
|
1999-01-01 22:03:17 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/proc/proc.c
|
|
|
|
* PURPOSE: Process functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
2007-09-02 19:42:22 +00:00
|
|
|
#include <debug.h>
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
static UNICODE_STRING CommandLineStringW;
|
|
|
|
static ANSI_STRING CommandLineStringA;
|
|
|
|
|
2004-01-23 17:18:16 +00:00
|
|
|
static BOOL bCommandLineInitialized = FALSE;
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
VOID
|
2010-05-06 10:50:26 +00:00
|
|
|
WINAPI
|
2010-01-09 20:51:33 +00:00
|
|
|
InitCommandLines(VOID)
|
1999-12-10 17:49:21 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
|
|
|
|
2010-05-06 10:50:26 +00:00
|
|
|
/* get command line */
|
2010-01-09 20:51:33 +00:00
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
|
|
|
RtlNormalizeProcessParams (Params);
|
|
|
|
|
2010-05-06 10:50:26 +00:00
|
|
|
/* initialize command line buffers */
|
2010-01-09 20:51:33 +00:00
|
|
|
CommandLineStringW.Length = Params->CommandLine.Length;
|
|
|
|
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
|
|
|
|
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
|
|
|
|
HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
|
|
|
|
CommandLineStringW.MaximumLength);
|
|
|
|
if (CommandLineStringW.Buffer == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlInitAnsiString(&CommandLineStringA, NULL);
|
|
|
|
|
|
|
|
/* Copy command line */
|
|
|
|
RtlCopyUnicodeString(&CommandLineStringW,
|
|
|
|
&(Params->CommandLine));
|
|
|
|
CommandLineStringW.Buffer[CommandLineStringW.Length / sizeof(WCHAR)] = 0;
|
|
|
|
|
|
|
|
/* convert unicode string to ansi (or oem) */
|
|
|
|
if (bIsFileApiAnsi)
|
|
|
|
RtlUnicodeStringToAnsiString(&CommandLineStringA,
|
|
|
|
&CommandLineStringW,
|
|
|
|
TRUE);
|
|
|
|
else
|
|
|
|
RtlUnicodeStringToOemString(&CommandLineStringA,
|
|
|
|
&CommandLineStringW,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
CommandLineStringA.Buffer[CommandLineStringA.Length] = 0;
|
|
|
|
|
|
|
|
bCommandLineInitialized = TRUE;
|
1999-12-10 17:49:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
LPSTR
|
|
|
|
WINAPI
|
|
|
|
GetCommandLineA(VOID)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
|
|
|
|
return CommandLineStringA.Buffer;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
LPWSTR
|
|
|
|
WINAPI
|
|
|
|
GetCommandLineW(VOID)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
|
|
|
|
return CommandLineStringW.Buffer;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
/* EOF */
|