/* PRIVATE FUNCTIONS *********************************************************/
-NTSTATUS
-NTAPI
-PspDeleteLdt(PEPROCESS Process)
-{
- /* FIXME */
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-PspDeleteVdmObjects(PEPROCESS Process)
-{
- /* FIXME */
- return STATUS_SUCCESS;
-}
-
PETHREAD
NTAPI
PsGetNextProcessThread(IN PEPROCESS Process,
if (Mode == PsProcessPriorityForeground)
{
/* Set the memory priority and use priority separation */
- MemoryPriority = 2;
+ MemoryPriority = MEMORY_PRIORITY_FOREGROUND;
i = PsPrioritySeparation;
}
else
{
/* Set the background memory priority and no separation */
- MemoryPriority = 0;
+ MemoryPriority = MEMORY_PRIORITY_BACKGROUND;
i = 0;
}
BOOLEAN Result, SdAllocated;
PSECURITY_DESCRIPTOR SecurityDescriptor;
SECURITY_SUBJECT_CONTEXT SubjectContext;
+ BOOLEAN NeedsPeb = FALSE;
+ INITIAL_PEB InitialPeb;
PAGED_CODE();
PSTRACE(PS_PROCESS_DEBUG,
"ProcessHandle: %p Parent: %p\n", ProcessHandle, ParentProcess);
/* Check if we have a parent */
if (Parent)
{
- /* Ineherit PID and Hard Error Processing */
+ /* Inherit PID and Hard Error Processing */
Process->InheritedFromUniqueProcessId = Parent->UniqueProcessId;
Process->DefaultHardErrorProcessing = Parent->
DefaultHardErrorProcessing;
if (Parent != PsInitialSystemProcess)
{
/* It's not, so acquire the process rundown */
- if (ExAcquireRundownProtection(&Process->RundownProtect))
+ if (ExAcquireRundownProtection(&Parent->RundownProtect))
{
/* If the parent has a section, use it */
SectionObject = Parent->SectionObject;
if (SectionObject) ObReferenceObject(SectionObject);
/* Release process rundown */
- ExReleaseRundownProtection(&Process->RundownProtect);
+ ExReleaseRundownProtection(&Parent->RundownProtect);
}
/* If we don't have a section object */
Process->SectionObject = SectionObject;
/* Set default exit code */
- Process->ExitStatus = STATUS_TIMEOUT;
+ Process->ExitStatus = STATUS_PENDING;
/* Check if this is the initial process being built */
if (Parent)
SeAuditProcessCreationInfo.
ImageFileName);
if (!NT_SUCCESS(Status)) goto CleanupWithRef;
+
+ //
+ // We need a PEB
+ //
+ NeedsPeb = TRUE;
}
else if (Parent)
{
/* Check if this is a child of the system process */
if (Parent != PsInitialSystemProcess)
{
+ //
+ // We need a PEB
+ //
+ NeedsPeb = TRUE;
+
/* This is a clone! */
ASSERTMSG("No support for cloning yet\n", FALSE);
}
else
- {
+ {
/* This is the initial system process */
Flags &= ~PS_LARGE_PAGES;
Status = MmInitializeProcessAddressSpace(Process,
Process->SeAuditProcessCreationInfo.ImageFileName =
ExAllocatePoolWithTag(PagedPool,
sizeof(OBJECT_NAME_INFORMATION),
- TAG('S', 'e', 'P', 'a'));
+ 'aPeS');
if (!Process->SeAuditProcessCreationInfo.ImageFileName)
{
/* Fail */
}
}
+#if MI_TRACE_PFNS
+ /* Copy the process name now that we have it */
+ memcpy(MiGetPfnEntry(Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT)->ProcessName, Process->ImageFileName, 16);
+ if (Process->Pcb.DirectoryTableBase[1]) memcpy(MiGetPfnEntry(Process->Pcb.DirectoryTableBase[1] >> PAGE_SHIFT)->ProcessName, Process->ImageFileName, 16);
+ if (Process->WorkingSetPage) memcpy(MiGetPfnEntry(Process->WorkingSetPage)->ProcessName, Process->ImageFileName, 16);
+#endif
+
/* Check if we have a section object and map the system DLL */
if (SectionObject) PspMapSystemDll(Process, NULL, FALSE);
}
/* Create PEB only for User-Mode Processes */
- if (Parent)
+ if ((Parent) && (NeedsPeb))
{
- /* Create it */
- Status = MmCreatePeb(Process);
- if (!NT_SUCCESS(Status)) goto CleanupWithRef;
+ //
+ // Set up the initial PEB
+ //
+ RtlZeroMemory(&InitialPeb, sizeof(INITIAL_PEB));
+ InitialPeb.Mutant = (HANDLE)-1;
+ InitialPeb.ImageUsesLargePages = 0; // FIXME: Not yet supported
+
+ //
+ // Create it only if we have an image section
+ //
+ if (SectionHandle)
+ {
+ //
+ // Create it
+ //
+ Status = MmCreatePeb(Process, &InitialPeb, &Process->Peb);
+ if (!NT_SUCCESS(Status)) goto CleanupWithRef;
+ }
+ else
+ {
+ //
+ // We have to clone it
+ //
+ ASSERTMSG("No support for cloning yet\n", FALSE);
+ }
+
}
/* The process can now be activated */
KeQuerySystemTime(&Process->CreateTime);
/* Protect against bad user-mode pointer */
- _SEH_TRY
+ _SEH2_TRY
{
/* Save the process handle */
*ProcessHandle = hProcess;
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
- Status = _SEH_GetExceptionCode();
+ Status = _SEH2_GetExceptionCode();
}
- _SEH_END;
+ _SEH2_END;
+
+ /* Run the Notification Routines */
+ PspRunCreateProcessNotifyRoutines(Process, TRUE);
+
+ /* If 12 processes have been created, enough of user-mode is ready */
+ if (++ProcessCount == 12) Ki386PerfEnd();
CleanupWithRef:
/*
IN HANDLE ExceptionPort OPTIONAL,
IN BOOLEAN InJob)
{
- KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
- NTSTATUS Status = STATUS_SUCCESS;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ NTSTATUS Status;
PAGED_CODE();
PSTRACE(PS_PROCESS_DEBUG,
"ParentProcess: %p Flags: %lx\n", ParentProcess, Flags);
/* Check if we came from user mode */
- if(PreviousMode != KernelMode)
+ if (PreviousMode != KernelMode)
{
- _SEH_TRY
+ _SEH2_TRY
{
/* Probe process handle */
ProbeForWriteHandle(ProcessHandle);
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Get exception code */
- Status = _SEH_GetExceptionCode();
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
- _SEH_END;
- if (!NT_SUCCESS(Status)) return Status;
+ _SEH2_END;
}
/* Make sure there's a parent process */
BOOLEAN HasObjectName = FALSE;
PETHREAD Thread = NULL;
PEPROCESS Process = NULL;
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status;
ACCESS_STATE AccessState;
AUX_ACCESS_DATA AuxData;
PAGED_CODE();
if (PreviousMode != KernelMode)
{
/* Enter SEH for probing */
- _SEH_TRY
+ _SEH2_TRY
{
/* Probe the thread handle */
ProbeForWriteHandle(ProcessHandle);
HasObjectName = (ObjectAttributes->ObjectName != NULL);
Attributes = ObjectAttributes->Attributes;
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Get the exception code */
- Status = _SEH_GetExceptionCode();
+ /* Return the exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
- _SEH_END;
- if (!NT_SUCCESS(Status)) return Status;
+ _SEH2_END;
}
else
{
if (NT_SUCCESS(Status))
{
/* Use SEH for write back */
- _SEH_TRY
+ _SEH2_TRY
{
/* Write back the handle */
*ProcessHandle = hProcess;
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
- Status = _SEH_GetExceptionCode();
+ Status = _SEH2_GetExceptionCode();
}
- _SEH_END;
+ _SEH2_END;
}
/* Return status */