mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 18:00:41 +00:00
[NTOSKRNL / RTL]
- Implement BreakOnTermination case for NtQueryInformationProcess and NtSetInformationProcess. - Implement RtlSetProcessIsCritical. svn path=/trunk/; revision=47423
This commit is contained in:
parent
5e8f4e5fd6
commit
00fbba2fb4
4 changed files with 109 additions and 14 deletions
|
@ -2042,12 +2042,12 @@ RtlRemoteCall(
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
VOID
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlSetProcessIsCritical(
|
RtlSetProcessIsCritical(
|
||||||
IN BOOLEAN NewValue,
|
IN BOOLEAN NewValue,
|
||||||
OUT PBOOLEAN OldValue OPTIONAL,
|
OUT PBOOLEAN OldValue OPTIONAL,
|
||||||
IN BOOLEAN IsWinlogon
|
IN BOOLEAN NeedBreaks
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* PURPOSE: Process functions
|
* PURPOSE: Process functions
|
||||||
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
|
||||||
* Ariadne (ariadne@xs4all.nl)
|
* Ariadne (ariadne@xs4all.nl)
|
||||||
|
* Eric Kohl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
@ -351,18 +352,45 @@ RtlEncodeSystemPointer(IN PVOID Pointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
|
*
|
||||||
|
* NOTES:
|
||||||
|
* Implementation based on the documentation from:
|
||||||
|
* http://www.geoffchappell.com/studies/windows/win32/ntdll/api/rtl/peb/setprocessiscritical.htm
|
||||||
*/
|
*/
|
||||||
NTSYSAPI
|
NTSTATUS
|
||||||
VOID
|
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlSetProcessIsCritical(
|
RtlSetProcessIsCritical(IN BOOLEAN NewValue,
|
||||||
IN BOOLEAN NewValue,
|
|
||||||
OUT PBOOLEAN OldValue OPTIONAL,
|
OUT PBOOLEAN OldValue OPTIONAL,
|
||||||
IN BOOLEAN IsWinlogon)
|
IN BOOLEAN NeedBreaks)
|
||||||
{
|
{
|
||||||
//TODO
|
ULONG BreakOnTermination = FALSE;
|
||||||
UNIMPLEMENTED;
|
|
||||||
|
if (OldValue)
|
||||||
|
*OldValue = FALSE;
|
||||||
|
|
||||||
|
/* Fail, if the critical breaks flag is required but is not set */
|
||||||
|
if (NeedBreaks == TRUE &&
|
||||||
|
!(NtCurrentPeb()->NtGlobalFlag & FLG_ENABLE_SYSTEM_CRIT_BREAKS))
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
if (OldValue)
|
||||||
|
{
|
||||||
|
/* Query and return the old break on termination flag for the process */
|
||||||
|
ZwQueryInformationProcess(NtCurrentProcess(),
|
||||||
|
ProcessBreakOnTermination,
|
||||||
|
&BreakOnTermination,
|
||||||
|
sizeof(ULONG),
|
||||||
|
NULL);
|
||||||
|
*OldValue = (BOOLEAN)BreakOnTermination;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the break on termination flag for the process */
|
||||||
|
BreakOnTermination = NewValue;
|
||||||
|
return ZwSetInformationProcess(NtCurrentProcess(),
|
||||||
|
ProcessBreakOnTermination,
|
||||||
|
&BreakOnTermination,
|
||||||
|
sizeof(ULONG));
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
|
|
|
@ -249,9 +249,9 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
|
||||||
/* ProcessBreakOnTermination */
|
/* ProcessBreakOnTermination */
|
||||||
IQS_SAME
|
IQS_SAME
|
||||||
(
|
(
|
||||||
UCHAR,
|
ULONG,
|
||||||
UCHAR,
|
ULONG,
|
||||||
0
|
ICIF_QUERY | ICIF_SET
|
||||||
),
|
),
|
||||||
|
|
||||||
/* ProcessDebugObjectHandle */
|
/* ProcessDebugObjectHandle */
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* PURPOSE: Process Manager: Thread/Process Query/Set Information
|
* PURPOSE: Process Manager: Thread/Process Query/Set Information
|
||||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
* Thomas Weidenmueller (w3seek@reactos.org)
|
* Thomas Weidenmueller (w3seek@reactos.org)
|
||||||
|
* Eric Kohl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
@ -735,6 +736,43 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
break;
|
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 */
|
/* Per-process security cookie */
|
||||||
case ProcessCookie:
|
case ProcessCookie:
|
||||||
|
|
||||||
|
@ -1146,6 +1184,35 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
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 */
|
/* We currently don't implement any of these */
|
||||||
case ProcessLdtInformation:
|
case ProcessLdtInformation:
|
||||||
case ProcessLdtSize:
|
case ProcessLdtSize:
|
||||||
|
|
Loading…
Reference in a new issue