mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 00:28:56 +00:00
Improved RtlCreateUserProcess()
svn path=/trunk/; revision=1010
This commit is contained in:
parent
8f1ea8477c
commit
89875c3a44
|
@ -1,10 +1,31 @@
|
||||||
/* $Id: rtl.h,v 1.10 2000/02/19 19:33:28 ekohl Exp $
|
/* $Id: rtl.h,v 1.11 2000/02/25 23:57:21 ekohl Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID WINAPI __RtlInitHeap(PVOID base,
|
|
||||||
ULONG minsize,
|
/*
|
||||||
ULONG maxsize);
|
* Preliminary data type!!
|
||||||
|
*
|
||||||
|
* This definition is not finished yet. It will change in the future.
|
||||||
|
*/
|
||||||
|
typedef struct _RTL_USER_PROCESS_INFO
|
||||||
|
{
|
||||||
|
ULONG Unknown1; // 0x00
|
||||||
|
HANDLE ProcessHandle; // 0x04
|
||||||
|
HANDLE ThreadHandle; // 0x08
|
||||||
|
CLIENT_ID ClientId; // 0x0C
|
||||||
|
ULONG Unknown5; // 0x14
|
||||||
|
LONG StackZeroBits; // 0x18
|
||||||
|
LONG StackReserved; // 0x1C
|
||||||
|
LONG StackCommit; // 0x20
|
||||||
|
ULONG Unknown9; // 0x24
|
||||||
|
// more data ... ???
|
||||||
|
} RTL_USER_PROCESS_INFO, *PRTL_USER_PROCESS_INFO;
|
||||||
|
|
||||||
|
|
||||||
|
//VOID WINAPI __RtlInitHeap(PVOID base,
|
||||||
|
// ULONG minsize,
|
||||||
|
// ULONG maxsize);
|
||||||
|
|
||||||
#define HEAP_BASE (0xa0000000)
|
#define HEAP_BASE (0xa0000000)
|
||||||
|
|
||||||
|
@ -177,15 +198,15 @@ NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlCreateUserProcess (
|
RtlCreateUserProcess (
|
||||||
PUNICODE_STRING CommandLine,
|
PUNICODE_STRING CommandLine,
|
||||||
ULONG Unknown1,
|
ULONG Unknown2,
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters, // verified
|
||||||
PSECURITY_DESCRIPTOR ProcessSd,
|
PSECURITY_DESCRIPTOR ProcessSd,
|
||||||
PSECURITY_DESCRIPTOR ThreadSd,
|
PSECURITY_DESCRIPTOR ThreadSd,
|
||||||
WINBOOL bInheritHandles,
|
WINBOOL bInheritHandles,
|
||||||
DWORD dwCreationFlags,
|
DWORD dwCreationFlags,
|
||||||
PCLIENT_ID ClientId,
|
ULONG Unknown8,
|
||||||
PHANDLE ProcessHandle,
|
ULONG Unknown9,
|
||||||
PHANDLE ThreadHandle
|
PRTL_USER_PROCESS_INFO ProcessInfo // verified
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.15 2000/02/19 19:34:49 ekohl Exp $
|
/* $Id: process.c,v 1.16 2000/02/25 23:58:03 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -98,7 +98,9 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
|
||||||
return(ThreadHandle);
|
return(ThreadHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS RtlpMapFile(PUNICODE_STRING ApplicationName,
|
static NTSTATUS RtlpMapFile(
|
||||||
|
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
||||||
|
//PUNICODE_STRING ApplicationName,
|
||||||
PHANDLE Section)
|
PHANDLE Section)
|
||||||
{
|
{
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
@ -109,12 +111,17 @@ static NTSTATUS RtlpMapFile(PUNICODE_STRING ApplicationName,
|
||||||
|
|
||||||
hFile = NULL;
|
hFile = NULL;
|
||||||
|
|
||||||
|
RtlDeNormalizeProcessParams (Ppb);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
ApplicationName,
|
// ApplicationName,
|
||||||
|
&(Ppb->ImagePathName),
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
NULL,
|
NULL,
|
||||||
SecurityDescriptor);
|
SecurityDescriptor);
|
||||||
|
|
||||||
|
RtlNormalizeProcessParams (Ppb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to open the executable
|
* Try to open the executable
|
||||||
*/
|
*/
|
||||||
|
@ -245,16 +252,20 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL RtlCreateUserProcess(PUNICODE_STRING CommandLine,
|
NTSTATUS
|
||||||
ULONG Unknown1,
|
STDCALL
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
RtlCreateUserProcess (
|
||||||
PSECURITY_DESCRIPTOR ProcessSd,
|
PUNICODE_STRING CommandLine, // verified
|
||||||
PSECURITY_DESCRIPTOR ThreadSd,
|
ULONG Unknown2,
|
||||||
WINBOOL bInheritHandles,
|
PRTL_USER_PROCESS_PARAMETERS Ppb, // verified
|
||||||
DWORD dwCreationFlags,
|
PSECURITY_DESCRIPTOR ProcessSd,
|
||||||
PCLIENT_ID ClientId,
|
PSECURITY_DESCRIPTOR ThreadSd,
|
||||||
PHANDLE ProcessHandle,
|
WINBOOL bInheritHandles,
|
||||||
PHANDLE ThreadHandle)
|
DWORD dwCreationFlags,
|
||||||
|
ULONG Unknown8,
|
||||||
|
ULONG Unknown9,
|
||||||
|
PRTL_USER_PROCESS_INFO ProcessInfo // verified
|
||||||
|
)
|
||||||
{
|
{
|
||||||
HANDLE hSection;
|
HANDLE hSection;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
|
@ -263,16 +274,17 @@ NTSTATUS STDCALL RtlCreateUserProcess(PUNICODE_STRING CommandLine,
|
||||||
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
||||||
ULONG retlen;
|
ULONG retlen;
|
||||||
|
|
||||||
DPRINT("CreateProcessW(CommandLine '%w')\n", CommandLine->Buffer);
|
DPRINT("RtlCreateUserProcess\n");
|
||||||
|
|
||||||
Status = RtlpMapFile(CommandLine,
|
// Status = RtlpMapFile(CommandLine,
|
||||||
|
Status = RtlpMapFile(Ppb,
|
||||||
&hSection);
|
&hSection);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new process
|
* Create a new process
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Status = NtCreateProcess(ProcessHandle,
|
Status = NtCreateProcess(&(ProcessInfo->ProcessHandle),
|
||||||
PROCESS_ALL_ACCESS,
|
PROCESS_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
NtCurrentProcess(),
|
NtCurrentProcess(),
|
||||||
|
@ -289,23 +301,20 @@ NTSTATUS STDCALL RtlCreateUserProcess(PUNICODE_STRING CommandLine,
|
||||||
* Get some information about the process
|
* Get some information about the process
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZwQueryInformationProcess(*ProcessHandle,
|
ZwQueryInformationProcess(ProcessInfo->ProcessHandle,
|
||||||
ProcessBasicInformation,
|
ProcessBasicInformation,
|
||||||
&ProcessBasicInfo,
|
&ProcessBasicInfo,
|
||||||
sizeof(ProcessBasicInfo),
|
sizeof(ProcessBasicInfo),
|
||||||
&retlen);
|
&retlen);
|
||||||
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
||||||
ProcessBasicInfo.UniqueProcessId);
|
ProcessBasicInfo.UniqueProcessId);
|
||||||
if (ClientId != NULL)
|
ProcessInfo->ClientId.UniqueProcess = (HANDLE)ProcessBasicInfo.UniqueProcessId;
|
||||||
{
|
|
||||||
ClientId->UniqueProcess = (HANDLE)ProcessBasicInfo.UniqueProcessId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create Process Environment Block
|
* Create Process Environment Block
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating peb\n");
|
DPRINT("Creating peb\n");
|
||||||
KlInitPeb(*ProcessHandle, Ppb);
|
KlInitPeb(ProcessInfo->ProcessHandle, Ppb);
|
||||||
|
|
||||||
DPRINT("Creating thread for process\n");
|
DPRINT("Creating thread for process\n");
|
||||||
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
||||||
|
@ -313,12 +322,12 @@ NTSTATUS STDCALL RtlCreateUserProcess(PUNICODE_STRING CommandLine,
|
||||||
AddressOfEntryPoint +
|
AddressOfEntryPoint +
|
||||||
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->ImageBase;
|
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->ImageBase;
|
||||||
|
|
||||||
hThread = KlCreateFirstThread(*ProcessHandle,
|
hThread = KlCreateFirstThread(ProcessInfo->ProcessHandle,
|
||||||
// Headers.OptionalHeader.SizeOfStackReserve,
|
// Headers.OptionalHeader.SizeOfStackReserve,
|
||||||
0x200000,
|
0x200000,
|
||||||
lpStartAddress,
|
lpStartAddress,
|
||||||
dwCreationFlags,
|
dwCreationFlags,
|
||||||
ClientId);
|
&(ProcessInfo->ClientId));
|
||||||
if (hThread == NULL)
|
if (hThread == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("Failed to create thread\n");
|
DPRINT("Failed to create thread\n");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: init.c,v 1.13 2000/02/21 22:43:15 ekohl Exp $
|
/* $Id: init.c,v 1.14 2000/02/25 23:58:57 ekohl Exp $
|
||||||
*
|
*
|
||||||
* init.c - Session Manager initialization
|
* init.c - Session Manager initialization
|
||||||
*
|
*
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
|
||||||
|
/* uncomment to run csrss.exe */
|
||||||
|
//#define RUN_CSRSS
|
||||||
|
|
||||||
/* GLOBAL VARIABLES *********************************************************/
|
/* GLOBAL VARIABLES *********************************************************/
|
||||||
|
|
||||||
|
@ -126,6 +128,7 @@ InitSessionManager (
|
||||||
UNICODE_STRING CmdLineW;
|
UNICODE_STRING CmdLineW;
|
||||||
UNICODE_STRING CurrentDirectoryW;
|
UNICODE_STRING CurrentDirectoryW;
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
|
||||||
|
RTL_USER_PROCESS_INFO ProcessInfo;
|
||||||
|
|
||||||
/* Create the "\SmApiPort" object (LPC) */
|
/* Create the "\SmApiPort" object (LPC) */
|
||||||
RtlInitUnicodeString (&UnicodeString,
|
RtlInitUnicodeString (&UnicodeString,
|
||||||
|
@ -191,18 +194,19 @@ InitSessionManager (
|
||||||
|
|
||||||
/* FIXME: Load the well known DLLs */
|
/* FIXME: Load the well known DLLs */
|
||||||
|
|
||||||
/* Create paging files */
|
|
||||||
#if 0
|
#if 0
|
||||||
|
/* Create paging files */
|
||||||
SmCreatePagingFiles ();
|
SmCreatePagingFiles ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Load missing registry hives */
|
/* Load missing registry hives */
|
||||||
// NtInitializeRegistry (FALSE);
|
NtInitializeRegistry (FALSE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set environment variables from registry */
|
/* Set environment variables from registry */
|
||||||
SmSetEnvironmentVariables ();
|
SmSetEnvironmentVariables ();
|
||||||
|
|
||||||
//#if 0
|
|
||||||
/* Load the kernel mode driver win32k.sys */
|
/* Load the kernel mode driver win32k.sys */
|
||||||
RtlInitUnicodeString (&CmdLineW,
|
RtlInitUnicodeString (&CmdLineW,
|
||||||
L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
|
L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
|
||||||
|
@ -212,9 +216,8 @@ InitSessionManager (
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
|
|
||||||
#if 0
|
#ifdef RUN_CSRSS
|
||||||
/* Start the Win32 subsystem (csrss.exe) */
|
/* Start the Win32 subsystem (csrss.exe) */
|
||||||
DisplayString (L"SM: Executing csrss.exe\n");
|
DisplayString (L"SM: Executing csrss.exe\n");
|
||||||
|
|
||||||
|
@ -243,17 +246,19 @@ InitSessionManager (
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
0,
|
||||||
&Children[CHILD_CSRSS],
|
0,
|
||||||
NULL);
|
&ProcessInfo);
|
||||||
|
|
||||||
|
RtlDestroyProcessParameters (ProcessParameters);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DisplayString (L"SM: Loading csrss.exe failed!\n");
|
DisplayString (L"SM: Loading csrss.exe failed!\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Children[CHILD_CSRSS] = ProcessInfo.ProcessHandle;
|
||||||
RtlDestroyProcessParameters (ProcessParameters);
|
#endif /* RUN_CSRSS */
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Start the simple shell (shell.exe) */
|
/* Start the simple shell (shell.exe) */
|
||||||
|
@ -262,7 +267,8 @@ InitSessionManager (
|
||||||
L"\\??\\C:\\reactos\\system32\\shell.exe");
|
L"\\??\\C:\\reactos\\system32\\shell.exe");
|
||||||
#if 0
|
#if 0
|
||||||
/* Start the logon process (winlogon.exe) */
|
/* Start the logon process (winlogon.exe) */
|
||||||
RtlInitUnicodeString (&CmdLineW,
|
DisplayString (L"SM: Running winlogon\n");
|
||||||
|
RtlInitUnicodeString (&UnicodeString,
|
||||||
L"\\??\\C:\\reactos\\system32\\winlogon.exe");
|
L"\\??\\C:\\reactos\\system32\\winlogon.exe");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -289,9 +295,9 @@ InitSessionManager (
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
0,
|
||||||
&Children[CHILD_WINLOGON],
|
0,
|
||||||
NULL);
|
&ProcessInfo);
|
||||||
|
|
||||||
RtlDestroyProcessParameters (ProcessParameters);
|
RtlDestroyProcessParameters (ProcessParameters);
|
||||||
|
|
||||||
|
@ -304,6 +310,7 @@ InitSessionManager (
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Children[CHILD_WINLOGON] = ProcessInfo.ProcessHandle;
|
||||||
|
|
||||||
/* Create the \DbgSsApiPort object (LPC) */
|
/* Create the \DbgSsApiPort object (LPC) */
|
||||||
RtlInitUnicodeString (&UnicodeString,
|
RtlInitUnicodeString (&UnicodeString,
|
||||||
|
|
Loading…
Reference in a new issue