* PURPOSE: Process Manager: Thread/Process Query/Set Information
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Thomas Weidenmueller (w3seek@reactos.org)
+ * Eric Kohl
*/
/* INCLUDES ******************************************************************/
Process->Vm.MinimumWorkingSetSize << PAGE_SHIFT;
/* Set default time limits */
- QuotaLimits->TimeLimit.LowPart = (ULONG)-1;
- QuotaLimits->TimeLimit.HighPart = (ULONG)-1;
+ QuotaLimits->TimeLimit.LowPart = MAXULONG;
+ QuotaLimits->TimeLimit.HighPart = MAXULONG;
/* Is quota block a default one? */
if (Process->QuotaBlock == &PspDefaultQuotaBlock)
ObDereferenceObject(Process);
break;
+ case ProcessBreakOnTermination:
+
+ /* Set the return length*/
+ Length = sizeof(ULONG);
+ if (ProcessInformationLength != Length)
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
+ /* Reference the process */
+ Status = ObReferenceObjectByHandle(ProcessHandle,
+ PROCESS_QUERY_INFORMATION,
+ PsProcessType,
+ PreviousMode,
+ (PVOID*)&Process,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ break;
+
+ /* Enter SEH for writing back data */
+ _SEH2_TRY
+ {
+ /* Return the BreakOnTermination state */
+ *(PULONG)ProcessInformation = Process->BreakOnTermination;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ /* Dereference the process */
+ ObDereferenceObject(Process);
+ break;
+
/* Per-process security cookie */
case ProcessCookie:
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Get the LPC Port */
Status = ObReferenceObjectByHandle(PortHandle,
0,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Assign the actual token */
Status = PspSetPrimaryToken(Process, TokenHandle, NULL);
break;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Setting the session id requires the SeTcbPrivilege */
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
{
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Check for invalid PriorityClass value */
if (PriorityClass.PriorityClass > PROCESS_PRIORITY_CLASS_ABOVE_NORMAL)
{
Status = STATUS_NOT_IMPLEMENTED;
break;
+ case ProcessBreakOnTermination:
+
+ /* Check buffer length */
+ if (ProcessInformationLength != sizeof(ULONG))
+ {
+ Status = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
+ /* Setting 'break on termination' requires the SeDebugPrivilege */
+ if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
+ {
+ Status = STATUS_PRIVILEGE_NOT_HELD;
+ break;
+ }
+
+ /* Enter SEH for direct buffer read */
+ _SEH2_TRY
+ {
+ Process->BreakOnTermination = *(PULONG)ProcessInformation;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Get exception code */
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ break;
+
/* We currently don't implement any of these */
case ProcessLdtInformation:
case ProcessLdtSize:
Access = THREAD_SET_THREAD_TOKEN;
}
- /* Reference the process */
+ /* Reference the thread */
Status = ObReferenceObjectByHandle(ThreadHandle,
Access,
PsThreadType,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Validate it */
if ((Priority > HIGH_PRIORITY) ||
(Priority <= LOW_PRIORITY))
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Validate it */
if ((Priority > THREAD_BASE_PRIORITY_MAX) ||
(Priority < THREAD_BASE_PRIORITY_MIN))
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Assign the actual token */
Status = PsAssignImpersonationToken(Thread, TokenHandle);
break;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Set the address */
Thread->Win32StartAddress = Address;
break;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Validate it */
if (IdealProcessor > MAXIMUM_PROCESSORS)
{
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* Call the kernel */
KeSetDisableBoostThread(&Thread->Tcb, (BOOLEAN)DisableBoost);
break;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- /* Return the exception code */
- _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
+ if (!NT_SUCCESS(Status)) break;
+
/* This is only valid for the current thread */
if (Thread != PsGetCurrentThread())
{
KeLowerIrql(OldIrql);
break;
+ /* LDT and GDT information */
case ThreadDescriptorTableEntry:
- DPRINT1("NtQueryInformationThread(): case ThreadDescriptorTableEntry not implemented!\n");
+
+#if defined(_X86_)
+ /* Call the worker routine */
+ Status = PspQueryDescriptorThread(Thread,
+ ThreadInformation,
+ ThreadInformationLength,
+ ReturnLength);
+#else
+ /* Only implemented on x86 */
Status = STATUS_NOT_IMPLEMENTED;
+#endif
break;
case ThreadPriorityBoost: