A raw attempt to fix the startup code for native processes.

(note: it seems NTOSKRNL passes nothing to smss.exe)

svn path=/trunk/; revision=18251
This commit is contained in:
Emanuele Aliberti 2005-10-03 21:35:12 +00:00
parent ce7daa3fef
commit 7d51afc9cf

View file

@ -23,10 +23,35 @@ _main(
ULONG DebugFlag ULONG DebugFlag
); );
#define NDEBUG //#define NDEBUG
#include <debug.h> #include <debug.h>
/* FUNCTIONSS ****************************************************************/ /* FUNCTIONS ****************************************************************/
ULONG FASTCALL WideCharStringToUnicodeString (PWCHAR wsIn, PUNICODE_STRING usOut)
{
ULONG Length = 0;
PWCHAR CurrentChar = wsIn;
DPRINT("%s(%08lx,%08lx) called\n", __FUNCTION__, wsIn, usOut);
if (NULL != CurrentChar)
{
usOut->Buffer = CurrentChar;
while (*CurrentChar ++)
{
++ Length;
while (*CurrentChar ++)
{
++ Length;
}
}
++ Length;
}
usOut->Length = Length;
usOut->MaximumLength = Length;
return Length;
}
VOID VOID
STDCALL STDCALL
@ -36,6 +61,8 @@ NtProcessStartup(PPEB Peb)
PRTL_USER_PROCESS_PARAMETERS ProcessParameters; PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
PUNICODE_STRING CmdLineString; PUNICODE_STRING CmdLineString;
ANSI_STRING AnsiCmdLine; ANSI_STRING AnsiCmdLine;
UNICODE_STRING UnicodeEnvironment;
ANSI_STRING AnsiEnvironment;
PCHAR NullPointer = NULL; PCHAR NullPointer = NULL;
INT argc = 0; INT argc = 0;
PCHAR *argv; PCHAR *argv;
@ -45,6 +72,8 @@ NtProcessStartup(PPEB Peb)
ULONG Length; ULONG Length;
ASSERT(Peb); ASSERT(Peb);
DPRINT("%s(%08lx) called\n", __FUNCTION__, Peb);
/* Normalize and get the Process Parameters */ /* Normalize and get the Process Parameters */
ProcessParameters = RtlNormalizeProcessParams(Peb->ProcessParameters); ProcessParameters = RtlNormalizeProcessParams(Peb->ProcessParameters);
ASSERT(ProcessParameters); ASSERT(ProcessParameters);
@ -93,6 +122,7 @@ NtProcessStartup(PPEB Peb)
{ {
/* Save one token pointer */ /* Save one token pointer */
*ArgumentList++ = Destination; *ArgumentList++ = Destination;
DPRINT("NT: argv[%d]=[%d]\n", argc, Destination);
/* Increase one token count */ /* Increase one token count */
argc++; argc++;
@ -112,25 +142,30 @@ NtProcessStartup(PPEB Peb)
/* Now handle the enviornment, point the envp at our current list location. */ /* Now handle the enviornment, point the envp at our current list location. */
envp = ArgumentList; envp = ArgumentList;
/* Change our source to the enviroment pointer */ if (0 < WideCharStringToUnicodeString (ProcessParameters->Environment, & UnicodeEnvironment))
Source = (PCHAR)ProcessParameters->Environment;
/* Simply do a direct copy */
if (Source)
{ {
while (*Source) RtlUnicodeStringToAnsiString (& AnsiEnvironment, & UnicodeEnvironment, TRUE);
{
/* Save a pointer to this token */
*ArgumentList++ = Source;
/* Keep looking for another variable */ /* Change our source to the enviroment pointer */
while (*Source++); Source = AnsiEnvironment.Buffer;
}
/* Simply do a direct copy */
if (Source)
{
while (*Source)
{
/* Save a pointer to this token */
*ArgumentList++ = Source;
DPRINT("NT: envp[%08x]=[%s]\n",Source,Source);
/* Keep looking for another variable */
while (*Source++);
}
}
/* Null terminate the list again */
*ArgumentList++ = NULL;
} }
/* Null terminate the list again */
*ArgumentList++ = NULL;
/* Breakpoint if we were requested to do so */ /* Breakpoint if we were requested to do so */
if (ProcessParameters->DebugFlags) DbgBreakPoint(); if (ProcessParameters->DebugFlags) DbgBreakPoint();