use tags for pool allocations, and reformat code

svn path=/trunk/; revision=14547
This commit is contained in:
Royce Mitchell III 2005-04-08 13:14:15 +00:00
parent 18cff7ccc9
commit 601ea5384b

View file

@ -17,20 +17,25 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define TAG_EJOB TAG('E', 'J', 'O', 'B') /* EJOB */
POBJECT_TYPE EXPORTED PsJobType = NULL; POBJECT_TYPE EXPORTED PsJobType = NULL;
LIST_ENTRY PsJobListHead; LIST_ENTRY PsJobListHead;
static FAST_MUTEX PsJobListLock; static FAST_MUTEX PsJobListLock;
static GENERIC_MAPPING PiJobMapping = {STANDARD_RIGHTS_READ | JOB_OBJECT_QUERY, static GENERIC_MAPPING PiJobMapping =
{
STANDARD_RIGHTS_READ | JOB_OBJECT_QUERY,
STANDARD_RIGHTS_WRITE | JOB_OBJECT_ASSIGN_PROCESS | JOB_OBJECT_SET_ATTRIBUTES | JOB_OBJECT_TERMINATE | JOB_OBJECT_SET_SECURITY_ATTRIBUTES, STANDARD_RIGHTS_WRITE | JOB_OBJECT_ASSIGN_PROCESS | JOB_OBJECT_SET_ATTRIBUTES | JOB_OBJECT_TERMINATE | JOB_OBJECT_SET_SECURITY_ATTRIBUTES,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
STANDARD_RIGHTS_ALL | JOB_OBJECT_ALL_ACCESS}; STANDARD_RIGHTS_ALL | JOB_OBJECT_ALL_ACCESS
};
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID STDCALL VOID STDCALL
PiDeleteJob(PVOID ObjectBody) PiDeleteJob ( PVOID ObjectBody )
{ {
PEJOB Job = (PEJOB)ObjectBody; PEJOB Job = (PEJOB)ObjectBody;
@ -52,11 +57,12 @@ PiDeleteJob(PVOID ObjectBody)
} }
VOID INIT_FUNCTION VOID INIT_FUNCTION
PsInitJobManagment(VOID) PsInitJobManagment ( VOID )
{ {
PsJobType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); PsJobType = ExAllocatePoolWithTag (
NonPagedPool, sizeof(OBJECT_TYPE), TAG_EJOB );
PsJobType->Tag = TAG('E', 'J', 'O', 'B'); PsJobType->Tag = TAG_EJOB;
PsJobType->TotalObjects = 0; PsJobType->TotalObjects = 0;
PsJobType->TotalHandles = 0; PsJobType->TotalHandles = 0;
PsJobType->PeakObjects = 0; PsJobType->PeakObjects = 0;
@ -84,7 +90,8 @@ PsInitJobManagment(VOID)
} }
NTSTATUS NTSTATUS
PspAssignProcessToJob(PEPROCESS Process, PspAssignProcessToJob (
PEPROCESS Process,
PEJOB Job) PEJOB Job)
{ {
DPRINT("PspAssignProcessToJob() is unimplemented!\n"); DPRINT("PspAssignProcessToJob() is unimplemented!\n");
@ -92,9 +99,10 @@ PspAssignProcessToJob(PEPROCESS Process,
} }
NTSTATUS NTSTATUS
PspTerminateJobObject(PEJOB Job, PspTerminateJobObject (
PEJOB Job,
KPROCESSOR_MODE AccessMode, KPROCESSOR_MODE AccessMode,
NTSTATUS ExitStatus) NTSTATUS ExitStatus )
{ {
DPRINT("PspTerminateJobObject() is unimplemented!\n"); DPRINT("PspTerminateJobObject() is unimplemented!\n");
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
@ -106,7 +114,8 @@ PspTerminateJobObject(PEJOB Job,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtAssignProcessToJobObject(HANDLE JobHandle, NtAssignProcessToJobObject (
HANDLE JobHandle,
HANDLE ProcessHandle) HANDLE ProcessHandle)
{ {
PEPROCESS Process; PEPROCESS Process;
@ -123,7 +132,8 @@ NtAssignProcessToJobObject(HANDLE JobHandle,
I open the process handle before the job handle is that a simple test showed 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 that it first complains about a invalid process handle! The other way around
would be simpler though... */ would be simpler though... */
Status = ObReferenceObjectByHandle(ProcessHandle, Status = ObReferenceObjectByHandle(
ProcessHandle,
PROCESS_TERMINATE, PROCESS_TERMINATE,
PsProcessType, PsProcessType,
PreviousMode, PreviousMode,
@ -135,7 +145,8 @@ NtAssignProcessToJobObject(HANDLE JobHandle,
{ {
PEJOB Job; PEJOB Job;
Status = ObReferenceObjectByHandle(JobHandle, Status = ObReferenceObjectByHandle(
JobHandle,
JOB_OBJECT_ASSIGN_PROCESS, JOB_OBJECT_ASSIGN_PROCESS,
PsJobType, PsJobType,
PreviousMode, PreviousMode,
@ -193,9 +204,10 @@ NtAssignProcessToJobObject(HANDLE JobHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtCreateJobObject(PHANDLE JobHandle, NtCreateJobObject (
PHANDLE JobHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes) POBJECT_ATTRIBUTES ObjectAttributes )
{ {
HANDLE hJob; HANDLE hJob;
PEJOB Job; PEJOB Job;
@ -300,8 +312,9 @@ NtCreateJobObject(PHANDLE JobHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtIsProcessInJob(IN HANDLE ProcessHandle, NtIsProcessInJob (
IN HANDLE JobHandle OPTIONAL) IN HANDLE ProcessHandle,
IN HANDLE JobHandle OPTIONAL )
{ {
KPROCESSOR_MODE PreviousMode; KPROCESSOR_MODE PreviousMode;
PEPROCESS Process; PEPROCESS Process;
@ -311,7 +324,8 @@ NtIsProcessInJob(IN HANDLE ProcessHandle,
PAGED_CODE(); PAGED_CODE();
Status = ObReferenceObjectByHandle(ProcessHandle, Status = ObReferenceObjectByHandle(
ProcessHandle,
PROCESS_QUERY_INFORMATION, PROCESS_QUERY_INFORMATION,
PsProcessType, PsProcessType,
PreviousMode, PreviousMode,
@ -366,7 +380,8 @@ NtIsProcessInJob(IN HANDLE ProcessHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtOpenJobObject(PHANDLE JobHandle, NtOpenJobObject (
PHANDLE JobHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes) POBJECT_ATTRIBUTES ObjectAttributes)
{ {
@ -432,11 +447,12 @@ NtOpenJobObject(PHANDLE JobHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtQueryInformationJobObject(HANDLE JobHandle, NtQueryInformationJobObject (
HANDLE JobHandle,
JOBOBJECTINFOCLASS JobInformationClass, JOBOBJECTINFOCLASS JobInformationClass,
PVOID JobInformation, PVOID JobInformation,
ULONG JobInformationLength, ULONG JobInformationLength,
PULONG ReturnLength) PULONG ReturnLength )
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
@ -448,7 +464,8 @@ NtQueryInformationJobObject(HANDLE JobHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtSetInformationJobObject(HANDLE JobHandle, NtSetInformationJobObject (
HANDLE JobHandle,
JOBOBJECTINFOCLASS JobInformationClass, JOBOBJECTINFOCLASS JobInformationClass,
PVOID JobInformation, PVOID JobInformation,
ULONG JobInformationLength) ULONG JobInformationLength)
@ -463,8 +480,9 @@ NtSetInformationJobObject(HANDLE JobHandle,
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtTerminateJobObject(HANDLE JobHandle, NtTerminateJobObject (
NTSTATUS ExitStatus) HANDLE JobHandle,
NTSTATUS ExitStatus )
{ {
KPROCESSOR_MODE PreviousMode; KPROCESSOR_MODE PreviousMode;
PEJOB Job; PEJOB Job;
@ -474,7 +492,8 @@ NtTerminateJobObject(HANDLE JobHandle,
PreviousMode = ExGetPreviousMode(); PreviousMode = ExGetPreviousMode();
Status = ObReferenceObjectByHandle(JobHandle, Status = ObReferenceObjectByHandle(
JobHandle,
JOB_OBJECT_TERMINATE, JOB_OBJECT_TERMINATE,
PsJobType, PsJobType,
PreviousMode, PreviousMode,
@ -482,7 +501,8 @@ NtTerminateJobObject(HANDLE JobHandle,
NULL); NULL);
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
Status = PspTerminateJobObject(Job, Status = PspTerminateJobObject(
Job,
PreviousMode, PreviousMode,
ExitStatus); ExitStatus);
ObDereferenceObject(Job); ObDereferenceObject(Job);
@ -497,7 +517,7 @@ NtTerminateJobObject(HANDLE JobHandle,
*/ */
PVOID PVOID
STDCALL STDCALL
PsGetJobLock(PEJOB Job) PsGetJobLock ( PEJOB Job )
{ {
ASSERT(Job); ASSERT(Job);
return (PVOID)&Job->JobLock; return (PVOID)&Job->JobLock;
@ -509,7 +529,7 @@ PsGetJobLock(PEJOB Job)
*/ */
PVOID PVOID
STDCALL STDCALL
PsGetJobSessionId(PEJOB Job) PsGetJobSessionId ( PEJOB Job )
{ {
ASSERT(Job); ASSERT(Job);
return (PVOID)Job->SessionId; return (PVOID)Job->SessionId;
@ -521,7 +541,7 @@ PsGetJobSessionId(PEJOB Job)
*/ */
ULONG ULONG
STDCALL STDCALL
PsGetJobUIRestrictionsClass(PEJOB Job) PsGetJobUIRestrictionsClass ( PEJOB Job )
{ {
ASSERT(Job); ASSERT(Job);
return Job->UIRestrictionsClass; return Job->UIRestrictionsClass;
@ -533,7 +553,8 @@ PsGetJobUIRestrictionsClass(PEJOB Job)
*/ */
VOID VOID
STDCALL STDCALL
PsSetJobUIRestrictionsClass(PEJOB Job, PsSetJobUIRestrictionsClass (
PEJOB Job,
ULONG UIRestrictionsClass) ULONG UIRestrictionsClass)
{ {
ASSERT(Job); ASSERT(Job);