LARGE_INTEGER ShortPsLockDelay;
-ULONG PsRawPrioritySeparation = 0;
+ULONG PsRawPrioritySeparation;
ULONG PsPrioritySeparation;
CHAR PspForegroundQuantum[3];
/* Use a variable table */
QuantumTable = PspVariableQuantums;
}
- else
+ else if (PspQuantumTypeFromMask(PrioritySeparation) == PSP_FIXED_QUANTUMS)
{
/* Use fixed table */
QuantumTable = PspFixedQuantums;
}
+ else
+ {
+ /* Use default for the type of system we're on */
+ QuantumTable = MmIsThisAnNtAsSystem() ? PspFixedQuantums : PspVariableQuantums;
+ }
/* Now check if we should use long or short */
if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_LONG_QUANTUMS)
/* Use long quantums */
QuantumTable += 3;
}
+ else if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_SHORT_QUANTUMS)
+ {
+ /* Keep existing table */
+ NOTHING;
+ }
+ else
+ {
+ /* Use default for the type of system we're on */
+ QuantumTable += MmIsThisAnNtAsSystem() ? 3 : 0;
+ }
/* Check if we're using long fixed quantums */
if (QuantumTable == &PspFixedQuantums[3])
Process = PsGetNextProcess(Process);
while (Process)
{
- /*
- * Use the priority separation, unless the process has
- * low memory priority
- */
- i = (Process->Vm.Flags.MemoryPriority == 1) ?
- 0: PsPrioritySeparation;
+ /* Use the priority separation if this is a foreground process */
+ i = (Process->Vm.Flags.MemoryPriority ==
+ MEMORY_PRIORITY_BACKGROUND) ?
+ 0: PsPrioritySeparation;
/* Make sure that the process isn't idle */
if (Process->PriorityClass != PROCESS_PRIORITY_CLASS_IDLE)
if ((Process->Job) && (PspUseJobSchedulingClasses))
{
/* Use job quantum */
- Quantum = PspJobSchedulingClasses[Process->Job->
- SchedulingClass];
+ Quantum = PspJobSchedulingClasses[Process->Job->SchedulingClass];
}
else
{
"ProcessHandle: %p Parent: %p\n", ProcessHandle, ParentProcess);
/* Validate flags */
- if (Flags & ~PS_ALL_FLAGS) return STATUS_INVALID_PARAMETER;
+ if (Flags & ~PROCESS_CREATE_FLAGS_LEGAL_MASK) return STATUS_INVALID_PARAMETER;
/* Check for parent */
if (ParentProcess)
/* Check if we have a parent */
if (Parent)
{
- /* Inherit PID and Hard Error Processing */
+ /* Inherit PID and hard-error processing */
Process->InheritedFromUniqueProcessId = Parent->UniqueProcessId;
- Process->DefaultHardErrorProcessing = Parent->
- DefaultHardErrorProcessing;
+ Process->DefaultHardErrorProcessing = Parent->DefaultHardErrorProcessing;
}
else
{
- /* Use default hard error processing */
- Process->DefaultHardErrorProcessing = TRUE;
+ /* Use default hard-error processing */
+ Process->DefaultHardErrorProcessing = SEM_FAILCRITICALERRORS;
}
/* Check for a section handle */
Process->DebugPort = DebugObject;
/* Check if the caller doesn't want the debug stuff inherited */
- if (Flags & PS_NO_DEBUG_INHERIT)
+ if (Flags & PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT)
{
/* Set the process flag */
InterlockedOr((PLONG)&Process->Flags, PSF_NO_DEBUG_INHERIT_BIT);
PROCESS_PRIORITY_NORMAL,
Affinity,
DirectoryTableBase,
- (BOOLEAN)(Process->DefaultHardErrorProcessing & 4));
+ BooleanFlagOn(Process->DefaultHardErrorProcessing,
+ SEM_NOALIGNMENTFAULTEXCEPT));
/* Duplicate Parent Token */
Status = PspInitializeProcessSecurity(Process, Parent);
}
/* Initialize object manager for the process */
- Status = ObInitProcess(Flags & PS_INHERIT_HANDLES ? Parent : NULL,
+ Status = ObInitProcess(Flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES ?
+ Parent : NULL,
Process);
if (!NT_SUCCESS(Status)) goto CleanupWithRef;
}
else
{
/* This is the initial system process */
- Flags &= ~PS_LARGE_PAGES;
+ Flags &= ~PROCESS_CREATE_FLAGS_LARGE_PAGES;
Status = MmInitializeProcessAddressSpace(Process,
NULL,
NULL,
Process->SeAuditProcessCreationInfo.ImageFileName =
ExAllocatePoolWithTag(PagedPool,
sizeof(OBJECT_NAME_INFORMATION),
- 'aPeS');
+ TAG_SEPA);
if (!Process->SeAuditProcessCreationInfo.ImageFileName)
{
/* Fail */
{
/* FIXME: We need to insert this process */
DPRINT1("Jobs not yet supported\n");
- ASSERT(FALSE);
}
/* Create PEB only for User-Mode Processes */
/* Protect against bad user-mode pointer */
_SEH2_TRY
{
+ /* Hacky way of returning the PEB to the user-mode creator */
+ if ((Process->Peb) && (CurrentThread->Tcb.Teb))
+ {
+ CurrentThread->Tcb.Teb->NtTib.ArbitraryUserPointer = Process->Peb;
+ }
+
/* Save the process handle */
*ProcessHandle = hProcess;
}
/*
* @implemented
*/
-HANDLE
+ULONG
+NTAPI
+PsGetProcessSessionId(IN PEPROCESS Process)
+{
+ return MmGetSessionId(Process);
+}
+
+/*
+ * @implemented
+ */
+ULONG
NTAPI
-PsGetProcessSessionId(PEPROCESS Process)
+PsGetProcessSessionIdEx(IN PEPROCESS Process)
{
- return (HANDLE)Process->Session;
+ return MmGetSessionIdEx(Process);
}
/*
/*
* @implemented
*/
-VOID
+NTSTATUS
NTAPI
PsSetProcessSecurityPort(PEPROCESS Process,
PVOID SecurityPort)
{
Process->SecurityPort = SecurityPort;
+ return STATUS_SUCCESS;
}
/*
* @implemented
*/
-VOID
+NTSTATUS
NTAPI
-PsSetProcessWin32Process(PEPROCESS Process,
- PVOID Win32Process)
+PsSetProcessWin32Process(
+ _Inout_ PEPROCESS Process,
+ _In_opt_ PVOID Win32Process,
+ _In_opt_ PVOID OldWin32Process)
{
- Process->Win32Process = Win32Process;
+ NTSTATUS Status;
+
+ /* Assume success */
+ Status = STATUS_SUCCESS;
+
+ /* Lock the process */
+ KeEnterCriticalRegion();
+ ExAcquirePushLockExclusive(&Process->ProcessLock);
+
+ /* Check if we set a new win32 process */
+ if (Win32Process != NULL)
+ {
+ /* Check if the process is in the right state */
+ if (((Process->Flags & PSF_PROCESS_DELETE_BIT) == 0) &&
+ (Process->Win32Process == NULL))
+ {
+ /* Set the new win32 process */
+ Process->Win32Process = Win32Process;
+ }
+ else
+ {
+ /* Otherwise fail */
+ Status = STATUS_PROCESS_IS_TERMINATING;
+ }
+ }
+ else
+ {
+ /* Reset the win32 process, did the caller specify the correct old value? */
+ if (Process->Win32Process == OldWin32Process)
+ {
+ /* Yes, so reset the win32 process to NULL */
+ Process->Win32Process = NULL;
+ }
+ else
+ {
+ /* Otherwise fail */
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ }
+
+ /* Unlock the process */
+ ExReleasePushLockExclusive(&Process->ProcessLock);
+ KeLeaveCriticalRegion();
+
+ return Status;
}
/*
"Parent: %p Attributes: %p\n", ParentProcess, ObjectAttributes);
/* Set new-style flags */
- if ((ULONG)SectionHandle & 1) Flags = PS_REQUEST_BREAKAWAY;
- if ((ULONG)DebugPort & 1) Flags |= PS_NO_DEBUG_INHERIT;
- if (InheritObjectTable) Flags |= PS_INHERIT_HANDLES;
+ if ((ULONG_PTR)SectionHandle & 1) Flags |= PROCESS_CREATE_FLAGS_BREAKAWAY;
+ if ((ULONG_PTR)DebugPort & 1) Flags |= PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT;
+ if (InheritObjectTable) Flags |= PROCESS_CREATE_FLAGS_INHERIT_HANDLES;
/* Call the new API */
return NtCreateProcessEx(ProcessHandle,
sizeof(OBJECT_ATTRIBUTES),
sizeof(ULONG));
HasObjectName = (ObjectAttributes->ObjectName != NULL);
- Attributes = ObjectAttributes->Attributes;
+
+ /* Validate user attributes */
+ Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
{
/* Otherwise just get the data directly */
HasObjectName = (ObjectAttributes->ObjectName != NULL);
- Attributes = ObjectAttributes->Attributes;
+
+ /* Still have to sanitize attributes */
+ Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode);
}
/* Can't pass both, fail */