diff --git a/reactos/include/ddk/psfuncs.h b/reactos/include/ddk/psfuncs.h index 0922cb5086d..b57e0afcc63 100644 --- a/reactos/include/ddk/psfuncs.h +++ b/reactos/include/ddk/psfuncs.h @@ -1,4 +1,4 @@ -/* $Id: psfuncs.h,v 1.32 2004/08/12 06:04:21 ion Exp $ +/* $Id: psfuncs.h,v 1.33 2004/09/22 14:53:26 weiden Exp $ */ #ifndef _INCLUDE_DDK_PSFUNCS_H #define _INCLUDE_DDK_PSFUNCS_H @@ -118,17 +118,17 @@ STDCALL PsGetCurrentThreadStackLimit ( PVOID STDCALL PsGetJobLock( - PVOID */*PEJOB*/ Job + PEJOB Job ); PVOID STDCALL PsGetJobSessionId( - PVOID /*PEJOB*/ Job + PEJOB Job ); ULONG STDCALL PsGetJobUIRestrictionsClass( - PVOID /*PEJOB*/ Job + PEJOB Job ); LONGLONG @@ -167,7 +167,7 @@ STDCALL PsGetProcessInheritedFromUniqueProcessId( PEPROCESS Process ); -PVOID /*PEJOB*/ +PEJOB STDCALL PsGetProcessJob( PEPROCESS Process ); @@ -311,7 +311,7 @@ PsRevertThreadToSelf( VOID STDCALL PsSetJobUIRestrictionsClass( - PVOID /*PEJOB*/ Job, + PEJOB Job, ULONG UIRestrictionsClass ); diff --git a/reactos/include/ddk/pstypes.h b/reactos/include/ddk/pstypes.h index aa949040123..d12b9fb13f5 100644 --- a/reactos/include/ddk/pstypes.h +++ b/reactos/include/ddk/pstypes.h @@ -20,7 +20,9 @@ struct _EPROCESS; struct _KPROCESS; struct _ETHREAD; struct _KTHREAD; +struct _EJOB; +typedef struct _EJOB *PEJOB; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _IMAGE_INFO { diff --git a/reactos/ntoskrnl/include/internal/ps.h b/reactos/ntoskrnl/include/internal/ps.h index 94c3b26f536..c71543a2214 100644 --- a/reactos/ntoskrnl/include/internal/ps.h +++ b/reactos/ntoskrnl/include/internal/ps.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: ps.h,v 1.66 2004/08/31 20:17:17 hbirr Exp $ +/* $Id: ps.h,v 1.67 2004/09/22 14:53:26 weiden Exp $ * * FILE: ntoskrnl/ke/kthread.c * PURPOSE: Process manager definitions @@ -33,6 +33,7 @@ /* Forward declarations. */ struct _KTHREAD; struct _KTRAPFRAME; +struct _EJOB; #endif /* __ASM__ */ @@ -433,6 +434,9 @@ struct _EPROCESS /* Added by Alex Ionescu (alex@relsoft.net)*/ ULONG SessionId; struct _EPORT* SecurityPort; + + struct _EJOB* Job; + UINT JobStatus; }; #define PROCESS_STATE_TERMINATED (1) @@ -574,6 +578,69 @@ VOID STDCALL PspRunCreateProcessNotifyRoutines(PEPROCESS, BOOLEAN); +#include +typedef struct _PS_JOB_TOKEN_FILTER +{ + UINT CapturedSidCount; + PSID_AND_ATTRIBUTES CapturedSids; + UINT CapturedSidsLength; + UINT CapturedGroupCount; + PSID_AND_ATTRIBUTES CapturedGroups; + UINT CapturedGroupsLength; + UINT CapturedPrivilegeCount; + PLUID_AND_ATTRIBUTES CapturedPrivileges; + UINT CapturedPrivilegesLength; +} PS_JOB_TOKEN_FILTER, *PPS_JOB_TOKEN_FILTER; +#include + +#include +typedef struct _EJOB +{ + KEVENT Event; + LIST_ENTRY JobLinks; + LIST_ENTRY ProcessListHead; + ERESOURCE JobLock; + LARGE_INTEGER TotalUserTime; + LARGE_INTEGER TotalKernelTime; + LARGE_INTEGER ThisPeriodTotalUserTime; + LARGE_INTEGER ThisPeriodTotalKernelTime; + UINT TotalPageFaultCount; + UINT TotalProcesses; + UINT ActiveProcesses; + UINT TotalTerminatedProcesses; + LARGE_INTEGER PerProcessUserTimeLimit; + LARGE_INTEGER PerJobUserTimeLimit; + UINT LimitFlags; + UINT MinimumWorkingSetSize; + UINT MaximumWorkingSetSize; + UINT ActiveProcessLimit; + UINT Affinity; + BYTE PriorityClass; + UINT UIRestrictionsClass; + UINT SecurityLimitFlags; + PVOID Token; + PPS_JOB_TOKEN_FILTER Filter; + UINT EndOfJobTimeAction; + PVOID CompletionPort; + PVOID CompletionKey; + UINT SessionId; + UINT SchedulingClass; + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; + IO_COUNTERS IoInfo; + UINT ProcessMemoryLimit; + UINT JobMemoryLimit; + UINT PeakProcessMemoryUsed; + UINT PeakJobMemoryUsed; + UINT CurrentJobMemoryUsed; + FAST_MUTEX MemoryLimitsLock; +} EJOB; +#include + #endif /* ASSEMBLER */ #endif /* __INCLUDE_INTERNAL_PS_H */ diff --git a/reactos/ntoskrnl/ps/job.c b/reactos/ntoskrnl/ps/job.c index 322dd2c7a1c..fcecb6baecb 100644 --- a/reactos/ntoskrnl/ps/job.c +++ b/reactos/ntoskrnl/ps/job.c @@ -21,152 +21,146 @@ */ NTSTATUS STDCALL -NtAssignProcessToJobObject( - HANDLE JobHandle, - HANDLE ProcessHandle - ) +NtAssignProcessToJobObject(HANDLE JobHandle, + HANDLE ProcessHandle) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } + + /* * @unimplemented */ NTSTATUS STDCALL -NtCreateJobObject( - PHANDLE JobHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes - ) +NtCreateJobObject(PHANDLE JobHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } + + /* * @unimplemented */ NTSTATUS STDCALL -NtIsProcessInJob( - IN HANDLE ProcessHandle, // ProcessHandle must PROCESS_QUERY_INFORMATION grant access. - IN HANDLE JobHandle OPTIONAL // JobHandle must grant JOB_OBJECT_QUERY access. Defaults to the current process's job object. - ) +NtIsProcessInJob(IN HANDLE ProcessHandle, // ProcessHandle must PROCESS_QUERY_INFORMATION grant access. + IN HANDLE JobHandle OPTIONAL) // JobHandle must grant JOB_OBJECT_QUERY access. Defaults to the current process's job object. { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} -/* - * @unimplemented - */ -NTSTATUS -STDCALL -NtOpenJobObject( - PHANDLE JobHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes - ) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} -/* - * @unimplemented - */ -NTSTATUS -STDCALL -NtQueryInformationJobObject( - HANDLE JobHandle, - JOBOBJECTINFOCLASS JobInformationClass, - PVOID JobInformation, - ULONG JobInformationLength, - PULONG ReturnLength - ) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} -/* - * @unimplemented - */ -NTSTATUS -STDCALL -NtSetInformationJobObject( - HANDLE JobHandle, - JOBOBJECTINFOCLASS JobInformationClass, - PVOID JobInformation, - ULONG JobInformationLength - ) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } + /* * @unimplemented */ NTSTATUS STDCALL -NtTerminateJobObject( - HANDLE JobHandle, - NTSTATUS ExitStatus - ) +NtOpenJobObject(PHANDLE JobHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } + /* * @unimplemented */ +NTSTATUS +STDCALL +NtQueryInformationJobObject(HANDLE JobHandle, + JOBOBJECTINFOCLASS JobInformationClass, + PVOID JobInformation, + ULONG JobInformationLength, + PULONG ReturnLength) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + + +/* + * @unimplemented + */ +NTSTATUS +STDCALL +NtSetInformationJobObject(HANDLE JobHandle, + JOBOBJECTINFOCLASS JobInformationClass, + PVOID JobInformation, + ULONG JobInformationLength) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + + +/* + * @unimplemented + */ +NTSTATUS +STDCALL +NtTerminateJobObject(HANDLE JobHandle, + NTSTATUS ExitStatus) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + + +/* + * @implemented + */ PVOID STDCALL -PsGetJobLock( - PVOID */*PEJOB*/ Job - ) +PsGetJobLock(PEJOB Job) { - UNIMPLEMENTED; - return 0; + assert(Job); + return (PVOID)&Job->JobLock; } - /* - * @unimplemented + * @implemented */ PVOID STDCALL -PsGetJobSessionId( - PVOID /*PEJOB*/ Job - ) +PsGetJobSessionId(PEJOB Job) { - UNIMPLEMENTED; - return 0; + assert(Job); + return (PVOID)Job->SessionId; } + /* - * @unimplemented + * @implemented */ ULONG STDCALL -PsGetJobUIRestrictionsClass( - PVOID /*PEJOB*/ Job - ) +PsGetJobUIRestrictionsClass(PEJOB Job) { - UNIMPLEMENTED; - return 0; + assert(Job); + return Job->UIRestrictionsClass; } + /* * @unimplemented */ VOID STDCALL -PsSetJobUIRestrictionsClass( - PVOID /*PEJOB*/ Job, - ULONG UIRestrictionsClass - ) +PsSetJobUIRestrictionsClass(PEJOB Job, + ULONG UIRestrictionsClass) { - UNIMPLEMENTED; + assert(Job); + InterlockedExchange((LONG*)&Job->UIRestrictionsClass, (LONG)UIRestrictionsClass); + /* FIXME - walk through the job process list and update the restrictions? */ } + /* EOF */ diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 9a49c44584e..330f60c2bf0 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.140 2004/08/31 20:17:18 hbirr Exp $ +/* $Id: process.c,v 1.141 2004/09/22 14:53:26 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1671,16 +1671,15 @@ PsGetProcessInheritedFromUniqueProcessId( } /* - * @unimplemented + * @implemented */ -PVOID /*PEJOB*/ +PEJOB STDCALL PsGetProcessJob( PEPROCESS Process ) { - UNIMPLEMENTED; - return 0; + return Process->Job; } /*