Modified: trunk/reactos/iface/native/makefile
Modified: trunk/reactos/iface/native/sysfuncs.lst
Modified: trunk/reactos/include/ddk/ketypes.h
Modified: trunk/reactos/lib/ntdll/def/ntdll.def
Modified: trunk/reactos/ntoskrnl/Makefile
Modified: trunk/reactos/ntoskrnl/Makefile.i386
Added: trunk/reactos/ntoskrnl/ex/event.c
Added: trunk/reactos/ntoskrnl/ex/evtpair.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
Added: trunk/reactos/ntoskrnl/ex/mutant.c
Added: trunk/reactos/ntoskrnl/ex/profile.c
Added: trunk/reactos/ntoskrnl/ex/sem.c
Added: trunk/reactos/ntoskrnl/ex/timer.c
Modified: trunk/reactos/ntoskrnl/inbv/inbv.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
Modified: trunk/reactos/ntoskrnl/include/internal/port.h
Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h
Added: trunk/reactos/ntoskrnl/io/efi.c
Added: trunk/reactos/ntoskrnl/io/plugplay.c
Added: trunk/reactos/ntoskrnl/ke/i386/vdm.c
Modified: trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/ke/profile.c
Added: trunk/reactos/ntoskrnl/ke/zw.c
Modified: trunk/reactos/ntoskrnl/lpc/connect.c
Modified: trunk/reactos/ntoskrnl/lpc/create.c
Modified: trunk/reactos/ntoskrnl/lpc/port.c
--- trunk/reactos/iface/native/makefile 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/iface/native/makefile 2005-01-07 06:54:27 UTC (rev 12861)
@@ -14,7 +14,7 @@
SYSTEM_CALLS_DB = sysfuncs.lst
NTDLL_STUBS = ../../lib/ntdll/napi.c
KERNEL_SERVICE_TABLE = ../../include/ntdll/napi.h
-KERNEL_ZW_CALLS = ../../ntoskrnl/nt/zw.c
+KERNEL_ZW_CALLS = ../../ntoskrnl/ke/zw.c
NAPI_FILES = $(NTDLL_STUBS) $(KERNEL_SERVICE_TABLE) $(KERNEL_ZW_CALLS)
BASE_CFLAGS = -I../../include
--- trunk/reactos/iface/native/sysfuncs.lst 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/iface/native/sysfuncs.lst 2005-01-07 06:54:27 UTC (rev 12861)
@@ -232,10 +232,4 @@
NtWriteRequestData ZwWriteRequestData 6
NtWriteVirtualMemory ZwWriteVirtualMemory 5
NtW32Call ZwW32Call 5
-NtCreateChannel ZwCreateChannel 2
-NtListenChannel ZwListenChannel 2
-NtOpenChannel ZwOpenChannel 2
-NtReplyWaitSendChannel ZwReplyWaitSendChannel 3
-NtSendWaitReplyChannel ZwSendWaitReplyChannel 4
-NtSetContextChannel ZwSetContextChannel 1
NtYieldExecution ZwYieldExecution 0
--- trunk/reactos/include/ddk/ketypes.h 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/include/ddk/ketypes.h 2005-01-07 06:54:27 UTC (rev 12861)
@@ -99,6 +99,10 @@
BOOLEAN Busy;
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
+/*
+ * Size of the profile hash table.
+ */
+#define PROFILE_HASH_TABLE_SIZE (32)
#include <pshpack2.h>
--- trunk/reactos/lib/ntdll/def/ntdll.def 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/lib/ntdll/def/ntdll.def 2005-01-07 06:54:27 UTC (rev 12861)
@@ -77,7 +77,6 @@
NtCompleteConnectPort@4
NtConnectPort@32
NtContinue@8
-NtCreateChannel@8
NtCreateDirectoryObject@12
NtCreateEvent@20
NtCreateEventPair@12
@@ -128,7 +127,6 @@
NtImpersonateThread@12
NtInitializeRegistry@4
NtIsProcessInJob@8
-NtListenChannel@8
NtListenPort@8
NtLoadDriver@4
NtLoadKey@8
@@ -139,7 +137,6 @@
NtMapViewOfSection@40
NtNotifyChangeDirectoryFile@36
NtNotifyChangeKey@40
-NtOpenChannel@8
NtOpenDirectoryObject@12
NtOpenEvent@12
NtOpenEventPair@12
@@ -212,17 +209,14 @@
NtRemoveIoCompletion@20
NtReplaceKey@12
NtReplyPort@8
-NtReplyWaitReceivePort@16
NtReplyWaitReplyPort@8
-NtReplyWaitSendChannel@12
+NtReplyWaitReceivePort@16
NtRequestPort@8
NtRequestWaitReplyPort@12
NtResetEvent@8
NtRestoreKey@12
NtResumeThread@8
NtSaveKey@8
-NtSendWaitReplyChannel@16
-NtSetContextChannel@4
NtSetContextThread@8
NtSetDefaultHardErrorPort@4
NtSetDefaultLocale@8
@@ -704,7 +698,6 @@
ZwCompleteConnectPort@4
ZwConnectPort@32
ZwContinue@8
-ZwCreateChannel@8
ZwCreateDirectoryObject@12
ZwCreateEvent@20
ZwCreateEventPair@12
@@ -751,7 +744,6 @@
ZwImpersonateClientOfPort@8
ZwImpersonateThread@12
ZwInitializeRegistry@4
-ZwListenChannel@8
ZwListenPort@8
ZwLoadDriver@4
ZwLoadKey@8
@@ -762,7 +754,6 @@
ZwMapViewOfSection@40
ZwNotifyChangeDirectoryFile@36
ZwNotifyChangeKey@40
-ZwOpenChannel@8
ZwOpenDirectoryObject@12
ZwOpenEvent@12
ZwOpenEventPair@12
@@ -835,15 +826,12 @@
ZwReplyPort@8
ZwReplyWaitReceivePort@16
ZwReplyWaitReplyPort@8
-ZwReplyWaitSendChannel@12
ZwRequestPort@8
ZwRequestWaitReplyPort@12
ZwResetEvent@8
ZwRestoreKey@12
ZwResumeThread@8
ZwSaveKey@8
-ZwSendWaitReplyChannel@16
-ZwSetContextChannel@4
ZwSetContextThread@8
ZwSetDefaultHardErrorPort@4
ZwSetDefaultLocale@8
--- trunk/reactos/ntoskrnl/Makefile 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/ntoskrnl/Makefile 2005-01-07 06:54:27 UTC (rev 12861)
@@ -77,22 +77,6 @@
#
include Makefile.$(ARCH)
-# System API (Nt/Zw)
-OBJECTS_NT = \
- nt/channel.o \
- nt/efi.o \
- nt/evtpair.o \
- nt/mutant.o \
- nt/misc.o \
- nt/nt.o \
- nt/ntevent.o \
- nt/ntsem.o \
- nt/nttimer.o \
- nt/plugplay.o \
- nt/profile.o \
- nt/vdm.o \
- nt/zw.o
-
# Run-Time Library (Rtl)
OBJECTS_RTL = \
rtl/atom.o \
@@ -136,7 +120,8 @@
ke/sem.o \
ke/spinlock.o \
ke/timer.o \
- ke/wait.o
+ ke/wait.o \
+ ke/zw.o
# Memory Manager (Mm)
OBJECTS_MM = \
@@ -188,6 +173,7 @@
io/deviface.o \
io/dir.o \
io/driver.o \
+ io/efi.o \
io/errlog.o \
io/error.o \
io/event.o \
@@ -206,6 +192,7 @@
io/npipe.o \
io/page.o \
io/parttab.o \
+ io/plugplay.o \
io/process.o \
io/pnpnotify.o \
io/pnpdma.o \
@@ -259,20 +246,26 @@
OBJECTS_EX = \
ex/btree.o \
ex/callback.o \
+ ex/event.o \
+ ex/evtpair.o \
ex/fmutex.o \
ex/hashtab.o \
ex/init.o \
ex/interlck.o \
ex/list.o \
ex/lookas.o \
+ ex/mutant.o \
ex/napi.o \
ex/power.o \
+ ex/profile.o \
ex/resource.o \
ex/rundown.o \
ex/stree.o \
+ ex/sem.o \
ex/synch.o \
ex/sysinfo.o \
ex/time.o \
+ ex/timer.o \
ex/util.o \
ex/uuid.o \
ex/win32k.o \
@@ -371,7 +364,7 @@
OBJECTS_INBV = \
inbv/inbv.o
-DEP_OBJECTS := $(OBJECTS_NT) $(OBJECTS_MM) $(OBJECTS_ARCH) \
+DEP_OBJECTS := $(OBJECTS_MM) $(OBJECTS_ARCH) \
$(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \
$(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \
$(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \
@@ -475,12 +468,6 @@
-o $(OBJECTS_PATH)/lpc.o \
$(OBJECTS_LPC)
-$(OBJECTS_PATH)/nt.o: $(OBJECTS_NT)
- $(LD) \
- -r \
- -o $(OBJECTS_PATH)/nt.o \
- $(OBJECTS_NT)
-
$(OBJECTS_PATH)/po.o: $(OBJECTS_PO)
$(LD) \
-r \
@@ -519,7 +506,6 @@
$(OBJECTS_PATH)/kd.o \
$(OBJECTS_PATH)/ldr.o \
$(OBJECTS_PATH)/mm.o \
- $(OBJECTS_PATH)/nt.o \
$(OBJECTS_PATH)/ob.o \
$(OBJECTS_PATH)/po.o \
$(OBJECTS_PATH)/ps.o \
--- trunk/reactos/ntoskrnl/Makefile.i386 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/ntoskrnl/Makefile.i386 2005-01-07 06:54:27 UTC (rev 12861)
@@ -22,6 +22,7 @@
ke/i386/tskswitch.o \
ke/i386/v86m.o \
ke/i386/v86m_sup.o \
+ ke/i386/vdm.o \
ke/i386/bios.o \
ke/i386/i386-mcount.o \
ke/i386/gdt.o \
--- trunk/reactos/ntoskrnl/ex/event.c 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/ntoskrnl/ex/event.c 2005-01-07 06:54:27 UTC (rev 12861)
@@ -0,0 +1,370 @@
+/*
+ * ReactOS kernel
+ * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/nt/event.c
+ * PURPOSE: Named event support
+ * PROGRAMMER: Philip Susi and David Welch
+ * UPDATE HISTORY:
+ * Created 22/05/98
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+/* GLOBALS *******************************************************************/
+
+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};
+
+
+/* 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
+ExpInitializeEventImplementation(VOID)
+{
+ ExEventObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+
+ RtlCreateUnicodeString(&ExEventObjectType->TypeName, L"Event");
+
+ 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);
+}
+
+
+NTSTATUS STDCALL
+NtClearEvent(IN HANDLE EventHandle)
+{
+ PKEVENT Event;
+ NTSTATUS Status;
+
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ UserMode,
+ (PVOID*)&Event,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ KeClearEvent(Event);
+ ObDereferenceObject(Event);
+ return(STATUS_SUCCESS);
+}
+
+
+/*
+ * @implemented
+ */
+NTSTATUS STDCALL
+NtCreateEvent(OUT PHANDLE EventHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+ IN EVENT_TYPE EventType,
+ IN BOOLEAN InitialState)
+{
+ PKEVENT Event;
+ HANDLE hEvent;
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES SafeObjectAttributes;
+
+ if (ObjectAttributes != NULL)
+ {
+ Status = MmCopyFromCaller(&SafeObjectAttributes, ObjectAttributes,
+ sizeof(OBJECT_ATTRIBUTES));
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ ObjectAttributes = &SafeObjectAttributes;
+ }
+
+ Status = ObCreateObject(ExGetPreviousMode(),
+ ExEventObjectType,
+ ObjectAttributes,
+ ExGetPreviousMode(),
+ NULL,
+ sizeof(KEVENT),
+ 0,
+ 0,
+ (PVOID*)&Event);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ KeInitializeEvent(Event,
+ EventType,
+ InitialState);
+
+ Status = ObInsertObject ((PVOID)Event,
+ NULL,
+ DesiredAccess,
+ 0,
+ NULL,
+ &hEvent);
+ ObDereferenceObject(Event);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ Status = MmCopyToCaller(EventHandle, &hEvent, sizeof(HANDLE));
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(hEvent);
+ return(Status);
+ }
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtOpenEvent(OUT PHANDLE EventHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes)
+{
+ NTSTATUS Status;
+ HANDLE hEvent;
+
+ DPRINT("ObjectName '%wZ'\n", ObjectAttributes->ObjectName);
+
+ Status = ObOpenObjectByName(ObjectAttributes,
+ ExEventObjectType,
+ NULL,
+ UserMode,
+ DesiredAccess,
+ NULL,
+ &hEvent);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ Status = MmCopyToCaller(EventHandle, &hEvent, sizeof(HANDLE));
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(EventHandle);
+ return(Status);
+ }
+
+ return(Status);
+}
+
+
+NTSTATUS STDCALL
+NtPulseEvent(IN HANDLE EventHandle,
+ OUT PLONG PreviousState OPTIONAL)
+{
+ PKEVENT Event;
+ NTSTATUS Status;
+
+ DPRINT("NtPulseEvent(EventHandle %x PreviousState %x)\n",
+ EventHandle, PreviousState);
+
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ UserMode,
+ (PVOID*)&Event,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ KePulseEvent(Event, EVENT_INCREMENT, FALSE);
+
+ ObDereferenceObject(Event);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtQueryEvent(IN HANDLE EventHandle,
+ IN EVENT_INFORMATION_CLASS EventInformationClass,
+ OUT PVOID EventInformation,
+ IN ULONG EventInformationLength,
+ OUT PULONG ReturnLength OPTIONAL)
+{
+ EVENT_BASIC_INFORMATION Info;
+ PKEVENT Event;
+ NTSTATUS Status;
+ ULONG RetLen;
+
+ if (EventInformationClass > EventBasicInformation)
+ return STATUS_INVALID_INFO_CLASS;
+
+ if (EventInformationLength < sizeof(EVENT_BASIC_INFORMATION))
+ return STATUS_INFO_LENGTH_MISMATCH;
+
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_QUERY_STATE,
+ ExEventObjectType,
+ UserMode,
+ (PVOID*)&Event,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ if (Event->Header.Type == InternalNotificationEvent)
+ Info.EventType = NotificationEvent;
+ else
+ Info.EventType = SynchronizationEvent;
+ Info.EventState = KeReadStateEvent(Event);
+
+ Status = MmCopyToCaller(EventInformation, &Event,
+ sizeof(EVENT_BASIC_INFORMATION));
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(Event);
+ return(Status);
+ }
+
+ if (ReturnLength != NULL)
+ {
+ RetLen = sizeof(EVENT_BASIC_INFORMATION);
+ Status = MmCopyToCaller(ReturnLength, &RetLen, sizeof(ULONG));
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(Event);
+ return(Status);
+ }
+ }
+
+ ObDereferenceObject(Event);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtResetEvent(IN HANDLE EventHandle,
+ OUT PLONG PreviousState OPTIONAL)
+{
+ PKEVENT Event;
+ NTSTATUS Status;
+
+ DPRINT("NtResetEvent(EventHandle %x)\n", EventHandle);
+
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ UserMode,
+ (PVOID*)&Event,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ KeResetEvent(Event);
+ ObDereferenceObject(Event);
+ return(STATUS_SUCCESS);
+}
+
+
+/*
+ * @implemented
+ */
+NTSTATUS STDCALL
+NtSetEvent(IN HANDLE EventHandle,
+ OUT PLONG PreviousState OPTIONAL)
+{
+ PKEVENT Event;
+ NTSTATUS Status;
+
+ DPRINT("NtSetEvent(EventHandle %x)\n", EventHandle);
+
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ UserMode,
+ (PVOID*)&Event,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ KeSetEvent(Event,EVENT_INCREMENT,FALSE);
+ ObDereferenceObject(Event);
+ return(STATUS_SUCCESS);
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+STDCALL
+NtTraceEvent(
+ IN ULONG TraceHandle,
+ IN ULONG Flags,
+ IN ULONG TraceHeaderLength,
+ IN struct _EVENT_TRACE_HEADER* TraceHeader
+ )
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+/* EOF */
--- trunk/reactos/ntoskrnl/ex/evtpair.c 2005-01-07 01:03:34 UTC (rev 12860)
+++ trunk/reactos/ntoskrnl/ex/evtpair.c 2005-01-07 06:54:27 UTC (rev 12861)
@@ -0,0 +1,496 @@
+/* $Id: evtpair.c 12779 2005-01-04 04:45:00Z gdalsnes $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/ex/evtpair.c
+ * PURPOSE: Support for event pairs
+ * PROGRAMMER: David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ * Created 22/05/98
+ * Updated 09/08/2003 by Skywing (skywing@valhallalegends.com)
+ * to correctly maintain ownership of the dispatcher lock
+ * between KeSetEvent and KeWaitForSingleObject calls.
+ * Additionally, implemented the thread-eventpair routines.
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+#ifndef NTSYSAPI
+#define NTSYSAPI
+#endif
+
+#ifndef NTAPI
+#define NTAPI STDCALL
+#endif
+
+
+/* GLOBALS *******************************************************************/
+
+POBJECT_TYPE EXPORTED ExEventPairObjectType = NULL;
+
+static GENERIC_MAPPING ExEventPairMapping = {
+ STANDARD_RIGHTS_READ,
+ STANDARD_RIGHTS_WRITE,
+ STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
+ EVENT_PAIR_ALL_ACCESS};
+
+static KSPIN_LOCK ExThreadEventPairSpinLock;
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS STDCALL
+ExpCreateEventPair(PVOID ObjectBody,
+ PVOID Parent,
+ PWSTR RemainingPath,
+ POBJECT_ATTRIBUTES ObjectAttributes)
+{
+ DPRINT("ExpCreateEventPair(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
+ExpInitializeEventPairImplementation(VOID)
+{
+ ExEventPairObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+
+ RtlCreateUnicodeString(&ExEventPairObjectType->TypeName, L"EventPair");
+ ExEventPairObjectType->Tag = TAG('E', 'v', 'P', 'a');
+ ExEventPairObjectType->PeakObjects = 0;
+ ExEventPairObjectType->PeakHandles = 0;
+ ExEventPairObjectType->TotalObjects = 0;
+ ExEventPairObjectType->TotalHandles = 0;
+ ExEventPairObjectType->PagedPoolCharge = 0;
+ ExEventPairObjectType->NonpagedPoolCharge = sizeof(KEVENT_PAIR);
+ ExEventPairObjectType->Mapping = &ExEventPairMapping;
+ ExEventPairObjectType->Dump = NULL;
+ ExEventPairObjectType->Open = NULL;
+ ExEventPairObjectType->Close = NULL;
+ ExEventPairObjectType->Delete = NULL;
+ ExEventPairObjectType->Parse = NULL;
+ ExEventPairObjectType->Security = NULL;
+ ExEventPairObjectType->QueryName = NULL;
+ ExEventPairObjectType->OkayToClose = NULL;
+ ExEventPairObjectType->Create = ExpCreateEventPair;
+ ExEventPairObjectType->DuplicationNotify = NULL;
+
+ KeInitializeSpinLock(&ExThreadEventPairSpinLock);
+ ObpCreateTypeObject(ExEventPairObjectType);
+}
+
+
+NTSTATUS STDCALL
+NtCreateEventPair(OUT PHANDLE EventPairHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtCreateEventPair()\n");
+ Status = ObCreateObject(ExGetPreviousMode(),
+ ExEventPairObjectType,
+ ObjectAttributes,
+ ExGetPreviousMode(),
+ NULL,
+ sizeof(KEVENT_PAIR),
+ 0,
+ 0,
+ (PVOID*)&EventPair);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ KeInitializeEvent(&EventPair->LowEvent,
+ SynchronizationEvent,
+ FALSE);
+ KeInitializeEvent(&EventPair->HighEvent,
+ SynchronizationEvent,
+ FALSE);
+
+ Status = ObInsertObject ((PVOID)EventPair,
+ NULL,
+ DesiredAccess,
+ 0,
+ NULL,
+ EventPairHandle);
+
+ ObDereferenceObject(EventPair);
+
+ return Status;
+}
+
+
+NTSTATUS STDCALL
+NtOpenEventPair(OUT PHANDLE EventPairHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes)
+{
+ NTSTATUS Status;
+
+ DPRINT("NtOpenEventPair()\n");
+
+ Status = ObOpenObjectByName(ObjectAttributes,
+ ExEventPairObjectType,
+ NULL,
+ UserMode,
+ DesiredAccess,
+ NULL,
+ EventPairHandle);
+
+ return Status;
+}
+
+
+NTSTATUS STDCALL
+NtSetHighEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtSetHighEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeSetEvent(&EventPair->HighEvent,
+ EVENT_INCREMENT,
+ FALSE);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeSetEvent(&EventPair->HighEvent,
+ EVENT_INCREMENT,
+ TRUE);
+
+ KeWaitForSingleObject(&EventPair->LowEvent,
+ WrEventPair,
+ UserMode,
+ FALSE,
+ NULL);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtSetLowEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtSetLowEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeSetEvent(&EventPair->LowEvent,
+ EVENT_INCREMENT,
+ FALSE);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtSetLowWaitHighEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeSetEvent(&EventPair->LowEvent,
+ EVENT_INCREMENT,
+ TRUE);
+
+ KeWaitForSingleObject(&EventPair->HighEvent,
+ WrEventPair,
+ UserMode,
+ FALSE,
+ NULL);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtWaitLowEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtWaitLowEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeWaitForSingleObject(&EventPair->LowEvent,
+ WrEventPair,
+ UserMode,
+ FALSE,
+ NULL);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+NtWaitHighEventPair(IN HANDLE EventPairHandle)
+{
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+
+ DPRINT("NtWaitHighEventPair(EventPairHandle %x)\n",
+ EventPairHandle);
+
+ Status = ObReferenceObjectByHandle(EventPairHandle,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode,
+ (PVOID*)&EventPair,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return(Status);
+
+ KeWaitForSingleObject(&EventPair->HighEvent,
+ WrEventPair,
+ UserMode,
+ FALSE,
+ NULL);
+
+ ObDereferenceObject(EventPair);
+ return(STATUS_SUCCESS);
+}
+
+#ifdef _ENABLE_THRDEVTPAIR
+
+/*
+ * Author: Skywing (skywing@valhallalegends.com), 09/08/2003
+ * Note that the eventpair spinlock must be acquired when setting the thread
+ * eventpair via NtSetInformationThread.
+ * @implemented
+ */
+NTSTATUS
+NTSYSAPI
+NTAPI
+NtSetLowWaitHighThread(
+ VOID
+ )
+{
+ PETHREAD Thread;
+ PKEVENT_PAIR EventPair;
+ NTSTATUS Status;
+ KIRQL Irql;
+
+ Thread = PsGetCurrentThread();
+
+ if(!Thread->EventPair)
+ return STATUS_NO_EVENT_PAIR;
+
+ KeAcquireSpinLock(&ExThreadEventPairSpinLock, &Irql);
+
+ EventPair = Thread->EventPair;
+
+ if(EventPair)
+ ObReferenceObjectByPointer(EventPair,
+ EVENT_PAIR_ALL_ACCESS,
+ ExEventPairObjectType,
+ UserMode);
+
+ KeReleaseSpinLock(&ExThreadEventPairSpinLock, Irql);
[truncated at 1000 lines; 2285 more skipped]