2002-09-07 15:13:13 +00:00
|
|
|
/* $Id: cmdline.c,v 1.14 2002/09/07 15:12:27 chorns Exp $
|
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 ****************************************************************/
|
|
|
|
|
|
|
|
#include <windows.h>
|
2002-09-07 15:13:13 +00:00
|
|
|
#define NTOS_USER_MODE
|
|
|
|
#include <ntos.h>
|
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
#include <kernel32/proc.h>
|
|
|
|
#include <kernel32/thread.h>
|
1999-03-19 05:55:55 +00:00
|
|
|
#include <wchar.h>
|
1999-01-01 22:03:17 +00:00
|
|
|
#include <string.h>
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <kernel32/kernel32.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;
|
|
|
|
|
|
|
|
static WINBOOL bCommandLineInitialized = FALSE;
|
|
|
|
|
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
static VOID
|
|
|
|
InitCommandLines (VOID)
|
|
|
|
{
|
2002-09-07 15:13:13 +00:00
|
|
|
PRTL_ROS_USER_PROCESS_PARAMETERS Params;
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
// get command line
|
2000-01-11 17:32:13 +00:00
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
2002-09-07 15:13:13 +00:00
|
|
|
RtlRosNormalizeProcessParams (Params);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
// initialize command line buffers
|
|
|
|
CommandLineStringW.Length = Params->CommandLine.Length;
|
|
|
|
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
|
|
|
|
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
|
|
|
|
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
|
|
|
|
CommandLineStringW.MaximumLength);
|
|
|
|
|
|
|
|
RtlInitAnsiString(&CommandLineStringA, NULL);
|
|
|
|
|
|
|
|
// copy command line
|
1999-12-10 17:49:21 +00:00
|
|
|
RtlCopyUnicodeString (&CommandLineStringW,
|
2000-01-11 17:32:13 +00:00
|
|
|
&(Params->CommandLine));
|
2002-03-25 21:11:13 +00:00
|
|
|
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;
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
bCommandLineInitialized = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
LPSTR STDCALL GetCommandLineA(VOID)
|
|
|
|
{
|
1999-12-10 17:49:21 +00:00
|
|
|
if (bCommandLineInitialized == FALSE)
|
|
|
|
{
|
|
|
|
InitCommandLines ();
|
|
|
|
}
|
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
DPRINT ("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
return(CommandLineStringA.Buffer);
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
1999-12-06 00:25:14 +00:00
|
|
|
LPWSTR STDCALL GetCommandLineW (VOID)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
1999-12-10 17:49:21 +00:00
|
|
|
if (bCommandLineInitialized == FALSE)
|
|
|
|
{
|
|
|
|
InitCommandLines ();
|
|
|
|
}
|
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
DPRINT ("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
return(CommandLineStringW.Buffer);
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
/* EOF */
|