mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
implemented CreateJobObjectA/W() - untested though
svn path=/trunk/; revision=11006
This commit is contained in:
parent
b85ef6c64a
commit
51c36121e9
1 changed files with 90 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
||||||
/* $Id: job.c,v 1.1 2004/09/23 18:02:19 weiden Exp $
|
/* $Id: job.c,v 1.2 2004/09/23 18:31:51 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/kernel32/process/job.c
|
* FILE: lib/kernel32/process/job.c
|
||||||
* PURPOSE: Job functions
|
* PURPOSE: Job functions
|
||||||
* PROGRAMMER: Thomas Weidenmueller
|
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 9/23/2004
|
* Created 9/23/2004
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,94 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
||||||
|
LPCSTR lpName)
|
||||||
|
{
|
||||||
|
HANDLE hJob;
|
||||||
|
ANSI_STRING AnsiName;
|
||||||
|
UNICODE_STRING UnicodeName;
|
||||||
|
|
||||||
|
if(lpName != NULL)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
RtlInitAnsiString(&AnsiName, lpName);
|
||||||
|
Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hJob = CreateJobObjectW(lpJobAttributes,
|
||||||
|
((lpName != NULL) ? UnicodeName.Buffer : NULL));
|
||||||
|
|
||||||
|
if(lpName != NULL)
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&UnicodeName);
|
||||||
|
}
|
||||||
|
return hJob;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
||||||
|
LPCWSTR lpName)
|
||||||
|
{
|
||||||
|
UNICODE_STRING JobName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
PVOID SecurityDescriptor;
|
||||||
|
HANDLE hJob;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if(lpName != NULL)
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&JobName, lpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lpJobAttributes != NULL)
|
||||||
|
{
|
||||||
|
if(lpJobAttributes->bInheritHandle)
|
||||||
|
{
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SecurityDescriptor = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
((lpName != NULL) ? &JobName : NULL),
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
SecurityDescriptor);
|
||||||
|
|
||||||
|
Status = NtCreateJobObject(&hJob,
|
||||||
|
JOB_OBJECT_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hJob;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -236,7 +324,6 @@ TerminateJobObject(HANDLE hJob,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = NtTerminateJobObject(hJob, uExitCode);
|
Status = NtTerminateJobObject(hJob, uExitCode);
|
||||||
|
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
|
|
Loading…
Reference in a new issue