From b20633a1f0b228e99eafb5536fa229a2b239356a Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 24 Sep 2008 08:12:41 +0000 Subject: [PATCH] - Make SmCreateUserProcess accept two flags: the old "wait for" one, and a new "reserve 1Mb" one. NT reserves lower 1MB of address space when starting a subsystem process. ReactOS should too, however right now this change is disabled (leads to boot problems). svn path=/trunk/; revision=36450 --- reactos/base/system/smss/initrun.c | 4 ++-- reactos/base/system/smss/smapiexec.c | 35 +++++++++++++++++----------- reactos/base/system/smss/smss.h | 4 +++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/reactos/base/system/smss/initrun.c b/reactos/base/system/smss/initrun.c index b49b6f4cdae..186254c0978 100644 --- a/reactos/base/system/smss/initrun.c +++ b/reactos/base/system/smss/initrun.c @@ -80,8 +80,8 @@ SmpRunBootAppsQueryRoutine(PWSTR ValueName, /* Create NT process */ Status = SmCreateUserProcess (ImagePath, - CommandLine, - TRUE, /* wait */ + CommandLine, + SM_CREATE_FLAG_WAIT, NULL, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/base/system/smss/smapiexec.c b/reactos/base/system/smss/smapiexec.c index 086bd960dd3..6c89ee7481f 100644 --- a/reactos/base/system/smss/smapiexec.c +++ b/reactos/base/system/smss/smapiexec.c @@ -22,8 +22,10 @@ static const WCHAR szSystemDirectory[] = L"\\System32"; * ARGUMENTS * ImagePath: absolute path of the image to run; * CommandLine: arguments and options for ImagePath; - * WaitForIt: TRUE for boot time processes and FALSE for - * subsystems bootstrapping; + * Flags: Wait flag: Set for boot time processes and unset for + * subsystems bootstrapping; + * 1Mb reserve flag: Set for subsystems, unset for everything +* else * Timeout: optional: used if WaitForIt==TRUE; * ProcessHandle: optional: a duplicated handle for the child process (storage provided by the caller). @@ -35,7 +37,7 @@ static const WCHAR szSystemDirectory[] = L"\\System32"; NTSTATUS STDCALL SmCreateUserProcess (LPWSTR ImagePath, LPWSTR CommandLine, - BOOLEAN WaitForIt, + ULONG Flags, PLARGE_INTEGER Timeout OPTIONAL, PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL) { @@ -106,7 +108,12 @@ FailProcParams: __FUNCTION__, Status); return Status; } - +#ifdef ROS_DOESNT_SUCK + /* Reserve lower 1Mb, if requested */ + if (Flags & SM_CREATE_FLAG_RESERVE_1MB) + ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB; +#endif + /* Create the user process */ Status = RtlCreateUserProcess (& ImagePathString, OBJ_CASE_INSENSITIVE, ProcessParameters, @@ -141,7 +148,7 @@ FailProcParams: } /* Wait for process termination */ - if (WaitForIt) + if (Flags & SM_CREATE_FLAG_WAIT) { Status = NtWaitForSingleObject (pProcessInfo->ProcessHandle, FALSE, @@ -151,13 +158,13 @@ FailProcParams: DPRINT1("SM: %s: NtWaitForSingleObject failed with Status=0x%08lx\n", __FUNCTION__, Status); } - } - if (NULL == UserProcessInfo) - { - NtClose(pProcessInfo->ProcessHandle); - NtClose(pProcessInfo->ThreadHandle); - } + + if (NULL == UserProcessInfo) + { + NtClose(pProcessInfo->ProcessHandle); + NtClose(pProcessInfo->ThreadHandle); + } return Status; } @@ -230,9 +237,9 @@ SMAPI(SmExecPgm) Request->SmHeader.Status = SmCreateUserProcess(ImagePath, CommandLine, - FALSE, /* wait */ - NULL, /* timeout */ - & ProcessInfo); + SM_CREATE_FLAG_RESERVE_1MB, + NULL, /* timeout */ + & ProcessInfo); if (NT_SUCCESS(Request->SmHeader.Status)) { Status = SmCreateClient (& ProcessInfo, Name); diff --git a/reactos/base/system/smss/smss.h b/reactos/base/system/smss/smss.h index b5000dcac24..23e3cd0a46a 100644 --- a/reactos/base/system/smss/smss.h +++ b/reactos/base/system/smss/smss.h @@ -61,9 +61,11 @@ VOID STDCALL SmpApiThread(PVOID); /* smapiexec.c */ +#define SM_CREATE_FLAG_WAIT 0x01 +#define SM_CREATE_FLAG_RESERVE_1MB 0x02 NTSTATUS STDCALL SmCreateUserProcess(LPWSTR ImagePath, LPWSTR CommandLine, - BOOLEAN WaitForIt, + ULONG Flags, PLARGE_INTEGER Timeout OPTIONAL, PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL); NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE);