mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
implemented IsProcessInJob(), AssignProcessToJobObject(), QueryInformationJobObject(), SetInformationJobObject() and TerminateJobObject(), all untested though
svn path=/trunk/; revision=11005
This commit is contained in:
parent
04c8adbef9
commit
b85ef6c64a
3 changed files with 253 additions and 79 deletions
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.85 2004/09/21 19:17:26 weiden Exp $
|
# $Id: makefile,v 1.86 2004/09/23 18:02:19 weiden Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ PROCESS_OBJECTS = \
|
||||||
process/proc.o \
|
process/proc.o \
|
||||||
process/cmdline.o \
|
process/cmdline.o \
|
||||||
process/create.o \
|
process/create.o \
|
||||||
|
process/job.o \
|
||||||
process/session.o
|
process/session.o
|
||||||
|
|
||||||
STRING_OBJECTS = string/lstring.o
|
STRING_OBJECTS = string/lstring.o
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: stubs.c,v 1.89 2004/09/22 10:58:06 weiden Exp $
|
/* $Id: stubs.c,v 1.90 2004/09/23 18:02:19 weiden Exp $
|
||||||
*
|
*
|
||||||
* KERNEL32.DLL stubs (STUB functions)
|
* KERNEL32.DLL stubs (STUB functions)
|
||||||
* Remove from this file, if you implement them.
|
* Remove from this file, if you implement them.
|
||||||
|
@ -571,20 +571,6 @@ AllocateUserPhysicalPages(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
AssignProcessToJobObject(
|
|
||||||
HANDLE hJob,
|
|
||||||
HANDLE hProcess
|
|
||||||
)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -870,21 +856,6 @@ HeapSetInformation (
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
IsProcessInJob (
|
|
||||||
HANDLE ProcessHandle,
|
|
||||||
HANDLE JobHandle,
|
|
||||||
PBOOL Result
|
|
||||||
)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -961,23 +932,6 @@ QueryActCtxW(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
QueryInformationJobObject(
|
|
||||||
HANDLE hJob,
|
|
||||||
JOBOBJECTINFOCLASS JobObjectInformationClass,
|
|
||||||
LPVOID lpJobObjectInformation,
|
|
||||||
DWORD cbJobObjectInformationLength,
|
|
||||||
LPDWORD lpReturnLength
|
|
||||||
)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -1157,23 +1111,6 @@ RestoreLastError(
|
||||||
STUB;
|
STUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
SetInformationJobObject(
|
|
||||||
HANDLE hJob,
|
|
||||||
JOBOBJECTINFOCLASS JobObjectInformationClass,
|
|
||||||
LPVOID lpJobObjectInformation,
|
|
||||||
DWORD cbJobObjectInformationLength
|
|
||||||
)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -1201,20 +1138,6 @@ SetThreadExecutionState(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
TerminateJobObject(
|
|
||||||
HANDLE hJob,
|
|
||||||
UINT uExitCode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
|
250
reactos/lib/kernel32/process/job.c
Normal file
250
reactos/lib/kernel32/process/job.c
Normal file
|
@ -0,0 +1,250 @@
|
||||||
|
/* $Id: job.c,v 1.1 2004/09/23 18:02:19 weiden Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/process/job.c
|
||||||
|
* PURPOSE: Job functions
|
||||||
|
* PROGRAMMER: Thomas Weidenmueller
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 9/23/2004
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
|
#include <k32.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include "../include/debug.h"
|
||||||
|
|
||||||
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
IsProcessInJob(HANDLE ProcessHandle,
|
||||||
|
HANDLE JobHandle,
|
||||||
|
PBOOL Result)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtIsProcessInJob(ProcessHandle, JobHandle);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*Result = (Status == STATUS_PROCESS_IN_JOB);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
AssignProcessToJobObject(HANDLE hJob,
|
||||||
|
HANDLE hProcess)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtAssignProcessToJobObject(hJob, hProcess);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
QueryInformationJobObject(HANDLE hJob,
|
||||||
|
JOBOBJECTINFOCLASS JobObjectInformationClass,
|
||||||
|
LPVOID lpJobObjectInformation,
|
||||||
|
DWORD cbJobObjectInformationLength,
|
||||||
|
LPDWORD lpReturnLength)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtQueryInformationJobObject(hJob,
|
||||||
|
JobObjectInformationClass,
|
||||||
|
lpJobObjectInformation,
|
||||||
|
cbJobObjectInformationLength,
|
||||||
|
lpReturnLength);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
||||||
|
switch(JobObjectInformationClass)
|
||||||
|
{
|
||||||
|
case JobObjectBasicLimitInformation:
|
||||||
|
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation;
|
||||||
|
break;
|
||||||
|
case JobObjectExtendedLimitInformation:
|
||||||
|
BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BasicInfo = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(BasicInfo != NULL)
|
||||||
|
{
|
||||||
|
/* we need to convert the process priority classes in the
|
||||||
|
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
||||||
|
GetPriorityClass() converts it! */
|
||||||
|
switch(BasicInfo->PriorityClass)
|
||||||
|
{
|
||||||
|
case PROCESS_PRIORITY_CLASS_IDLE:
|
||||||
|
BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
case PROCESS_PRIORITY_CLASS_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
case PROCESS_PRIORITY_CLASS_HIGH:
|
||||||
|
BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
case PROCESS_PRIORITY_CLASS_REALTIME:
|
||||||
|
BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
SetInformationJobObject(HANDLE hJob,
|
||||||
|
JOBOBJECTINFOCLASS JobObjectInformationClass,
|
||||||
|
LPVOID lpJobObjectInformation,
|
||||||
|
DWORD cbJobObjectInformationLength)
|
||||||
|
{
|
||||||
|
JOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimitInfo;
|
||||||
|
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
||||||
|
PVOID ObjectInfo;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
switch(JobObjectInformationClass)
|
||||||
|
{
|
||||||
|
case JobObjectBasicLimitInformation:
|
||||||
|
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_BAD_LENGTH);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
||||||
|
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo;
|
||||||
|
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JobObjectExtendedLimitInformation:
|
||||||
|
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_BAD_LENGTH);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ObjectInfo = &ExtendedLimitInfo;
|
||||||
|
BasicInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
||||||
|
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ObjectInfo = lpJobObjectInformation;
|
||||||
|
BasicInfo = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(BasicInfo != NULL)
|
||||||
|
{
|
||||||
|
/* we need to convert the process priority classes in the
|
||||||
|
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
||||||
|
SetPriorityClass() converts it! */
|
||||||
|
switch(BasicInfo->PriorityClass)
|
||||||
|
{
|
||||||
|
case IDLE_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
||||||
|
break;
|
||||||
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
||||||
|
break;
|
||||||
|
case NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
|
break;
|
||||||
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
||||||
|
break;
|
||||||
|
case HIGH_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
||||||
|
break;
|
||||||
|
case REALTIME_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtSetInformationJobObject(hJob,
|
||||||
|
JobObjectInformationClass,
|
||||||
|
ObjectInfo,
|
||||||
|
cbJobObjectInformationLength);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
TerminateJobObject(HANDLE hJob,
|
||||||
|
UINT uExitCode)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtTerminateJobObject(hJob, uExitCode);
|
||||||
|
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
Loading…
Reference in a new issue