2008-03-09 14:11:42 +00:00
|
|
|
/*
|
2004-07-17 03:07:00 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2005-01-26 13:58:37 +00:00
|
|
|
* FILE: ntoskrnl/ps/job.c
|
2004-07-17 03:07:00 +00:00
|
|
|
* PURPOSE: Job Native Functions
|
2005-02-17 16:41:28 +00:00
|
|
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net) (stubs)
|
|
|
|
* Thomas Weidenmueller <w3seek@reactos.com>
|
2004-07-17 03:07:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2006-07-09 18:54:13 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2004-07-17 03:07:00 +00:00
|
|
|
|
2005-11-28 23:25:31 +00:00
|
|
|
|
2004-09-22 22:31:46 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2005-11-22 02:30:18 +00:00
|
|
|
POBJECT_TYPE PsJobType = NULL;
|
2004-09-22 22:31:46 +00:00
|
|
|
|
|
|
|
LIST_ENTRY PsJobListHead;
|
2005-01-21 14:12:03 +00:00
|
|
|
static FAST_MUTEX PsJobListLock;
|
2004-09-22 22:31:46 +00:00
|
|
|
|
2006-07-21 19:28:38 +00:00
|
|
|
BOOLEAN PspUseJobSchedulingClasses;
|
|
|
|
|
|
|
|
CHAR PspJobSchedulingClasses[PSP_JOB_SCHEDULING_CLASSES] =
|
|
|
|
{
|
|
|
|
1 * 6,
|
|
|
|
2 * 6,
|
|
|
|
3 * 6,
|
|
|
|
4 * 6,
|
|
|
|
5 * 6,
|
|
|
|
6 * 6,
|
|
|
|
7 * 6,
|
|
|
|
8 * 6,
|
|
|
|
9 * 6,
|
|
|
|
10 * 6
|
|
|
|
};
|
|
|
|
|
2006-09-16 20:37:49 +00:00
|
|
|
GENERIC_MAPPING PspJobMapping =
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
|
|
|
STANDARD_RIGHTS_READ | JOB_OBJECT_QUERY,
|
2012-09-02 22:06:42 +00:00
|
|
|
|
|
|
|
STANDARD_RIGHTS_WRITE | JOB_OBJECT_ASSIGN_PROCESS |
|
|
|
|
JOB_OBJECT_SET_ATTRIBUTES | JOB_OBJECT_TERMINATE,
|
|
|
|
|
2005-04-08 13:14:15 +00:00
|
|
|
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
|
2012-09-02 22:06:42 +00:00
|
|
|
|
|
|
|
STANDARD_RIGHTS_ALL | THREAD_ALL_ACCESS // bug fixed only in vista
|
2005-04-08 13:14:15 +00:00
|
|
|
};
|
2004-09-22 22:31:46 +00:00
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2006-07-09 18:54:13 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2006-09-16 20:37:49 +00:00
|
|
|
PspDeleteJob ( PVOID ObjectBody )
|
2004-09-22 22:31:46 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
PEJOB Job = (PEJOB)ObjectBody;
|
|
|
|
|
|
|
|
/* remove the reference to the completion port if associated */
|
|
|
|
if(Job->CompletionPort != NULL)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(Job->CompletionPort);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unlink the job object */
|
|
|
|
if(Job->JobLinks.Flink != NULL)
|
|
|
|
{
|
|
|
|
ExAcquireFastMutex(&PsJobListLock);
|
|
|
|
RemoveEntryList(&Job->JobLinks);
|
|
|
|
ExReleaseFastMutex(&PsJobListLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExDeleteResource(&Job->JobLock);
|
2004-09-22 22:31:46 +00:00
|
|
|
}
|
|
|
|
|
2006-09-16 20:37:49 +00:00
|
|
|
VOID
|
2005-09-13 23:28:21 +00:00
|
|
|
NTAPI
|
2010-11-02 16:29:06 +00:00
|
|
|
INIT_FUNCTION
|
2006-09-16 20:37:49 +00:00
|
|
|
PspInitializeJobStructures(VOID)
|
2004-09-22 22:31:46 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
InitializeListHead(&PsJobListHead);
|
|
|
|
ExInitializeFastMutex(&PsJobListLock);
|
2004-09-22 22:31:46 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 14:12:03 +00:00
|
|
|
NTSTATUS
|
2005-09-13 23:28:21 +00:00
|
|
|
NTAPI
|
2006-07-09 18:54:13 +00:00
|
|
|
PspAssignProcessToJob(PEPROCESS Process,
|
2005-04-08 13:14:15 +00:00
|
|
|
PEJOB Job)
|
2005-01-21 14:12:03 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
DPRINT("PspAssignProcessToJob() is unimplemented!\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2005-01-21 14:12:03 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 14:52:53 +00:00
|
|
|
NTSTATUS
|
2005-09-13 23:28:21 +00:00
|
|
|
NTAPI
|
2006-07-09 18:54:13 +00:00
|
|
|
PspTerminateJobObject(PEJOB Job,
|
2005-04-08 13:14:15 +00:00
|
|
|
KPROCESSOR_MODE AccessMode,
|
|
|
|
NTSTATUS ExitStatus )
|
2005-01-21 14:52:53 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
DPRINT("PspTerminateJobObject() is unimplemented!\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2005-01-21 14:52:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 18:54:13 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
PspRemoveProcessFromJob(IN PEPROCESS Process,
|
|
|
|
IN PEJOB Job)
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
PspExitProcessFromJob(IN PEJOB Job,
|
|
|
|
IN PEPROCESS Process)
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
}
|
2005-01-21 14:12:03 +00:00
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtAssignProcessToJobObject (
|
|
|
|
HANDLE JobHandle,
|
|
|
|
HANDLE ProcessHandle)
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
PEPROCESS Process;
|
|
|
|
KPROCESSOR_MODE PreviousMode;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
PreviousMode = ExGetPreviousMode();
|
|
|
|
|
|
|
|
/* make sure we're having a handle with enough rights, especially the to
|
|
|
|
terminate the process. otherwise one could abuse the job objects to
|
|
|
|
terminate processes without having rights granted to do so! The reason
|
|
|
|
I open the process handle before the job handle is that a simple test showed
|
|
|
|
that it first complains about a invalid process handle! The other way around
|
|
|
|
would be simpler though... */
|
|
|
|
Status = ObReferenceObjectByHandle(
|
|
|
|
ProcessHandle,
|
|
|
|
PROCESS_TERMINATE,
|
|
|
|
PsProcessType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&Process,
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
2005-01-21 14:12:03 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
if(Process->Job == NULL)
|
|
|
|
{
|
|
|
|
PEJOB Job;
|
|
|
|
|
|
|
|
Status = ObReferenceObjectByHandle(
|
|
|
|
JobHandle,
|
|
|
|
JOB_OBJECT_ASSIGN_PROCESS,
|
|
|
|
PsJobType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&Job,
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* lock the process so we can safely assign the process. Note that in the
|
|
|
|
meanwhile another thread could have assigned this process to a job! */
|
|
|
|
|
2006-07-20 17:44:30 +00:00
|
|
|
ExAcquireRundownProtection(&Process->RundownProtect);
|
2005-04-08 13:14:15 +00:00
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
2013-09-21 22:59:24 +00:00
|
|
|
if(Process->Job == NULL && PsGetProcessSessionId(Process) == Job->SessionId)
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
|
|
|
/* Just store the pointer to the job object in the process, we'll
|
|
|
|
assign it later. The reason we can't do this here is that locking
|
|
|
|
the job object might require it to wait, which is a bad thing
|
|
|
|
while holding the process lock! */
|
|
|
|
Process->Job = Job;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* process is already assigned to a job or session id differs! */
|
|
|
|
Status = STATUS_ACCESS_DENIED;
|
|
|
|
}
|
2006-07-20 17:44:30 +00:00
|
|
|
ExReleaseRundownProtection(&Process->RundownProtect);
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* let's actually assign the process to the job as we're not holding
|
|
|
|
the process lock anymore! */
|
|
|
|
Status = PspAssignProcessToJob(Process, Job);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ObDereferenceObject(Job);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2005-01-21 14:12:03 +00:00
|
|
|
{
|
|
|
|
/* process is already assigned to a job or session id differs! */
|
|
|
|
Status = STATUS_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
2005-04-08 13:14:15 +00:00
|
|
|
ObDereferenceObject(Process);
|
2005-01-21 14:12:03 +00:00
|
|
|
}
|
|
|
|
|
2005-04-08 13:14:15 +00:00
|
|
|
return Status;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2006-10-23 18:35:13 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NtCreateJobSet(IN ULONG NumJob,
|
|
|
|
IN PJOB_SET_ARRAY UserJobSet,
|
|
|
|
IN ULONG Flags)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtCreateJobObject (
|
|
|
|
PHANDLE JobHandle,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes )
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
HANDLE hJob;
|
|
|
|
PEJOB Job;
|
2007-04-02 15:08:54 +00:00
|
|
|
KPROCESSOR_MODE PreviousMode;
|
|
|
|
PEPROCESS CurrentProcess;
|
2009-08-26 17:31:02 +00:00
|
|
|
NTSTATUS Status;
|
2005-01-21 14:12:03 +00:00
|
|
|
|
2005-04-08 13:14:15 +00:00
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
PreviousMode = ExGetPreviousMode();
|
|
|
|
CurrentProcess = PsGetCurrentProcess();
|
|
|
|
|
|
|
|
/* check for valid buffers */
|
2009-08-26 17:31:02 +00:00
|
|
|
if (PreviousMode != KernelMode)
|
2005-01-21 14:12:03 +00:00
|
|
|
{
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2005-08-21 15:38:47 +00:00
|
|
|
ProbeForWriteHandle(JobHandle);
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-01-21 14:12:03 +00:00
|
|
|
}
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
Status = ObCreateObject(PreviousMode,
|
|
|
|
PsJobType,
|
|
|
|
ObjectAttributes,
|
|
|
|
PreviousMode,
|
|
|
|
NULL,
|
|
|
|
sizeof(EJOB),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(PVOID*)&Job);
|
|
|
|
|
2005-01-21 22:25:54 +00:00
|
|
|
if(NT_SUCCESS(Status))
|
2005-01-21 14:12:03 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
/* FIXME - Zero all fields as we don't yet implement all of them */
|
|
|
|
RtlZeroMemory(Job, sizeof(EJOB));
|
|
|
|
|
|
|
|
/* make sure that early destruction doesn't attempt to remove the object from
|
|
|
|
the list before it even gets added! */
|
|
|
|
Job->JobLinks.Flink = NULL;
|
|
|
|
|
2013-09-21 22:59:24 +00:00
|
|
|
/* setup the job object - FIXME: More to do! */
|
|
|
|
InitializeListHead(&Job->JobSetLinks);
|
2005-04-08 13:14:15 +00:00
|
|
|
InitializeListHead(&Job->ProcessListHead);
|
2013-09-21 22:59:24 +00:00
|
|
|
|
|
|
|
/* inherit the session id from the caller */
|
|
|
|
Job->SessionId = PsGetProcessSessionId(CurrentProcess);
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
Status = ExInitializeResource(&Job->JobLock);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Failed to initialize job lock!!!\n");
|
|
|
|
ObDereferenceObject(Job);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
KeInitializeEvent(&Job->Event, NotificationEvent, FALSE);
|
|
|
|
|
|
|
|
/* link the object into the global job list */
|
|
|
|
ExAcquireFastMutex(&PsJobListLock);
|
|
|
|
InsertTailList(&PsJobListHead, &Job->JobLinks);
|
|
|
|
ExReleaseFastMutex(&PsJobListLock);
|
|
|
|
|
|
|
|
Status = ObInsertObject(Job,
|
|
|
|
NULL,
|
|
|
|
DesiredAccess,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&hJob);
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* pass the handle back to the caller */
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
|
|
|
/* NOTE: if the caller passed invalid buffers to receive the handle it's his
|
|
|
|
own fault! the object will still be created and live... It's possible
|
|
|
|
to find the handle using ObFindHandleForObject()! */
|
|
|
|
*JobHandle = hJob;
|
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2008-11-24 13:40:26 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2005-01-21 14:12:03 +00:00
|
|
|
}
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
return Status;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
2004-09-23 21:23:34 +00:00
|
|
|
* @implemented
|
2004-07-17 03:07:00 +00:00
|
|
|
*/
|
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtIsProcessInJob (
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN HANDLE JobHandle OPTIONAL )
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
KPROCESSOR_MODE PreviousMode;
|
|
|
|
PEPROCESS Process;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
PreviousMode = ExGetPreviousMode();
|
|
|
|
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
Status = ObReferenceObjectByHandle(
|
|
|
|
ProcessHandle,
|
|
|
|
PROCESS_QUERY_INFORMATION,
|
|
|
|
PsProcessType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&Process,
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
2004-09-23 21:23:34 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
/* FIXME - make sure the job object doesn't get exchanged or deleted while trying to
|
|
|
|
reference it, e.g. by locking it somehow until it is referenced... */
|
|
|
|
|
|
|
|
PEJOB ProcessJob = Process->Job;
|
|
|
|
|
|
|
|
if(ProcessJob != NULL)
|
2004-09-23 22:02:39 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
if(JobHandle == NULL)
|
|
|
|
{
|
|
|
|
/* the process is assigned to a job */
|
|
|
|
Status = STATUS_PROCESS_IN_JOB;
|
|
|
|
}
|
|
|
|
else /* JobHandle != NULL */
|
|
|
|
{
|
|
|
|
PEJOB JobObject;
|
|
|
|
|
|
|
|
/* get the job object and compare the object pointer with the one assigned to the process */
|
|
|
|
Status = ObReferenceObjectByHandle(JobHandle,
|
|
|
|
JOB_OBJECT_QUERY,
|
|
|
|
PsJobType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&JobObject,
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
Status = ((ProcessJob == JobObject) ? STATUS_PROCESS_IN_JOB : STATUS_PROCESS_NOT_IN_JOB);
|
|
|
|
ObDereferenceObject(JobObject);
|
|
|
|
}
|
|
|
|
}
|
2004-09-23 22:02:39 +00:00
|
|
|
}
|
2005-04-08 13:14:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* the process is not assigned to any job */
|
|
|
|
Status = STATUS_PROCESS_NOT_IN_JOB;
|
|
|
|
}
|
|
|
|
ObDereferenceObject(Process);
|
2004-09-23 21:23:34 +00:00
|
|
|
}
|
|
|
|
|
2005-04-08 13:14:15 +00:00
|
|
|
return Status;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
2005-01-21 14:40:06 +00:00
|
|
|
* @implemented
|
2004-07-17 03:07:00 +00:00
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtOpenJobObject (
|
|
|
|
PHANDLE JobHandle,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2007-04-02 15:08:54 +00:00
|
|
|
KPROCESSOR_MODE PreviousMode;
|
2005-04-08 13:14:15 +00:00
|
|
|
HANDLE hJob;
|
2009-08-26 17:31:02 +00:00
|
|
|
NTSTATUS Status;
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
PreviousMode = ExGetPreviousMode();
|
|
|
|
|
|
|
|
/* check for valid buffers */
|
2009-08-26 17:31:02 +00:00
|
|
|
if (PreviousMode != KernelMode)
|
2005-01-22 14:34:54 +00:00
|
|
|
{
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2005-08-21 15:38:47 +00:00
|
|
|
ProbeForWriteHandle(JobHandle);
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-01-22 14:34:54 +00:00
|
|
|
}
|
2005-04-08 13:14:15 +00:00
|
|
|
|
2009-08-26 17:31:02 +00:00
|
|
|
Status = ObOpenObjectByName(ObjectAttributes,
|
|
|
|
PsJobType,
|
|
|
|
PreviousMode,
|
|
|
|
NULL,
|
|
|
|
DesiredAccess,
|
|
|
|
NULL,
|
|
|
|
&hJob);
|
2005-01-21 14:40:06 +00:00
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_TRY
|
2005-04-08 13:14:15 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
*JobHandle = hJob;
|
2005-04-08 13:14:15 +00:00
|
|
|
}
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
2005-01-21 14:40:06 +00:00
|
|
|
}
|
2005-04-08 13:14:15 +00:00
|
|
|
|
|
|
|
return Status;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtQueryInformationJobObject (
|
|
|
|
HANDLE JobHandle,
|
|
|
|
JOBOBJECTINFOCLASS JobInformationClass,
|
|
|
|
PVOID JobInformation,
|
|
|
|
ULONG JobInformationLength,
|
|
|
|
PULONG ReturnLength )
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtSetInformationJobObject (
|
|
|
|
HANDLE JobHandle,
|
|
|
|
JOBOBJECTINFOCLASS JobInformationClass,
|
|
|
|
PVOID JobInformation,
|
|
|
|
ULONG JobInformationLength)
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
|
|
|
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2005-04-08 13:14:15 +00:00
|
|
|
NTSTATUS
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
NtTerminateJobObject (
|
|
|
|
HANDLE JobHandle,
|
|
|
|
NTSTATUS ExitStatus )
|
2004-07-17 03:07:00 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
KPROCESSOR_MODE PreviousMode;
|
|
|
|
PEJOB Job;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
PreviousMode = ExGetPreviousMode();
|
|
|
|
|
|
|
|
Status = ObReferenceObjectByHandle(
|
|
|
|
JobHandle,
|
|
|
|
JOB_OBJECT_TERMINATE,
|
|
|
|
PsJobType,
|
|
|
|
PreviousMode,
|
|
|
|
(PVOID*)&Job,
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
Status = PspTerminateJobObject(
|
|
|
|
Job,
|
|
|
|
PreviousMode,
|
|
|
|
ExitStatus);
|
|
|
|
ObDereferenceObject(Job);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
2004-07-17 03:07:00 +00:00
|
|
|
}
|
|
|
|
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-19 06:08:21 +00:00
|
|
|
/*
|
2004-09-22 14:53:26 +00:00
|
|
|
* @implemented
|
2004-07-19 06:08:21 +00:00
|
|
|
*/
|
|
|
|
PVOID
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
PsGetJobLock ( PEJOB Job )
|
2004-07-19 06:08:21 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
ASSERT(Job);
|
|
|
|
return (PVOID)&Job->JobLock;
|
2004-07-19 06:08:21 +00:00
|
|
|
}
|
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
|
2004-07-19 06:08:21 +00:00
|
|
|
/*
|
2004-09-22 14:53:26 +00:00
|
|
|
* @implemented
|
2004-07-19 06:08:21 +00:00
|
|
|
*/
|
2013-09-21 20:46:42 +00:00
|
|
|
ULONG
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
PsGetJobSessionId ( PEJOB Job )
|
2004-07-19 06:08:21 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
ASSERT(Job);
|
2013-09-21 20:46:42 +00:00
|
|
|
return Job->SessionId;
|
2004-07-19 06:08:21 +00:00
|
|
|
}
|
|
|
|
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-19 06:08:21 +00:00
|
|
|
/*
|
2004-09-22 14:53:26 +00:00
|
|
|
* @implemented
|
2004-07-19 06:08:21 +00:00
|
|
|
*/
|
|
|
|
ULONG
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2005-04-08 13:14:15 +00:00
|
|
|
PsGetJobUIRestrictionsClass ( PEJOB Job )
|
2004-07-19 06:08:21 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
ASSERT(Job);
|
|
|
|
return Job->UIRestrictionsClass;
|
2004-07-19 06:08:21 +00:00
|
|
|
}
|
|
|
|
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-19 06:08:21 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
2004-10-22 20:57:39 +00:00
|
|
|
*/
|
2004-07-19 06:08:21 +00:00
|
|
|
VOID
|
2008-08-18 09:50:38 +00:00
|
|
|
NTAPI
|
2006-07-09 18:54:13 +00:00
|
|
|
PsSetJobUIRestrictionsClass(PEJOB Job,
|
2005-04-08 13:14:15 +00:00
|
|
|
ULONG UIRestrictionsClass)
|
2004-07-19 06:08:21 +00:00
|
|
|
{
|
2005-04-08 13:14:15 +00:00
|
|
|
ASSERT(Job);
|
2006-03-04 17:27:40 +00:00
|
|
|
(void)InterlockedExchangeUL(&Job->UIRestrictionsClass, UIRestrictionsClass);
|
2005-04-08 13:14:15 +00:00
|
|
|
/* FIXME - walk through the job process list and update the restrictions? */
|
2004-07-19 06:08:21 +00:00
|
|
|
}
|
2004-09-22 14:53:26 +00:00
|
|
|
|
2004-07-17 03:07:00 +00:00
|
|
|
/* EOF */
|