1999-12-10 17:49:21 +00:00
|
|
|
/* $Id: cmdline.c,v 1.9 1999/12/10 17:47:29 ekohl Exp $
|
|
|
|
*
|
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 ****************************************************************/
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
//#define UNICODE
|
1999-10-07 23:46:27 +00:00
|
|
|
#include <ddk/ntddk.h>
|
1999-01-01 22:03:17 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#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-04-10 12:08:24 +00:00
|
|
|
#include <internal/teb.h>
|
1999-12-10 17:49:21 +00:00
|
|
|
#include <ntdll/rtl.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <kernel32/kernel32.h>
|
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 WCHAR CommandLineW[MAX_PATH];
|
1999-04-10 12:08:24 +00:00
|
|
|
static CHAR CommandLineA[MAX_PATH];
|
1999-01-01 22:03:17 +00:00
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
PPPB Ppb;
|
|
|
|
|
|
|
|
// initialize command line buffers
|
|
|
|
CommandLineW[0] = 0;
|
|
|
|
CommandLineStringW.Buffer = CommandLineW;
|
|
|
|
CommandLineStringW.Length = 0;
|
|
|
|
CommandLineStringW.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
|
|
|
|
|
|
|
CommandLineA[0] = 0;
|
|
|
|
CommandLineStringA.Buffer = CommandLineA;
|
|
|
|
CommandLineStringA.Length = 0;
|
|
|
|
CommandLineStringA.MaximumLength = MAX_PATH;
|
|
|
|
|
|
|
|
// get command line
|
|
|
|
Ppb = NtCurrentPeb()->Ppb;
|
|
|
|
RtlNormalizeProcessParams (Ppb);
|
|
|
|
|
|
|
|
RtlCopyUnicodeString (&CommandLineStringW,
|
|
|
|
&(Ppb->CommandLine));
|
|
|
|
RtlUnicodeStringToAnsiString (&CommandLineStringA,
|
|
|
|
&CommandLineStringW,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT ("CommandLine \'%s\'\n", CommandLineA);
|
|
|
|
|
|
|
|
return(CommandLineA);
|
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 ();
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT ("CommandLine \'%w\'\n", CommandLineW);
|
|
|
|
|
|
|
|
return(CommandLineW);
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
/* EOF */
|