Fixed bugs in process parameter and environment code

svn path=/trunk/; revision=992
This commit is contained in:
Eric Kohl 2000-02-19 19:37:13 +00:00
parent e632116bee
commit b9bb1744aa
8 changed files with 257 additions and 229 deletions

View file

@ -33,34 +33,34 @@ typedef struct _PEB_FREE_BLOCK
typedef struct _RTL_USER_PROCESS_PARAMETERS
{
ULONG TotalSize; // 00h
ULONG DataSize; // 04h
ULONG Flags; // 08h
ULONG DebugFlags; // 0Ch
PVOID ConsoleHandle; // 10h
ULONG ConsoleFlags; // 14h
ULONG MaximumLength; // 00h
ULONG Length; // 04h
ULONG Flags; // 08h
ULONG DebugFlags; // 0Ch
PVOID ConsoleHandle; // 10h
ULONG ConsoleFlags; // 14h
HANDLE InputHandle; // 18h
HANDLE OutputHandle; // 1Ch
HANDLE ErrorHandle; // 20h
CURDIR CurrentDirectory; // 24h
UNICODE_STRING LibraryPath; // 30h
UNICODE_STRING CommandLine; // 38h
UNICODE_STRING ImageName; // 40h
CURDIR CurrentDirectory; // 24h
UNICODE_STRING DllPath; // 30h
UNICODE_STRING ImagePathName; // 38h
UNICODE_STRING CommandLine; // 40h
PVOID Environment; // 48h
DWORD X; // 4Ch
DWORD Y; // 50h
DWORD XSize; // 54h
DWORD YSize; // 58h
DWORD XCountChars; // 5Ch
DWORD YCountChars; // 60h
DWORD FillAttribute; // 64h
DWORD WindowFlags; // 68h
DWORD ShowWindow; // 6Ch
UNICODE_STRING Title; // 70h
UNICODE_STRING Desktop; // 78h
ULONG StartingX; // 4Ch
ULONG StartingY; // 50h
ULONG CountX; // 54h
ULONG CountY; // 58h
ULONG CountCharsX; // 5Ch
ULONG CountCharsY; // 60h
ULONG FillAttribute; // 64h
ULONG WindowFlags; // 68h
ULONG ShowWindowFlags; // 6Ch
UNICODE_STRING WindowTitle; // 70h
UNICODE_STRING DesktopInfo; // 78h
UNICODE_STRING ShellInfo; // 80h
UNICODE_STRING RuntimeData; // 88h
RTL_DRIVE_LETTER_CURDIR RtlCurrentDirectory[0x20]; // 90h
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20]; // 90h
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
#define PEB_BASE (0x7FFDF000)

View file

@ -1,4 +1,4 @@
/* $Id: rtl.h,v 1.9 2000/02/18 00:48:25 ekohl Exp $
/* $Id: rtl.h,v 1.10 2000/02/19 19:33:28 ekohl Exp $
*
*/
@ -193,14 +193,14 @@ STDCALL
RtlCreateProcessParameters (
IN OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
IN PUNICODE_STRING CommandLine,
IN PUNICODE_STRING LibraryPath,
IN PUNICODE_STRING DllPath,
IN PUNICODE_STRING CurrentDirectory,
IN PUNICODE_STRING ImageName,
IN PUNICODE_STRING ImagePathName,
IN PVOID Environment,
IN PUNICODE_STRING Title,
IN PUNICODE_STRING Desktop,
IN PUNICODE_STRING Reserved,
IN PUNICODE_STRING Reserved2
IN PUNICODE_STRING WindowTitle,
IN PUNICODE_STRING DesktopInfo,
IN PUNICODE_STRING ShellInfo,
IN PUNICODE_STRING RuntimeData
);
PRTL_USER_PROCESS_PARAMETERS

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.21 2000/02/18 00:50:07 ekohl Exp $
/* $Id: create.c,v 1.22 2000/02/19 19:35:57 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -326,7 +326,7 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
/* create the PPB */
PpbBase = (PVOID)PEB_STARTUPINFO;
PpbSize = Ppb->TotalSize;
PpbSize = Ppb->MaximumLength;
Status = NtAllocateVirtualMemory(ProcessHandle,
&PpbBase,
0,
@ -338,11 +338,11 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
return(Status);
}
DPRINT("Ppb->TotalSize %x\n", Ppb->TotalSize);
DPRINT("Ppb->MaximumLength %x\n", Ppb->MaximumLength);
NtWriteVirtualMemory(ProcessHandle,
PpbBase,
Ppb,
Ppb->TotalSize,
Ppb->MaximumLength,
&BytesWritten);
/* write pointer to environment */

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.29 2000/01/27 08:56:47 dwelch Exp $
/* $Id: proc.c,v 1.30 2000/02/19 19:35:57 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -12,6 +12,7 @@
/* INCLUDES ****************************************************************/
#include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
@ -23,40 +24,20 @@
#define NDEBUG
#include <kernel32/kernel32.h>
/* TYPES *********************************************************************/
/*
typedef struct _WSTARTUPINFO {
DWORD cb;
LPWSTR lpReserved;
LPWSTR lpDesktop;
LPWSTR lpTitle;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
LPBYTE lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
} WSTARTUPINFO, *LPWSTARTUPINFO;
*/
/* GLOBALS *******************************************************************/
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
LPSTARTUPINFO lpLocalStartupInfo = NULL;
VOID
STDCALL
RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle
);
/* FUNCTIONS ****************************************************************/
WINBOOL
@ -119,7 +100,7 @@ GetExitCodeProcess (
&ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION),
&BytesWritten);
if (!NT_SUCCESS(errCode))
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
@ -145,13 +126,13 @@ GetProcessId (
&ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION),
&BytesWritten);
if (!NT_SUCCESS(errCode))
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
memcpy( lpProcessId ,&ProcessBasic.UniqueProcessId,sizeof(DWORD));
return TRUE;
return TRUE;
}
@ -210,11 +191,11 @@ OpenProcess (
else
ObjectAttributes.Attributes = 0;
errCode = NtOpenProcess(&ProcessHandle,
dwDesiredAccess,
&ObjectAttributes,
errCode = NtOpenProcess(&ProcessHandle,
dwDesiredAccess,
&ObjectAttributes,
&ClientId);
if (!NT_SUCCESS(errCode))
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return NULL;
@ -234,7 +215,7 @@ WinExec (
PROCESS_INFORMATION ProcessInformation;
HINSTANCE hInst;
DWORD dosErr;
StartupInfo.cb = sizeof(STARTUPINFOA);
StartupInfo.wShowWindow = uCmdShow;
StartupInfo.dwFlags = 0;
@ -247,9 +228,9 @@ WinExec (
0,
NULL,
NULL,
&StartupInfo,
&StartupInfo,
&ProcessInformation);
if ( hInst == NULL )
if ( hInst == NULL )
{
dosErr = GetLastError();
return dosErr;
@ -294,10 +275,10 @@ DWORD STDCALL SleepEx(DWORD dwMilliseconds,
BOOL bAlertable)
{
TIME Interval;
NTSTATUS errCode;
NTSTATUS errCode;
Interval.QuadPart = dwMilliseconds * 1000;
errCode = NtDelayExecution(bAlertable,&Interval);
if (!NT_SUCCESS(errCode))
{
@ -314,7 +295,7 @@ GetStartupInfoW (
LPSTARTUPINFOW lpStartupInfo
)
{
PPEB pPeb = NtCurrentPeb();
PRTL_USER_PROCESS_PARAMETERS Params;
if (lpStartupInfo == NULL)
{
@ -322,25 +303,27 @@ GetStartupInfoW (
return;
}
lpStartupInfo->cb = sizeof(STARTUPINFOW);
// lstrcpyW(lpStartupInfo->lpDesktop, pPeb->Ppb->Desktop);
// lstrcpyW(lpStartupInfo->lpTitle, pPeb->Ppb->Title);
lpStartupInfo->dwX = pPeb->ProcessParameters->X;
lpStartupInfo->dwY = pPeb->ProcessParameters->Y;
lpStartupInfo->dwXSize = pPeb->ProcessParameters->XSize;
lpStartupInfo->dwYSize = pPeb->ProcessParameters->YSize;
lpStartupInfo->dwXCountChars = pPeb->ProcessParameters->XCountChars;
lpStartupInfo->dwYCountChars = pPeb->ProcessParameters->YCountChars;
lpStartupInfo->dwFillAttribute = pPeb->ProcessParameters->FillAttribute;
lpStartupInfo->dwFlags = pPeb->ProcessParameters->Flags;
lpStartupInfo->wShowWindow = pPeb->ProcessParameters->ShowWindow;
// lpStartupInfo->lpReserved = pPeb->ProcessParameters->lpReserved1;
// lpStartupInfo->cbReserved2 = pPeb->ProcessParameters->cbReserved;
// lpStartupInfo->lpReserved2 = pPeb->ProcessParameters->lpReserved2;
Params = NtCurrentPeb ()->ProcessParameters;
lpStartupInfo->hStdInput = pPeb->ProcessParameters->InputHandle;
lpStartupInfo->hStdOutput = pPeb->ProcessParameters->OutputHandle;
lpStartupInfo->hStdError = pPeb->ProcessParameters->ErrorHandle;
lpStartupInfo->cb = sizeof(STARTUPINFOW);
lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
lpStartupInfo->dwX = Params->StartingX;
lpStartupInfo->dwY = Params->StartingY;
lpStartupInfo->dwXSize = Params->CountX;
lpStartupInfo->dwYSize = Params->CountY;
lpStartupInfo->dwXCountChars = Params->CountCharsX;
lpStartupInfo->dwYCountChars = Params->CountCharsY;
lpStartupInfo->dwFillAttribute = Params->FillAttribute;
lpStartupInfo->dwFlags = Params->Flags;
lpStartupInfo->wShowWindow = Params->ShowWindowFlags;
lpStartupInfo->lpReserved = Params->ShellInfo.Buffer;
lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
lpStartupInfo->hStdInput = Params->InputHandle;
lpStartupInfo->hStdOutput = Params->OutputHandle;
lpStartupInfo->hStdError = Params->ErrorHandle;
}
@ -350,8 +333,8 @@ GetStartupInfoA (
LPSTARTUPINFOA lpStartupInfo
)
{
PPEB pPeb = NtCurrentPeb();
ULONG i = 0;
PRTL_USER_PROCESS_PARAMETERS Params;
ANSI_STRING AnsiString;
if (lpStartupInfo == NULL)
{
@ -359,49 +342,68 @@ GetStartupInfoA (
return;
}
lpStartupInfo->cb = sizeof(STARTUPINFOA);
#if 0
i = 0;
while ((pPeb->ProcessParameters->Desktop[i])!=0 && i < MAX_PATH)
{
lpStartupInfo->lpDesktop[i] = (unsigned char)
pPeb->ProcessParameters->Desktop[i];
i++;
}
lpStartupInfo->lpDesktop[i] = 0;
Params = NtCurrentPeb ()->ProcessParameters;
i = 0;
while ((pPeb->ProcessParameters->Title[i])!=0 && i < MAX_PATH)
{
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->ProcessParameters->Title[i];
i++;
}
lpStartupInfo->lpTitle[i] = 0;
#endif
lpStartupInfo->dwX = pPeb->ProcessParameters->X;
lpStartupInfo->dwY = pPeb->ProcessParameters->Y;
lpStartupInfo->dwXSize = pPeb->ProcessParameters->XSize;
lpStartupInfo->dwYSize = pPeb->ProcessParameters->YSize;
lpStartupInfo->dwXCountChars = pPeb->ProcessParameters->XCountChars;
lpStartupInfo->dwYCountChars = pPeb->ProcessParameters->YCountChars;
lpStartupInfo->dwFillAttribute = pPeb->ProcessParameters->FillAttribute;
lpStartupInfo->dwFlags = pPeb->ProcessParameters->Flags;
lpStartupInfo->wShowWindow = pPeb->ProcessParameters->ShowWindow;
// lpStartupInfo->cbReserved2 = pPeb->ProcessParameters->cbReserved;
// lpStartupInfo->lpReserved = pPeb->ProcessParameters->lpReserved1;
// lpStartupInfo->lpReserved2 = pPeb->ProcessParameters->lpReserved2;
RtlAcquirePebLock ();
lpStartupInfo->hStdInput = pPeb->ProcessParameters->InputHandle;
lpStartupInfo->hStdOutput = pPeb->ProcessParameters->OutputHandle;
lpStartupInfo->hStdError = pPeb->ProcessParameters->ErrorHandle;
if (lpLocalStartupInfo == NULL)
{
/* create new local startup info (ansi) */
lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (),
0,
sizeof(STARTUPINFOA));
lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);
/* copy window title string */
RtlUnicodeStringToAnsiString (&AnsiString,
&Params->WindowTitle,
TRUE);
lpLocalStartupInfo->lpTitle = AnsiString.Buffer;
/* copy desktop info string */
RtlUnicodeStringToAnsiString (&AnsiString,
&Params->DesktopInfo,
TRUE);
lpLocalStartupInfo->lpDesktop = AnsiString.Buffer;
/* copy shell info string */
RtlUnicodeStringToAnsiString (&AnsiString,
&Params->ShellInfo,
TRUE);
lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
lpLocalStartupInfo->dwX = Params->StartingX;
lpLocalStartupInfo->dwY = Params->StartingY;
lpLocalStartupInfo->dwXSize = Params->CountX;
lpLocalStartupInfo->dwYSize = Params->CountY;
lpLocalStartupInfo->dwXCountChars = Params->CountCharsX;
lpLocalStartupInfo->dwYCountChars = Params->CountCharsY;
lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute;
lpLocalStartupInfo->dwFlags = Params->Flags;
lpLocalStartupInfo->wShowWindow = Params->ShowWindowFlags;
lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length;
lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
lpLocalStartupInfo->hStdInput = Params->InputHandle;
lpLocalStartupInfo->hStdOutput = Params->OutputHandle;
lpLocalStartupInfo->hStdError = Params->ErrorHandle;
}
RtlReleasePebLock ();
/* copy local startup info data to external startup info */
memcpy (lpStartupInfo,
lpLocalStartupInfo,
sizeof(STARTUPINFOA));
}
BOOL
STDCALL
FlushInstructionCache (
HANDLE hProcess,
LPCVOID lpBaseAddress,
HANDLE hProcess,
LPCVOID lpBaseAddress,
DWORD dwSize
)
{
@ -483,5 +485,4 @@ FatalAppExitW (
return;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: env.c,v 1.7 2000/02/18 00:49:11 ekohl Exp $
/* $Id: env.c,v 1.8 2000/02/19 19:34:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -229,8 +229,9 @@ RtlSetEnvironmentVariable (
UNICODE_STRING var;
int hole_len, new_len, env_len = 0;
WCHAR *new_env = 0, *env_end = 0, *wcs, *env, *val = 0, *tail = 0, *hole = 0;
ULONG size = 0, new_size;
LONG f = 1;
PWSTR head = NULL;
ULONG size = 0, new_size;
LONG f = 1;
NTSTATUS Status = STATUS_SUCCESS;
DPRINT ("RtlSetEnvironmentVariable Environment %p Name %wZ Value %wZ\n",
@ -275,6 +276,7 @@ RtlSetEnvironmentVariable (
}
else /* Exact match */
{
head = var.Buffer;
tail = ++wcs;
hole = val;
}
@ -366,14 +368,10 @@ found:
if (env)
{
size = 0;
CHECKPOINT;
DPRINT ("env %x\n", env);
DPRINT ("&env %x\n", &env);
NtFreeVirtualMemory (NtCurrentProcess (),
(VOID**)&env,
&size,
MEM_RELEASE);
CHECKPOINT;
}
}
@ -395,7 +393,7 @@ CHECKPOINT;
{
/* remove the environment variable */
if (f == 0)
memmove (hole,
memmove (head,
tail,
(env_end - tail) * sizeof(WCHAR));
else
@ -423,7 +421,7 @@ RtlQueryEnvironmentVariable_U (
int len;
DPRINT("RtlQueryEnvironmentVariable_U Environment %p Variable %wZ Value %p\n",
Environment, varname, Value);
Environment, Name, Value);
if (!Environment)
Environment = NtCurrentPeb()->ProcessParameters->Environment;

View file

@ -1,4 +1,4 @@
/* $Id: ppb.c,v 1.3 2000/02/18 00:49:11 ekohl Exp $
/* $Id: ppb.c,v 1.4 2000/02/19 19:34:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -70,23 +70,24 @@ STDCALL
RtlCreateProcessParameters (
PRTL_USER_PROCESS_PARAMETERS *Ppb,
PUNICODE_STRING CommandLine,
PUNICODE_STRING LibraryPath,
PUNICODE_STRING DllPath,
PUNICODE_STRING CurrentDirectory,
PUNICODE_STRING ImageName,
PUNICODE_STRING ImagePathName,
PVOID Environment,
PUNICODE_STRING Title,
PUNICODE_STRING Desktop,
PUNICODE_STRING Reserved,
PUNICODE_STRING Reserved2
PUNICODE_STRING WindowTitle,
PUNICODE_STRING DesktopInfo,
PUNICODE_STRING ShellInfo,
PUNICODE_STRING RuntimeData
)
{
NTSTATUS Status = STATUS_SUCCESS;
PRTL_USER_PROCESS_PARAMETERS Param = NULL;
ULONG RegionSize = 0;
ULONG DataSize = 0;
ULONG Length = 0;
PWCHAR Dest;
UNICODE_STRING EmptyString;
HANDLE CurrentDirectoryHandle;
HANDLE ConsoleHandle;
ULONG ConsoleFlags;
DPRINT ("RtlCreateProcessParameters\n");
@ -99,53 +100,55 @@ RtlCreateProcessParameters (
if (NtCurrentPeb()->ProcessParameters)
{
if (LibraryPath == NULL)
LibraryPath = &NtCurrentPeb()->ProcessParameters->LibraryPath;
if (DllPath == NULL)
DllPath = &NtCurrentPeb()->ProcessParameters->DllPath;
if (Environment == NULL)
Environment = NtCurrentPeb()->ProcessParameters->Environment;
if (CurrentDirectory == NULL)
CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
ConsoleFlags = NtCurrentPeb()->ProcessParameters->ConsoleFlags;
}
else
{
if (LibraryPath == NULL)
LibraryPath = &EmptyString;
if (DllPath == NULL)
DllPath = &EmptyString;
if (CurrentDirectory == NULL)
CurrentDirectory = &EmptyString;
CurrentDirectoryHandle = NULL;
ConsoleHandle = NULL;
ConsoleFlags = 0;
}
if (ImageName == NULL)
ImageName = CommandLine;
if (Title == NULL)
Title = &EmptyString;
if (Desktop == NULL)
Desktop = &EmptyString;
if (Reserved == NULL)
Reserved = &EmptyString;
if (Reserved2 == NULL)
Reserved2 = &EmptyString;
if (ImagePathName == NULL)
ImagePathName = CommandLine;
if (WindowTitle == NULL)
WindowTitle = &EmptyString;
if (DesktopInfo == NULL)
DesktopInfo = &EmptyString;
if (ShellInfo == NULL)
ShellInfo = &EmptyString;
if (RuntimeData == NULL)
RuntimeData = &EmptyString;
/* size of process parameter block */
DataSize = sizeof (RTL_USER_PROCESS_PARAMETERS);
Length = sizeof (RTL_USER_PROCESS_PARAMETERS);
/* size of current directory buffer */
DataSize += (MAX_PATH * sizeof(WCHAR));
Length += (MAX_PATH * sizeof(WCHAR));
/* add string lengths */
DataSize += ALIGN(LibraryPath->MaximumLength, sizeof(ULONG));
DataSize += ALIGN(CommandLine->Length, sizeof(ULONG));
DataSize += ALIGN(ImageName->Length, sizeof(ULONG));
DataSize += ALIGN(Title->MaximumLength, sizeof(ULONG));
DataSize += ALIGN(Desktop->MaximumLength, sizeof(ULONG));
DataSize += ALIGN(Reserved->MaximumLength, sizeof(ULONG));
DataSize += ALIGN(Reserved2->MaximumLength, sizeof(ULONG));
Length += ALIGN(DllPath->MaximumLength, sizeof(ULONG));
Length += ALIGN(CommandLine->Length, sizeof(ULONG));
Length += ALIGN(ImagePathName->Length, sizeof(ULONG));
Length += ALIGN(WindowTitle->MaximumLength, sizeof(ULONG));
Length += ALIGN(DesktopInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(ShellInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(RuntimeData->MaximumLength, sizeof(ULONG));
/* Calculate the required block size */
RegionSize = ROUNDUP(DataSize, PAGESIZE);
RegionSize = ROUNDUP(Length, PAGESIZE);
Status = NtAllocateVirtualMemory (
NtCurrentProcess (),
@ -162,11 +165,12 @@ RtlCreateProcessParameters (
DPRINT ("Ppb allocated\n");
Param->TotalSize = RegionSize;
Param->DataSize = DataSize;
Param->MaximumLength = RegionSize;
Param->Length = Length;
Param->Flags = PPF_NORMALIZED;
Param->Environment = Environment;
Param->CurrentDirectory.Handle = CurrentDirectoryHandle;
Param->ConsoleHandle = ConsoleHandle;
Param->ConsoleFlags = ConsoleFlags;
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS));
@ -193,8 +197,8 @@ RtlCreateProcessParameters (
/* copy library path */
RtlpCopyParameterString (&Dest,
&Param->LibraryPath,
LibraryPath,
&Param->DllPath,
DllPath,
0);
/* copy command line */
@ -205,30 +209,30 @@ RtlCreateProcessParameters (
/* copy image name */
RtlpCopyParameterString (&Dest,
&Param->ImageName,
ImageName,
ImageName->Length + sizeof(WCHAR));
&Param->ImagePathName,
ImagePathName,
ImagePathName->Length + sizeof(WCHAR));
/* copy title */
RtlpCopyParameterString (&Dest,
&Param->Title,
Title,
&Param->WindowTitle,
WindowTitle,
0);
/* copy desktop */
RtlpCopyParameterString (&Dest,
&Param->Desktop,
Desktop,
&Param->DesktopInfo,
DesktopInfo,
0);
RtlpCopyParameterString (&Dest,
&Param->ShellInfo,
Reserved,
ShellInfo,
0);
RtlpCopyParameterString (&Dest,
&Param->RuntimeData,
Reserved2,
RuntimeData,
0);
RtlDeNormalizeProcessParams (Param);
@ -264,11 +268,11 @@ RtlDeNormalizeProcessParams (
if (Params && (Params->Flags & PPF_NORMALIZED))
{
DENORMALIZE (Params->CurrentDirectory.DosPath.Buffer, Params);
DENORMALIZE (Params->LibraryPath.Buffer, Params);
DENORMALIZE (Params->DllPath.Buffer, Params);
DENORMALIZE (Params->CommandLine.Buffer, Params);
DENORMALIZE (Params->ImageName.Buffer, Params);
DENORMALIZE (Params->Title.Buffer, Params);
DENORMALIZE (Params->Desktop.Buffer, Params);
DENORMALIZE (Params->ImagePathName.Buffer, Params);
DENORMALIZE (Params->WindowTitle.Buffer, Params);
DENORMALIZE (Params->DesktopInfo.Buffer, Params);
DENORMALIZE (Params->ShellInfo.Buffer, Params);
DENORMALIZE (Params->RuntimeData.Buffer, Params);
@ -289,11 +293,11 @@ RtlNormalizeProcessParams (
if (Params && !(Params->Flags & PPF_NORMALIZED))
{
NORMALIZE (Params->CurrentDirectory.DosPath.Buffer, Params);
NORMALIZE (Params->LibraryPath.Buffer, Params);
NORMALIZE (Params->DllPath.Buffer, Params);
NORMALIZE (Params->CommandLine.Buffer, Params);
NORMALIZE (Params->ImageName.Buffer, Params);
NORMALIZE (Params->Title.Buffer, Params);
NORMALIZE (Params->Desktop.Buffer, Params);
NORMALIZE (Params->ImagePathName.Buffer, Params);
NORMALIZE (Params->WindowTitle.Buffer, Params);
NORMALIZE (Params->DesktopInfo.Buffer, Params);
NORMALIZE (Params->ShellInfo.Buffer, Params);
NORMALIZE (Params->RuntimeData.Buffer, Params);

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.14 2000/02/18 00:49:11 ekohl Exp $
/* $Id: process.c,v 1.15 2000/02/19 19:34:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -156,22 +156,17 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
ULONG PpbSize;
ULONG BytesWritten;
ULONG Offset;
PVOID ParentEnv = NULL;
PVOID EnvPtr = NULL;
ULONG EnvSize = 0;
/* create the Environment */
if (Ppb->Environment != NULL)
ParentEnv = Ppb->Environment;
else if (NtCurrentPeb()->ProcessParameters->Environment != NULL)
ParentEnv = NtCurrentPeb()->ProcessParameters->Environment;
if (ParentEnv != NULL)
{
MEMORY_BASIC_INFORMATION MemInfo;
Status = NtQueryVirtualMemory (NtCurrentProcess (),
ParentEnv,
Ppb->Environment,
MemoryBasicInformation,
&MemInfo,
sizeof(MEMORY_BASIC_INFORMATION),
@ -200,14 +195,15 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
NtWriteVirtualMemory(ProcessHandle,
EnvPtr,
ParentEnv,
Ppb->Environment,
EnvSize,
&BytesWritten);
}
DPRINT("EnvironmentPointer %p\n", EnvPtr);
/* create the PPB */
PpbBase = (PVOID)PEB_STARTUPINFO;
PpbSize = Ppb->TotalSize;
PpbSize = Ppb->MaximumLength;
Status = NtAllocateVirtualMemory(ProcessHandle,
&PpbBase,
0,
@ -219,14 +215,16 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
return(Status);
}
DPRINT("Ppb->TotalSize %x\n", Ppb->TotalSize);
DPRINT("Ppb->MaximumLength %x\n", Ppb->MaximumLength);
/* write process parameters block*/
RtlDeNormalizeProcessParams (Ppb);
NtWriteVirtualMemory(ProcessHandle,
PpbBase,
Ppb,
Ppb->TotalSize,
Ppb->MaximumLength,
&BytesWritten);
RtlNormalizeProcessParams (Ppb);
/* write pointer to environment */
Offset = FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment);
@ -262,13 +260,8 @@ NTSTATUS STDCALL RtlCreateUserProcess(PUNICODE_STRING CommandLine,
HANDLE hThread;
NTSTATUS Status;
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
// WCHAR TempCommandLine[256];
// PVOID BaseAddress;
// LARGE_INTEGER SectionOffset;
// ULONG InitialViewSize;
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
ULONG retlen;
// DWORD len = 0;
DPRINT("CreateProcessW(CommandLine '%w')\n", CommandLine->Buffer);

View file

@ -1,4 +1,4 @@
/* $Id: init.c,v 1.11 2000/02/18 00:51:03 ekohl Exp $
/* $Id: init.c,v 1.12 2000/02/19 19:37:13 ekohl Exp $
*
* init.c - Session Manager initialization
*
@ -65,6 +65,56 @@ SmCreatePagingFiles (VOID)
#endif
static VOID
SmSetEnvironmentVariables (VOID)
{
UNICODE_STRING EnvVariable;
UNICODE_STRING EnvValue;
/*
* The following environment variables are read from the registry.
* Since the registry does not work yet, the environment variables
* are set one by one, using hard-coded default values.
*
* Variables:
* SystemRoot = C:\reactos
* SystemDrive = C:
*
* OS = ReactOS
* Path = %SystemRoot%\system32;%SystemRoot%
* windir = %SystemRoot%
*/
/* Set "SystemRoot = C:\reactos" */
RtlInitUnicodeString (&EnvVariable,
L"SystemRoot");
RtlInitUnicodeString (&EnvValue,
L"C:\\reactos");
RtlSetEnvironmentVariable (&SmSystemEnvironment,
&EnvVariable,
&EnvValue);
/* Set "SystemDrive = C:" */
RtlInitUnicodeString (&EnvVariable,
L"SystemDrive");
RtlInitUnicodeString (&EnvValue,
L"C:");
RtlSetEnvironmentVariable (&SmSystemEnvironment,
&EnvVariable,
&EnvValue);
/* Set "OS = ReactOS" */
RtlInitUnicodeString (&EnvVariable,
L"OS");
RtlInitUnicodeString (&EnvValue,
L"ReactOS");
RtlSetEnvironmentVariable (&SmSystemEnvironment,
&EnvVariable,
&EnvValue);
}
BOOL
InitSessionManager (
HANDLE Children[]
@ -77,9 +127,6 @@ InitSessionManager (
UNICODE_STRING CurrentDirectoryW;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
UNICODE_STRING EnvVariable;
UNICODE_STRING EnvValue;
/* Create the "\SmApiPort" object (LPC) */
RtlInitUnicodeString (&UnicodeString,
L"\\SmApiPort");
@ -136,22 +183,6 @@ InitSessionManager (
DisplayString (L"SM: System Environment created\n");
#endif
RtlInitUnicodeString (&EnvVariable,
L"OS");
RtlInitUnicodeString (&EnvValue,
L"Reactos 0.0.15");
RtlSetEnvironmentVariable (SmSystemEnvironment,
&EnvVariable,
&EnvValue);
// RtlSetCurrentEnvironment (SmSystemEnvironment,
// NULL);
#ifndef NDEBUG
DisplayString (L"System Environment set\n");
#endif
/* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
/* FIXME: Run all programs in the boot execution list */
@ -167,10 +198,11 @@ InitSessionManager (
/* FIXME: Load missing registry hives */
/* FIXME: Set environment variables from registry */
/* Set environment variables from registry */
SmSetEnvironmentVariables ();
/* Load the kernel mode driver win32k.sys */
#if 0
/* Load the kernel mode driver win32k.sys */
RtlInitUnicodeString (&CmdLineW,
L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
Status = NtLoadDriver (&CmdLineW);
@ -181,7 +213,7 @@ InitSessionManager (
}
#endif
#if 0
#if 0
/* Start the Win32 subsystem (csrss.exe) */
DisplayString (L"SM: Executing csrss.exe\n");
RtlInitUnicodeString (&UnicodeString,