My kernel fixes, new apis, reformatting, commenting, documenting,
reorganizing, bug fixing, optimizing patch. More detailed changelog at
www.relsoft.net/changelog. Passes all regression tests and installs/runs
Abiword. Will be updated along the week and merged later.
Modified:
branches/alex_devel_branch/reactos/drivers/storage/floppy/floppy.c
Modified: branches/alex_devel_branch/reactos/include/ddk/extypes.h
Modified: branches/alex_devel_branch/reactos/include/ddk/iotypes.h
Modified: branches/alex_devel_branch/reactos/include/ddk/ketypes.h
Modified: branches/alex_devel_branch/reactos/include/ntos/zwtypes.h
Modified: branches/alex_devel_branch/reactos/lib/ntdll/def/ntdll.def
Modified: branches/alex_devel_branch/reactos/ntoskrnl/Makefile
Modified: branches/alex_devel_branch/reactos/ntoskrnl/cm/registry.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/btree.c
Added: branches/alex_devel_branch/reactos/ntoskrnl/ex/error.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/event.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/evtpair.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/hashtab.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/init.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/mutant.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/napi.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/rundown.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/sem.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/stree.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/synch.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/sysinfo.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/timer.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/util.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/work.c
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/ex.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/id.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/io.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/ke.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/nls.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/ntoskrnl.h
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/include/internal/ps.h
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/bootlog.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/cleanup.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/create.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/deviface.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/driver.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/flush.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/iocomp.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/iomgr.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/irq.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/lock.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/mailslot.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/npipe.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/pnpnotify.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/pnpreport.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/remlock.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/timer.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/wdm.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/wmi.c
Deleted: branches/alex_devel_branch/reactos/ntoskrnl/ke/alert.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/apc.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/bug.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/catch.c
Deleted: branches/alex_devel_branch/reactos/ntoskrnl/ke/critical.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/dpc.c
Deleted: branches/alex_devel_branch/reactos/ntoskrnl/ke/error.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/event.c
Modified:
branches/alex_devel_branch/reactos/ntoskrnl/ke/i386/tskswitch.S
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/kqueue.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/kthread.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/main.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/mutex.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/queue.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/sem.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/timer.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/wait.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ntoskrnl.def
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ntoskrnl.mc
Added: branches/alex_devel_branch/reactos/ntoskrnl/ob/wait.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ps/idle.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ps/kill.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ps/process.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ps/thread.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/rtl/nls.c
Modified: branches/alex_devel_branch/reactos/tools/nci/sysfuncs.lst
_____
Modified:
branches/alex_devel_branch/reactos/drivers/storage/floppy/floppy.c
--- branches/alex_devel_branch/reactos/drivers/storage/floppy/floppy.c
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/drivers/storage/floppy/floppy.c
2005-02-28 22:03:10 UTC (rev 13786)
@@ -58,7 +58,7 @@
/* Queue thread management */
static KEVENT QueueThreadTerminate;
-static PVOID ThreadObject;
+static PVOID QueueThreadObject;
static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
@@ -378,8 +378,8 @@
KdPrint(("floppy: unloading\n"));
KeSetEvent(&QueueThreadTerminate, 0, FALSE);
- KeWaitForSingleObject(ThreadObject, Executive, KernelMode, FALSE, 0);
- ObDereferenceObject(ThreadObject);
+ KeWaitForSingleObject(QueueThreadObject, Executive, KernelMode,
FALSE, 0);
+ ObDereferenceObject(QueueThreadObject);
for(i = 0; i < gNumberOfControllers; i++)
{
@@ -1152,7 +1152,7 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
- if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL,
KernelMode, &ThreadObject, NULL) != STATUS_SUCCESS)
+ if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL,
KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS)
{
KdPrint(("floppy: Unable to reference returned thread handle;
failing init\n"));
return STATUS_UNSUCCESSFUL;
_____
Modified: branches/alex_devel_branch/reactos/include/ddk/extypes.h
--- branches/alex_devel_branch/reactos/include/ddk/extypes.h
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/include/ddk/extypes.h
2005-02-28 22:03:10 UTC (rev 13786)
@@ -30,6 +30,23 @@
MaximumWorkQueue
} WORK_QUEUE_TYPE;
+typedef struct _EX_QUEUE_WORKER_INFO {
+ UCHAR QueueDisabled:1;
+ UCHAR MakeThreadsAsNecessary:1;
+ UCHAR WaitMode:1;
+ ULONG WorkerCount:29;
+} EX_QUEUE_WORKER_INFO, *PEX_QUEUE_WORKER_INFO;
+
+typedef struct _EX_WORK_QUEUE {
+ KQUEUE WorkerQueue;
+ ULONG DynamicThreadCount;
+ ULONG WorkItemsProcessed;
+ ULONG WorkItemsProcessedLastPass;
+ ULONG QueueDepthLastPass;
+ EX_QUEUE_WORKER_INFO Info;
+} EX_WORK_QUEUE, *PEX_WORK_QUEUE;
+
+
typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
typedef struct _OWNER_ENTRY
@@ -240,6 +257,10 @@
PVOID Argument1,
PVOID Argument2);
+extern struct _OBJECT_TYPE EXPORTED *ExMutantObjectType;
+extern struct _OBJECT_TYPE EXPORTED *ExSemaphoreObjectType;
+extern struct _OBJECT_TYPE EXPORTED *ExTimerType;
+
#endif /* __INCLUDE_DDK_EXTYPES_H */
/* EOF */
_____
Modified: branches/alex_devel_branch/reactos/include/ddk/iotypes.h
--- branches/alex_devel_branch/reactos/include/ddk/iotypes.h
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/include/ddk/iotypes.h
2005-02-28 22:03:10 UTC (rev 13786)
@@ -886,6 +886,8 @@
#endif
#define IO_TYPE_DRIVER 4L
+#define IO_TYPE_FILE 0x0F5L
+
#define DRVO_UNLOAD_INVOKED 0x1L
#define DRVO_LEGACY_DRIVER 0x2L
#define DRVO_BUILTIN_DRIVER 0x4L
_____
Modified: branches/alex_devel_branch/reactos/include/ddk/ketypes.h
--- branches/alex_devel_branch/reactos/include/ddk/ketypes.h
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/include/ddk/ketypes.h
2005-02-28 22:03:10 UTC (rev 13786)
@@ -36,23 +36,34 @@
struct _DISPATCHER_HEADER;
-typedef enum _KERNEL_OBJECTS {
- KNotificationEvent = 0,
- KSynchronizationEvent = 1,
- KMutant = 2,
- KProcess = 3,
- KQueue = 4,
- KSemaphore = 5,
- KThread = 6,
- KNotificationTimer = 8,
- KSynchronizationTimer = 9,
- KApc = 18,
- KDpc = 19,
- KDeviceQueue = 20,
- KEventPair = 21,
- KInterrupt = 22,
- KProfile = 23
-} KERNEL_OBJECTS;
+typedef enum _KOBJECTS {
+ EventNotificationObject = 0,
+ EventSynchronizationObject = 1,
+ MutantObject = 2,
+ ProcessObject = 3,
+ QueueObject = 4,
+ SemaphoreObject = 5,
+ ThreadObject = 6,
+ GateObject = 7,
+ TimerNotificationObject = 8,
+ TimerSynchronizationObject = 9,
+ Spare2Object = 10,
+ Spare3Object = 11,
+ Spare4Object = 12,
+ Spare5Object = 13,
+ Spare6Object = 14,
+ Spare7Object = 15,
+ Spare8Object = 16,
+ Spare9Object = 17,
+ ApcObject = 18,
+ DpcObject = 19,
+ DeviceQueueObject = 20,
+ EventPairObject = 21,
+ InterruptObject = 22,
+ ProfileObject = 23,
+ ThreadedDpcObject = 24,
+ MaximumKernelObject = 25
+} KOBJECTS;
#include <pshpack1.h>
_____
Modified: branches/alex_devel_branch/reactos/include/ntos/zwtypes.h
--- branches/alex_devel_branch/reactos/include/ntos/zwtypes.h
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/include/ntos/zwtypes.h
2005-02-28 22:03:10 UTC (rev 13786)
@@ -1262,9 +1262,9 @@
typedef struct _MUTANT_BASIC_INFORMATION
{
- LONG Count;
- BOOLEAN Owned;
- BOOLEAN Abandoned;
+ LONG CurrentCount;
+ BOOLEAN OwnedByCaller;
+ BOOLEAN AbandonedState;
} MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION;
_____
Modified: branches/alex_devel_branch/reactos/lib/ntdll/def/ntdll.def
--- branches/alex_devel_branch/reactos/lib/ntdll/def/ntdll.def
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/lib/ntdll/def/ntdll.def
2005-02-28 22:03:10 UTC (rev 13786)
@@ -225,7 +225,6 @@
NtSetEvent@8
NtSetHighEventPair@4
NtSetHighWaitLowEventPair@4
-NtSetHighWaitLowThread@0
NtSetInformationFile@20
NtSetInformationJobObject@16
NtSetInformationKey@16
@@ -238,7 +237,6 @@
NtSetLdtEntries@24
NtSetLowEventPair@4
NtSetLowWaitHighEventPair@4
-NtSetLowWaitHighThread@0
NtSetSecurityObject@12
NtSetSystemEnvironmentValue@8
NtSetSystemInformation@12
@@ -849,7 +847,6 @@
ZwSetEvent@8
ZwSetHighEventPair@4
ZwSetHighWaitLowEventPair@4
-ZwSetHighWaitLowThread@0
ZwSetInformationFile@20
ZwSetInformationKey@16
ZwSetInformationObject@16
@@ -861,7 +858,6 @@
ZwSetLdtEntries@24
ZwSetLowEventPair@4
ZwSetLowWaitHighEventPair@4
-ZwSetLowWaitHighThread@0
ZwSetSecurityObject@12
ZwSetSystemEnvironmentValue@8
ZwSetSystemInformation@12
_____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/Makefile
--- branches/alex_devel_branch/reactos/ntoskrnl/Makefile
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/ntoskrnl/Makefile
2005-02-28 22:03:10 UTC (rev 13786)
@@ -101,10 +101,8 @@
ke/bug.o \
ke/catch.o \
ke/clock.o \
- ke/critical.o \
ke/dpc.o \
ke/device.o \
- ke/error.o \
ke/event.o \
ke/kqueue.o \
ke/kthread.o \
@@ -118,7 +116,6 @@
ke/spinlock.o \
ke/timer.o \
ke/wait.o \
- ke/alert.o
# Memory Manager (Mm)
OBJECTS_MM = \
@@ -219,7 +216,8 @@
ob/object.o \
ob/sdcache.o \
ob/security.o \
- ob/symlink.o
+ ob/symlink.o \
+ ob/wait.o
# Process Manager (Ps)
OBJECTS_PS = \
@@ -242,6 +240,7 @@
OBJECTS_EX = \
ex/btree.o \
ex/callback.o \
+ ex/error.o \
ex/event.o \
ex/evtpair.o \
ex/fmutex.o \
_____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/cm/registry.c
--- branches/alex_devel_branch/reactos/ntoskrnl/cm/registry.c
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/ntoskrnl/cm/registry.c
2005-02-28 22:03:10 UTC (rev 13786)
@@ -241,7 +241,30 @@
CmiCheckByName(Verbose, L"User");
}
+VOID
+INIT_FUNCTION
+STDCALL
+CmInitHives(BOOLEAN SetupBoot)
+{
+ PCHAR BaseAddress;
+
+ /* Load Registry Hives */
+ BaseAddress = (PCHAR)CachedModules[SystemRegistry]->ModStart;
+ CmImportSystemHive(BaseAddress,
+ CachedModules[SystemRegistry]->ModEnd -
(ULONG_PTR)BaseAddress);
+
+ BaseAddress = (PCHAR)CachedModules[HardwareRegistry]->ModStart;
+ CmImportHardwareHive(BaseAddress,
+ CachedModules[HardwareRegistry]->ModEnd -
(ULONG_PTR)BaseAddress);
+
+ /* Create dummy keys if no hardware hive was found */
+ CmImportHardwareHive (NULL, 0);
+
+ /* Initialize volatile registry settings */
+ if (SetupBoot == FALSE) CmInit2((PCHAR)KeLoaderBlock.CommandLine);
+}
+
VOID INIT_FUNCTION
CmInitializeRegistry(VOID)
{
_____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/btree.c
--- branches/alex_devel_branch/reactos/ntoskrnl/ex/btree.c
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/ntoskrnl/ex/btree.c
2005-02-28 22:03:10 UTC (rev 13786)
@@ -1,4 +1,4 @@
-/* $Id:$
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
_____
Added: branches/alex_devel_branch/reactos/ntoskrnl/ex/error.c
--- branches/alex_devel_branch/reactos/ntoskrnl/ex/error.c
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/ntoskrnl/ex/error.c
2005-02-28 22:03:10 UTC (rev 13786)
@@ -0,0 +1,163 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/ex/error.c
+ * PURPOSE: Error Functions and Status/Exception
Dispatching/Raising
+ *
+ * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - Created File
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+/* GLOBALS
****************************************************************/
+
+BOOLEAN ExReadyForErrors = FALSE;
+PEPORT ExpDefaultErrorPort = NULL;
+PEPROCESS ExpDefaultErrorPortProcess = NULL;
+
+/* FUNCTIONS
****************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+ExRaiseAccessViolation(VOID)
+{
+ /* Raise the Right Status */
+ ExRaiseStatus (STATUS_ACCESS_VIOLATION);
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+ExRaiseDatatypeMisalignment (VOID)
+{
+ /* Raise the Right Status */
+ ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+ExRaiseStatus(IN NTSTATUS Status)
+{
+ EXCEPTION_RECORD ExceptionRecord;
+
+ DPRINT("ExRaiseStatus(%x)\n", Status);
+
+ /* Set up an Exception Record */
+ ExceptionRecord.ExceptionRecord = NULL;
+ ExceptionRecord.NumberParameters = 0;
+ ExceptionRecord.ExceptionCode = Status;
+ ExceptionRecord.ExceptionFlags = 0;
+
+ /* Call the Rtl Function */
+ RtlRaiseException(&ExceptionRecord);
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+ExRaiseException (PEXCEPTION_RECORD ExceptionRecord)
+{
+ /* Call the Rtl function */
+ RtlRaiseException(ExceptionRecord);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+STDCALL
+ExSystemExceptionFilter(VOID)
+{
+ return KeGetPreviousMode() != KernelMode ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+STDCALL
+ExRaiseHardError(IN NTSTATUS ErrorStatus,
+ IN ULONG NumberOfParameters,
+ IN PUNICODE_STRING UnicodeStringParameterMask
OPTIONAL,
+ IN PVOID *Parameters,
+ IN HARDERROR_RESPONSE_OPTION ResponseOption,
+ OUT PHARDERROR_RESPONSE Response)
+{
+ UNIMPLEMENTED;
+}
+
+NTSTATUS
+STDCALL
+NtRaiseHardError(IN NTSTATUS ErrorStatus,
+ IN ULONG NumberOfParameters,
+ IN PUNICODE_STRING UnicodeStringParameterMask
OPTIONAL,
+ IN PVOID *Parameters,
+ IN HARDERROR_RESPONSE_OPTION ResponseOption,
+ OUT PHARDERROR_RESPONSE Response)
+{
+ DPRINT1("Hard error %x\n", ErrorStatus);
+
+ /* Call the Executive Function (WE SHOULD PUT SEH HERE/CAPTURE!) */
+ ExRaiseHardError(ErrorStatus,
+ NumberOfParameters,
+ UnicodeStringParameterMask,
+ Parameters,
+ ResponseOption,
+ Response);
+
+ /* Return Success */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+STDCALL
+NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
+{
+
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ NTSTATUS Status = STATUS_UNSUCCESSFUL;
+
+ /* Check if we have the Privilege */
+ if(!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode)) {
+
+ DPRINT1("NtSetDefaultHardErrorPort: Caller requires the
SeTcbPrivilege privilege!\n");
+ return STATUS_PRIVILEGE_NOT_HELD;
+ }
+
+ /* Only called once during bootup, make sure we weren't called yet
*/
+ if(!ExReadyForErrors) {
+
+ Status = ObReferenceObjectByHandle(PortHandle,
+ 0,
+ LpcPortObjectType,
+ PreviousMode,
+
(PVOID*)&ExpDefaultErrorPort,
+ NULL);
+
+ /* Check for Success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Save the data */
+ ExpDefaultErrorPortProcess = PsGetCurrentProcess();
+ ExReadyForErrors = TRUE;
+ }
+ }
+
+ return Status;
+}
+
+/* EOF */
_____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ex/event.c
--- branches/alex_devel_branch/reactos/ntoskrnl/ex/event.c
2005-02-28 21:59:47 UTC (rev 13785)
+++ branches/alex_devel_branch/reactos/ntoskrnl/ex/event.c
2005-02-28 22:03:10 UTC (rev 13786)
@@ -19,300 +19,286 @@
POBJECT_TYPE EXPORTED ExEventObjectType = NULL;
static GENERIC_MAPPING ExpEventMapping = {
- STANDARD_RIGHTS_READ | SYNCHRONIZE | EVENT_QUERY_STATE,
- STANDARD_RIGHTS_WRITE | SYNCHRONIZE | EVENT_MODIFY_STATE,
- STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | EVENT_QUERY_STATE,
- EVENT_ALL_ACCESS};
+ STANDARD_RIGHTS_READ | SYNCHRONIZE | EVENT_QUERY_STATE,
+ STANDARD_RIGHTS_WRITE | SYNCHRONIZE | EVENT_MODIFY_STATE,
+ STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | EVENT_QUERY_STATE,
+ EVENT_ALL_ACCESS};
-static const INFORMATION_CLASS_INFO ExEventInfoClass[] =
-{
- ICI_SQ_SAME( sizeof(EVENT_BASIC_INFORMATION), sizeof(ULONG),
ICIF_QUERY ), /* EventBasicInformation */
+static const INFORMATION_CLASS_INFO ExEventInfoClass[] = {
+
+ /* EventBasicInformation */
+ ICI_SQ_SAME( sizeof(EVENT_BASIC_INFORMATION), sizeof(ULONG),
ICIF_QUERY),
};
/* FUNCTIONS
*****************************************************************/
-NTSTATUS STDCALL
-NtpCreateEvent(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_ATTRIBUTES ObjectAttributes)
-{
- DPRINT("NtpCreateEvent(ObjectBody %x, Parent %x, RemainingPath
%S)\n",
- ObjectBody, Parent, RemainingPath);
-
- if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL)
- {
- return(STATUS_UNSUCCESSFUL);
- }
-
- return(STATUS_SUCCESS);
-}
-
-
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
ExpInitializeEventImplementation(VOID)
{
- ExEventObjectType =
ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
-
- RtlpCreateUnicodeString(&ExEventObjectType->TypeName, L"Event",
NonPagedPool);
-
- ExEventObjectType->Tag = TAG('E', 'V', 'T', 'T');
- ExEventObjectType->PeakObjects = 0;
- ExEventObjectType->PeakHandles = 0;
- ExEventObjectType->TotalObjects = 0;
- ExEventObjectType->TotalHandles = 0;
- ExEventObjectType->PagedPoolCharge = 0;
- ExEventObjectType->NonpagedPoolCharge = sizeof(KEVENT);
- ExEventObjectType->Mapping = &ExpEventMapping;
- ExEventObjectType->Dump = NULL;
- ExEventObjectType->Open = NULL;
- ExEventObjectType->Close = NULL;
- ExEventObjectType->Delete = NULL;
- ExEventObjectType->Parse = NULL;
- ExEventObjectType->Security = NULL;
- ExEventObjectType->QueryName = NULL;
- ExEventObjectType->OkayToClose = NULL;
- ExEventObjectType->Create = NtpCreateEvent;
- ExEventObjectType->DuplicationNotify = NULL;
-
- ObpCreateTypeObject(ExEventObjectType);
+ /* Create the Event Object Type */
+ ExEventObjectType =
ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+ RtlpCreateUnicodeString(&ExEventObjectType->TypeName, L"Event",
NonPagedPool);
+ ExEventObjectType->Tag = TAG('E', 'V', 'T', 'T');
+ ExEventObjectType->PeakObjects = 0;
+ ExEventObjectType->PeakHandles = 0;
+ ExEventObjectType->TotalObjects = 0;
+ ExEventObjectType->TotalHandles = 0;
+ ExEventObjectType->PagedPoolCharge = 0;
+ ExEventObjectType->NonpagedPoolCharge = sizeof(KEVENT);
+ ExEventObjectType->Mapping = &ExpEventMapping;
+ ExEventObjectType->Dump = NULL;
+ ExEventObjectType->Open = NULL;
+ ExEventObjectType->Close = NULL;
+ ExEventObjectType->Delete = NULL;
+ ExEventObjectType->Parse = NULL;
+ ExEventObjectType->Security = NULL;
+ ExEventObjectType->QueryName = NULL;
+ ExEventObjectType->OkayToClose = NULL;
+ ExEventObjectType->Create = NULL;
+ ExEventObjectType->DuplicationNotify = NULL;
+ ObpCreateTypeObject(ExEventObjectType);
}
-
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtClearEvent(IN HANDLE EventHandle)
{
- PKEVENT Event;
- NTSTATUS Status;
+ PKEVENT Event;
+ NTSTATUS Status;
+
+ PAGED_CODE();
- PAGED_CODE();
-
+ /* Reference the Object */
Status = ObReferenceObjectByHandle(EventHandle,
- EVENT_MODIFY_STATE,
- ExEventObjectType,
- ExGetPreviousMode(),
- (PVOID*)&Event,
- NULL);
- if(NT_SUCCESS(Status))
- {
- KeClearEvent(Event);
- ObDereferenceObject(Event);
- }
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ ExGetPreviousMode(),
+ (PVOID*)&Event,
+ NULL);
- return Status;
+ /* Check for Success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Clear the Event and Dereference */
+ KeClearEvent(Event);
+ ObDereferenceObject(Event);
+ }
+
+ /* Return Status */
+ return Status;
}
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtCreateEvent(OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
- IN EVENT_TYPE EventType,
- IN BOOLEAN InitialState)
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+ IN EVENT_TYPE EventType,
+ IN BOOLEAN InitialState)
{
- KPROCESSOR_MODE PreviousMode;
- PKEVENT Event;
- HANDLE hEvent;
- NTSTATUS Status = STATUS_SUCCESS;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ PKEVENT Event;
+ HANDLE hEvent;
+ NTSTATUS Status = STATUS_SUCCESS;
- PAGED_CODE();
+ PAGED_CODE();
- PreviousMode = ExGetPreviousMode();
-
- if(PreviousMode == UserMode)
- {
- _SEH_TRY
- {
- ProbeForWrite(EventHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
+ /* Check Output Safety */
+ if(PreviousMode == UserMode) {
+
+ _SEH_TRY {
+
+ ProbeForWrite(EventHandle,
+ sizeof(HANDLE),
+ sizeof(ULONG));
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
- if(!NT_SUCCESS(Status))
- {
- return Status;
- }
- }
+ if(!NT_SUCCESS(Status)) return Status;
+ }
+
+ /* Create the Object */
+ Status = ObCreateObject(PreviousMode,
+ ExEventObjectType,
+ ObjectAttributes,
+ PreviousMode,
+ NULL,
+ sizeof(KEVENT),
+ 0,
+ 0,
+ (PVOID*)&Event);
+
+ /* Check for Success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Initalize the Event */
+ KeInitializeEvent(Event,
+ EventType,
+ InitialState);
+
+ /* Insert it */
+ Status = ObInsertObject((PVOID)Event,
+ NULL,
+ DesiredAccess,
+ 0,
+ NULL,
+ &hEvent);
+ ObDereferenceObject(Event);
- Status = ObCreateObject(PreviousMode,
- ExEventObjectType,
- ObjectAttributes,
- PreviousMode,
- NULL,
- sizeof(KEVENT),
- 0,
- 0,
- (PVOID*)&Event);
- if(NT_SUCCESS(Status))
- {
- KeInitializeEvent(Event,
- EventType,
- InitialState);
-
-
- Status = ObInsertObject((PVOID)Event,
- NULL,
- DesiredAccess,
- 0,
- NULL,
- &hEvent);
- ObDereferenceObject(Event);
-
- if(NT_SUCCESS(Status))
- {
- _SEH_TRY
- {
- *EventHandle = hEvent;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
- }
-
- return Status;
+ /* Check for success and return handle */
+ if(NT_SUCCESS(Status)) {
+
+ _SEH_TRY {
+
+ *EventHandle = hEvent;
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+ }
+ }
+
+ /* Return Status */
+ return Status;
}
-
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtOpenEvent(OUT PHANDLE EventHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes)
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes)
{
- HANDLE hEvent;
- KPROCESSOR_MODE PreviousMode;
- NTSTATUS Status = STATUS_SUCCESS;
+ HANDLE hEvent;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ NTSTATUS Status = STATUS_SUCCESS;
- PAGED_CODE();
-
- DPRINT("NtOpenEvent(0x%x, 0x%x, 0x%x)\n", EventHandle,
DesiredAccess, ObjectAttributes);
+ PAGED_CODE();
+ DPRINT("NtOpenEvent(0x%x, 0x%x, 0x%x)\n", EventHandle,
DesiredAccess, ObjectAttributes);
- PreviousMode = ExGetPreviousMode();
-
- if(PreviousMode == UserMode)
- {
- _SEH_TRY
- {
- ProbeForWrite(EventHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
+ /* Check Output Safety */
+ if(PreviousMode == UserMode) {
+
+ _SEH_TRY {
+
+ ProbeForWrite(EventHandle,
+ sizeof(HANDLE),
+ sizeof(ULONG));
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
- if(!NT_SUCCESS(Status))
- {
- return Status;
- }
- }
-
- Status = ObOpenObjectByName(ObjectAttributes,
- ExEventObjectType,
- NULL,
- PreviousMode,
- DesiredAccess,
- NULL,
- &hEvent);
+ if(!NT_SUCCESS(Status)) return Status;
+ }
+
+ /* Open the Object */
+ Status = ObOpenObjectByName(ObjectAttributes,
+ ExEventObjectType,
+ NULL,
+ PreviousMode,
+ DesiredAccess,
+ NULL,
+ &hEvent);
- if(NT_SUCCESS(Status))
- {
- _SEH_TRY
- {
- *EventHandle = hEvent;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
+ /* Check for success and return handle */
+ if(NT_SUCCESS(Status)) {
+
+ _SEH_TRY {
+
+ *EventHandle = hEvent;
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+ }
- return Status;
+ /* Return status */
+ return Status;
}
-
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtPulseEvent(IN HANDLE EventHandle,
- OUT PLONG PreviousState OPTIONAL)
+ OUT PLONG PreviousState OPTIONAL)
{
- PKEVENT Event;
- KPROCESSOR_MODE PreviousMode;
- NTSTATUS Status = STATUS_SUCCESS;
+ PKEVENT Event;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ NTSTATUS Status = STATUS_SUCCESS;
- PAGED_CODE();
+ PAGED_CODE();
+ DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
+ EventHandle, PreviousState);
- DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
- EventHandle, PreviousState);
+ /* Check buffer validity */
+ if(PreviousState && PreviousMode == UserMode) {
+
+ _SEH_TRY {
+
+ ProbeForWrite(PreviousState,
+ sizeof(LONG),
+ sizeof(ULONG));
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
- PreviousMode = ExGetPreviousMode();
-
- if(PreviousState != NULL && PreviousMode == UserMode)
- {
- _SEH_TRY
- {
- ProbeForWrite(PreviousState,
- sizeof(LONG),
- sizeof(ULONG));
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
+ if(!NT_SUCCESS(Status)) return Status;
+ }
+
+ /* Open the Object */
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ PreviousMode,
+ (PVOID*)&Event,
+ NULL);
+
+ /* Check for success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Pulse the Event */
+ LONG Prev = KePulseEvent(Event, EVENT_INCREMENT, FALSE);
+ ObDereferenceObject(Event);
- if(!NT_SUCCESS(Status))
- {
- return Status;
- }
+ /* Return it */
+ if(PreviousState) {
+
+ _SEH_TRY {
+
+ *PreviousState = Prev;
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+ }
}
- Status = ObReferenceObjectByHandle(EventHandle,
- EVENT_MODIFY_STATE,
- ExEventObjectType,
- PreviousMode,
- (PVOID*)&Event,
- NULL);
- if(NT_SUCCESS(Status))
- {
- LONG Prev = KePulseEvent(Event, EVENT_INCREMENT, FALSE);
- ObDereferenceObject(Event);
-
- if(PreviousState != NULL)
- {
- _SEH_TRY
- {
- *PreviousState = Prev;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
- }
-
+ /* Return Status */
return Status;
}
@@ -320,230 +306,202 @@
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtQueryEvent(IN HANDLE EventHandle,
- IN EVENT_INFORMATION_CLASS EventInformationClass,
- OUT PVOID EventInformation,
- IN ULONG EventInformationLength,
- OUT PULONG ReturnLength OPTIONAL)
+ IN EVENT_INFORMATION_CLASS EventInformationClass,
+ OUT PVOID EventInformation,
+ IN ULONG EventInformationLength,
+ OUT PULONG ReturnLength OPTIONAL)
{
- PKEVENT Event;
- KPROCESSOR_MODE PreviousMode;
- NTSTATUS Status = STATUS_SUCCESS;
+ PKEVENT Event;
[truncated at 1000 lines; 14056 more skipped]