reactos/lib/kernel32
diff -u -r1.85 -r1.86
--- makefile 21 Sep 2004 19:17:26 -0000 1.85
+++ makefile 23 Sep 2004 18:02:19 -0000 1.86
@@ -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 = ../..
@@ -62,6 +62,7 @@
process/proc.o \
process/cmdline.o \
process/create.o \
+ process/job.o \
process/session.o
STRING_OBJECTS = string/lstring.o
reactos/lib/kernel32/misc
diff -u -r1.89 -r1.90
--- stubs.c 22 Sep 2004 10:58:06 -0000 1.89
+++ stubs.c 23 Sep 2004 18:02:19 -0000 1.90
@@ -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)
* Remove from this file, if you implement them.
@@ -576,20 +576,6 @@
*/
BOOL
STDCALL
-AssignProcessToJobObject(
- HANDLE hJob,
- HANDLE hProcess
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
BindIoCompletionCallback (
HANDLE FileHandle,
LPOVERLAPPED_COMPLETION_ROUTINE Function,
@@ -875,21 +861,6 @@
*/
BOOL
STDCALL
-IsProcessInJob (
- HANDLE ProcessHandle,
- HANDLE JobHandle,
- PBOOL Result
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
IsSystemResumeAutomatic(
VOID
)
@@ -964,23 +935,6 @@
/*
* @unimplemented
*/
-BOOL
-STDCALL
-QueryInformationJobObject(
- HANDLE hJob,
- JOBOBJECTINFOCLASS JobObjectInformationClass,
- LPVOID lpJobObjectInformation,
- DWORD cbJobObjectInformationLength,
- LPDWORD lpReturnLength
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
DWORD
STDCALL
QueueUserAPC(
@@ -1157,23 +1111,6 @@
STUB;
}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-SetInformationJobObject(
- HANDLE hJob,
- JOBOBJECTINFOCLASS JobObjectInformationClass,
- LPVOID lpJobObjectInformation,
- DWORD cbJobObjectInformationLength
- )
-{
- STUB;
- return 0;
-}
-
/*
* @unimplemented
*/
@@ -1206,20 +1143,6 @@
*/
BOOL
STDCALL
-TerminateJobObject(
- HANDLE hJob,
- UINT uExitCode
- )
-{
- STUB;
- return 0;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
TzSpecificLocalTimeToSystemTime(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
LPSYSTEMTIME lpLocalTime,
reactos/lib/kernel32/process
diff -N job.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ job.c 23 Sep 2004 18:02:19 -0000 1.1
@@ -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 */