--- trunk/reactos/ntoskrnl/ex/event.c 2005-03-14 01:47:18 UTC (rev 14044)
+++ trunk/reactos/ntoskrnl/ex/event.c 2005-03-14 02:08:17 UTC (rev 14045)
@@ -1,11 +1,11 @@
-/* $Id:$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/nt/event.c
* PURPOSE: Named event support
*
- * PROGRAMMERS: Philip Susi and David Welch
+ * PROGRAMMERS: Alex Ionescu(alex@relsoft.net) - Fixed bugs/commented
+ * Philip Susi and David Welch
*/
/* INCLUDES *****************************************************************/
@@ -19,300 +19,287 @@
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));
+ RtlInitUnicodeString(&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 = 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);
- Status = ObReferenceObjectByHandle(EventHandle,
- EVENT_MODIFY_STATE,
- ExEventObjectType,
- ExGetPreviousMode(),
- (PVOID*)&Event,
- NULL);
- if(NT_SUCCESS(Status))
- {
- KeClearEvent(Event);
- ObDereferenceObject(Event);
- }
+ /* Check for Success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Clear the Event and Dereference */
+ KeClearEvent(Event);
+ ObDereferenceObject(Event);
+ }
- return Status;
+ /* 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();
+ DPRINT("NtCreateEvent(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 != KernelMode) {
+
+ _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 != KernelMode) {
+
+ _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 +307,203 @@
/*
* @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;
+ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+ NTSTATUS Status = STATUS_SUCCESS;
+ PEVENT_BASIC_INFORMATION BasicInfo = (PEVENT_BASIC_INFORMATION)EventInformation;
+
+ PAGED_CODE();
+ DPRINT("NtQueryEvent(0x%x, 0x%x, 0x%x)\n", EventHandle, EventInformationClass);
+
+ /* Check buffers and class validity */
+ DefaultQueryInfoBufferCheck(EventInformationClass,
+ ExEventInfoClass,
+ EventInformation,
+ EventInformationLength,
+ ReturnLength,
+ PreviousMode,
+ &Status);
+ if(!NT_SUCCESS(Status)) {
+
+ /* Invalid buffers */
+ DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status);
+ return Status;
+ }
- PAGED_CODE();
+ /* Get the Object */
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_QUERY_STATE,
+ ExEventObjectType,
+ PreviousMode,
+ (PVOID*)&Event,
+ NULL);
+
+ /* Check for success */
+ if(NT_SUCCESS(Status)) {
- PreviousMode = ExGetPreviousMode();
-
- DefaultQueryInfoBufferCheck(EventInformationClass,
- ExEventInfoClass,
- EventInformation,
- EventInformationLength,
- ReturnLength,
- PreviousMode,
- &Status);
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("NtQueryEvent() failed, Status: 0x%x\n", Status);
- return Status;
- }
+ _SEH_TRY {
+
+ /* Return Event Type and State */
+ BasicInfo->EventType = Event->Header.Type;
+ BasicInfo->EventState = KeReadStateEvent(Event);
- Status = ObReferenceObjectByHandle(EventHandle,
- EVENT_QUERY_STATE,
- ExEventObjectType,
- PreviousMode,
- (PVOID*)&Event,
- NULL);
- if(NT_SUCCESS(Status))
- {
- switch(EventInformationClass)
- {
- case EventBasicInformation:
- {
- PEVENT_BASIC_INFORMATION BasicInfo = (PEVENT_BASIC_INFORMATION)EventInformation;
-
- _SEH_TRY
- {
- if (Event->Header.Type == InternalNotificationEvent)
- BasicInfo->EventType = NotificationEvent;
- else
- BasicInfo->EventType = SynchronizationEvent;
- BasicInfo->EventState = KeReadStateEvent(Event);
-
- if(ReturnLength != NULL)
- {
- *ReturnLength = sizeof(EVENT_BASIC_INFORMATION);
- }
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- break;
- }
-
- default:
- Status = STATUS_NOT_IMPLEMENTED;
- break;
- }
-
- ObDereferenceObject(Event);
+ /* Return length */
+ if(ReturnLength) *ReturnLength = sizeof(EVENT_BASIC_INFORMATION);
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+
+ /* Dereference the Object */
+ ObDereferenceObject(Event);
}
+ /* Return status */
return Status;
}
-
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtResetEvent(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("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n",
+ EventHandle, PreviousState);
- DPRINT("NtResetEvent(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(!NT_SUCCESS(Status)) return Status;
+ }
- if(PreviousState != NULL && PreviousMode == UserMode)
- {
- _SEH_TRY
- {
- ProbeForWrite(PreviousState,
- sizeof(LONG),
- sizeof(ULONG));
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
+ /* Open the Object */
+ Status = ObReferenceObjectByHandle(EventHandle,
+ EVENT_MODIFY_STATE,
+ ExEventObjectType,
+ PreviousMode,
+ (PVOID*)&Event,
+ NULL);
+
+ /* Check for success */
+ if(NT_SUCCESS(Status)) {
+
+ /* Reset the Event */
+ LONG Prev = KeResetEvent(Event);
+ 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 = KeResetEvent(Event);
- ObDereferenceObject(Event);
-
- if(PreviousState != NULL)
- {
- _SEH_TRY
- {
- *PreviousState = Prev;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
- }
-
+ /* Return Status */
return Status;
}
-
/*
* @implemented
*/
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
NtSetEvent(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("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
+ EventHandle, PreviousState);
- DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
- EventHandle, PreviousState);
+ /* Check buffer validity */
+ if(PreviousState != NULL && PreviousMode == UserMode) {
+
+ _SEH_TRY {
+
+ ProbeForWrite(PreviousState,
+ sizeof(LONG),
+ sizeof(ULONG));
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
- PreviousMode = ExGetPreviousMode();
+ if(!NT_SUCCESS(Status)) return Status;
+ }
- 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)) {
- Status = ObReferenceObjectByHandle(EventHandle,
- EVENT_MODIFY_STATE,
- ExEventObjectType,
- PreviousMode,
- (PVOID*)&Event,
- NULL);
- if(NT_SUCCESS(Status))
- {
- LONG Prev = KeSetEvent(Event, EVENT_INCREMENT, FALSE);
- ObDereferenceObject(Event);
+ /* Set the Event */
+ LONG Prev = KeSetEvent(Event, EVENT_INCREMENT, FALSE);
+ ObDereferenceObject(Event);
- if(PreviousState != NULL)
- {
- _SEH_TRY
- {
- *PreviousState = Prev;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
+ /* Return it */
+ if(PreviousState) {
+
+ _SEH_TRY {
+
+ *PreviousState = Prev;
+
+ } _SEH_HANDLE {
+
+ Status = _SEH_GetExceptionCode();
+
+ } _SEH_END;
+ }
}
+ /* Return Status */
return Status;
}
-
-/*
- * @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 */