Implemented PsCreateSystemProcess()

svn path=/trunk/; revision=1815
This commit is contained in:
Eric Kohl 2001-04-21 12:39:33 +00:00
parent 71d0b655ac
commit cb2396496c
4 changed files with 71 additions and 44 deletions

View file

@ -1,4 +1,4 @@
/* $Id: psfuncs.h,v 1.12 2000/12/22 13:29:48 ekohl Exp $ /* $Id: psfuncs.h,v 1.13 2001/04/21 12:38:28 ekohl Exp $
*/ */
#ifndef _INCLUDE_DDK_PSFUNCS_H #ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H #define _INCLUDE_DDK_PSFUNCS_H
@ -34,6 +34,10 @@ NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle,
PVOID StartContext); PVOID StartContext);
NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus); NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus);
NTSTATUS STDCALL PsCreateSystemProcess(PHANDLE ProcessHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes);
struct _ETHREAD* STDCALL PsGetCurrentThread(VOID); struct _ETHREAD* STDCALL PsGetCurrentThread(VOID);
struct _EPROCESS* STDCALL PsGetCurrentProcess(VOID); struct _EPROCESS* STDCALL PsGetCurrentProcess(VOID);
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread, PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread,

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.103 2001/04/16 00:48:04 chorns Exp $ ; $Id: ntoskrnl.def,v 1.104 2001/04/21 12:39:33 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -586,7 +586,7 @@ PoUnregisterSystemState@4
;ProbeForWrite@12 ;ProbeForWrite@12
PsAssignImpersonationToken@8 PsAssignImpersonationToken@8
;PsChargePoolQuota@12 ;PsChargePoolQuota@12
;PsCreateSystemProcess@12 PsCreateSystemProcess@12
PsCreateSystemThread@28 PsCreateSystemThread@28
;PsCreateWin32Process@4 ;PsCreateWin32Process@4
;PsEstablishWin32Callouts@24 ;PsEstablishWin32Callouts@24

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.90 2001/04/16 00:48:04 chorns Exp $ ; $Id: ntoskrnl.edf,v 1.91 2001/04/21 12:39:33 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -586,7 +586,7 @@ PoUnregisterSystemState=PoUnregisterSystemState@4
;ProbeForWrite=ProbeForWrite@12 ;ProbeForWrite=ProbeForWrite@12
PsAssignImpersonationToken=PsAssignImpersonationToken@8 PsAssignImpersonationToken=PsAssignImpersonationToken@8
;PsChargePoolQuota=PsChargePoolQuota@12 ;PsChargePoolQuota=PsChargePoolQuota@12
;PsCreateSystemProcess=PsCreateSystemProcess@12 PsCreateSystemProcess=PsCreateSystemProcess@12
PsCreateSystemThread=PsCreateSystemThread@28 PsCreateSystemThread=PsCreateSystemThread@28
;PsCreateWin32Process ;PsCreateWin32Process
;PsEstablishWin32Callouts ;PsEstablishWin32Callouts

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.62 2001/04/16 16:29:03 dwelch Exp $ /* $Id: process.c,v 1.63 2001/04/21 12:39:05 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -90,7 +90,7 @@ PsGetNextProcess(PEPROCESS OldProcess)
NTSTATUS STDCALL NTSTATUS STDCALL
NtOpenProcessToken(IN HANDLE ProcessHandle, NtOpenProcessToken(IN HANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess, IN ACCESS_MASK DesiredAccess,
OUT PHANDLE TokenHandle) OUT PHANDLE TokenHandle)
{ {
PACCESS_TOKEN Token; PACCESS_TOKEN Token;
@ -111,7 +111,7 @@ NtOpenProcessToken(IN HANDLE ProcessHandle,
return(Status); return(Status);
} }
PACCESS_TOKEN STDCALL PACCESS_TOKEN STDCALL
PsReferencePrimaryToken(PEPROCESS Process) PsReferencePrimaryToken(PEPROCESS Process)
{ {
ObReferenceObjectByPointer(Process->Token, ObReferenceObjectByPointer(Process->Token,
@ -121,7 +121,7 @@ PsReferencePrimaryToken(PEPROCESS Process)
return(Process->Token); return(Process->Token);
} }
NTSTATUS NTSTATUS
PsOpenTokenOfProcess(HANDLE ProcessHandle, PsOpenTokenOfProcess(HANDLE ProcessHandle,
PACCESS_TOKEN* Token) PACCESS_TOKEN* Token)
{ {
@ -296,7 +296,8 @@ static NTSTATUS PsCreatePeb(HANDLE ProcessHandle,
} }
PKPROCESS KeGetCurrentProcess(VOID) PKPROCESS
KeGetCurrentProcess(VOID)
/* /*
* FUNCTION: Returns a pointer to the current process * FUNCTION: Returns a pointer to the current process
*/ */
@ -304,7 +305,8 @@ PKPROCESS KeGetCurrentProcess(VOID)
return(&(PsGetCurrentProcess()->Pcb)); return(&(PsGetCurrentProcess()->Pcb));
} }
HANDLE STDCALL PsGetCurrentProcessId(VOID) HANDLE STDCALL
PsGetCurrentProcessId(VOID)
{ {
return((HANDLE)PsGetCurrentProcess()->UniqueProcessId); return((HANDLE)PsGetCurrentProcess()->UniqueProcessId);
} }
@ -312,7 +314,8 @@ HANDLE STDCALL PsGetCurrentProcessId(VOID)
/* /*
* FUNCTION: Returns a pointer to the current process * FUNCTION: Returns a pointer to the current process
*/ */
PEPROCESS STDCALL PsGetCurrentProcess(VOID) PEPROCESS STDCALL
PsGetCurrentProcess(VOID)
{ {
if (PsGetCurrentThread() == NULL || if (PsGetCurrentThread() == NULL ||
PsGetCurrentThread()->ThreadsProcess == NULL) PsGetCurrentThread()->ThreadsProcess == NULL)
@ -325,20 +328,36 @@ PEPROCESS STDCALL PsGetCurrentProcess(VOID)
} }
} }
PEPROCESS STDCALL IoGetCurrentProcess(VOID) PEPROCESS STDCALL
IoGetCurrentProcess(VOID)
{ {
return(PsGetCurrentProcess()); return(PsGetCurrentProcess());
} }
NTSTATUS STDCALL NTSTATUS STDCALL
NtCreateProcess (OUT PHANDLE ProcessHandle, PsCreateSystemProcess(PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, POBJECT_ATTRIBUTES ObjectAttributes)
IN HANDLE ParentProcessHandle, {
IN BOOLEAN InheritObjectTable, return NtCreateProcess(ProcessHandle,
IN HANDLE SectionHandle OPTIONAL, DesiredAccess,
IN HANDLE DebugPortHandle OPTIONAL, ObjectAttributes,
IN HANDLE ExceptionPortHandle OPTIONAL) SystemProcessHandle,
FALSE,
NULL,
NULL,
NULL);
}
NTSTATUS STDCALL
NtCreateProcess(OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN HANDLE ParentProcessHandle,
IN BOOLEAN InheritObjectTable,
IN HANDLE SectionHandle OPTIONAL,
IN HANDLE DebugPortHandle OPTIONAL,
IN HANDLE ExceptionPortHandle OPTIONAL)
/* /*
* FUNCTION: Creates a process. * FUNCTION: Creates a process.
* ARGUMENTS: * ARGUMENTS:
@ -534,7 +553,7 @@ NtCreateProcess (OUT PHANDLE ProcessHandle,
ObDereferenceObject(Process); ObDereferenceObject(Process);
ObDereferenceObject(ParentProcess); ObDereferenceObject(ParentProcess);
ZwClose(*ProcessHandle); ZwClose(*ProcessHandle);
*ProcessHandle = NULL; *ProcessHandle = NULL;
return(Status); return(Status);
} }
Process->Peb = Peb; Process->Peb = Peb;
@ -573,10 +592,11 @@ NtCreateProcess (OUT PHANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtOpenProcess (OUT PHANDLE ProcessHandle, NTSTATUS STDCALL
IN ACCESS_MASK DesiredAccess, NtOpenProcess(OUT PHANDLE ProcessHandle,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess,
IN PCLIENT_ID ClientId) IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PCLIENT_ID ClientId)
{ {
DPRINT("NtOpenProcess(ProcessHandle %x, DesiredAccess %x, " DPRINT("NtOpenProcess(ProcessHandle %x, DesiredAccess %x, "
"ObjectAttributes %x, ClientId %x { UniP %d, UniT %d })\n", "ObjectAttributes %x, ClientId %x { UniP %d, UniT %d })\n",
@ -643,7 +663,7 @@ NTSTATUS STDCALL NtOpenProcess (OUT PHANDLE ProcessHandle,
ObDereferenceObject(current); ObDereferenceObject(current);
DPRINT("*ProcessHandle %x\n", ProcessHandle); DPRINT("*ProcessHandle %x\n", ProcessHandle);
DPRINT("NtOpenProcess() = %x\n", Status); DPRINT("NtOpenProcess() = %x\n", Status);
return(Status); return(Status);
} }
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
} }
@ -655,11 +675,12 @@ NTSTATUS STDCALL NtOpenProcess (OUT PHANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtQueryInformationProcess (IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN CINT ProcessInformationClass, NtQueryInformationProcess(IN HANDLE ProcessHandle,
OUT PVOID ProcessInformation, IN CINT ProcessInformationClass,
IN ULONG ProcessInformationLength, OUT PVOID ProcessInformation,
OUT PULONG ReturnLength) IN ULONG ProcessInformationLength,
OUT PULONG ReturnLength)
{ {
PEPROCESS Process; PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
@ -684,10 +705,10 @@ NTSTATUS STDCALL NtQueryInformationProcess (IN HANDLE ProcessHandle,
ProcessBasicInformationP->ExitStatus = Process->ExitStatus; ProcessBasicInformationP->ExitStatus = Process->ExitStatus;
ProcessBasicInformationP->PebBaseAddress = Process->Peb; ProcessBasicInformationP->PebBaseAddress = Process->Peb;
ProcessBasicInformationP->AffinityMask = Process->Pcb.Affinity; ProcessBasicInformationP->AffinityMask = Process->Pcb.Affinity;
ProcessBasicInformationP->UniqueProcessId = ProcessBasicInformationP->UniqueProcessId =
Process->UniqueProcessId; Process->UniqueProcessId;
ProcessBasicInformationP->InheritedFromUniqueProcessId = ProcessBasicInformationP->InheritedFromUniqueProcessId =
(ULONG)Process->InheritedFromUniqueProcessId; (ULONG)Process->InheritedFromUniqueProcessId;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
@ -724,8 +745,9 @@ NTSTATUS STDCALL NtQueryInformationProcess (IN HANDLE ProcessHandle,
return(Status); return(Status);
} }
NTSTATUS PspAssignPrimaryToken(PEPROCESS Process, NTSTATUS
HANDLE TokenHandle) PspAssignPrimaryToken(PEPROCESS Process,
HANDLE TokenHandle)
{ {
PACCESS_TOKEN Token; PACCESS_TOKEN Token;
PACCESS_TOKEN OldToken; PACCESS_TOKEN OldToken;
@ -750,10 +772,11 @@ NTSTATUS PspAssignPrimaryToken(PEPROCESS Process,
return(Status); return(Status);
} }
NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN CINT ProcessInformationClass, NtSetInformationProcess(IN HANDLE ProcessHandle,
IN PVOID ProcessInformation, IN CINT ProcessInformationClass,
IN ULONG ProcessInformationLength) IN PVOID ProcessInformation,
IN ULONG ProcessInformationLength)
{ {
PEPROCESS Process; PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
@ -799,7 +822,7 @@ NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle,
// DPRINT1("Process->ImageFileName %.8s\n", Process->ImageFileName); // DPRINT1("Process->ImageFileName %.8s\n", Process->ImageFileName);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case ProcessLdtInformation: case ProcessLdtInformation:
case ProcessLdtSize: case ProcessLdtSize:
case ProcessDefaultHardErrorMode: case ProcessDefaultHardErrorMode: