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,8 +142,12 @@ 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;
if (0 < WideCharStringToUnicodeString (ProcessParameters->Environment, & UnicodeEnvironment))
{
RtlUnicodeStringToAnsiString (& AnsiEnvironment, & UnicodeEnvironment, TRUE);
/* Change our source to the enviroment pointer */ /* Change our source to the enviroment pointer */
Source = (PCHAR)ProcessParameters->Environment; Source = AnsiEnvironment.Buffer;
/* Simply do a direct copy */ /* Simply do a direct copy */
if (Source) if (Source)
@ -122,6 +156,7 @@ NtProcessStartup(PPEB Peb)
{ {
/* Save a pointer to this token */ /* Save a pointer to this token */
*ArgumentList++ = Source; *ArgumentList++ = Source;
DPRINT("NT: envp[%08x]=[%s]\n",Source,Source);
/* Keep looking for another variable */ /* Keep looking for another variable */
while (*Source++); while (*Source++);
@ -130,7 +165,7 @@ NtProcessStartup(PPEB Peb)
/* Null terminate the list again */ /* Null terminate the list again */
*ArgumentList++ = NULL; *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();