- Fix some formatting.
Modified: trunk/reactos/ntoskrnl/ex/event.c
Modified: trunk/reactos/ntoskrnl/ex/evtpair.c

Modified: trunk/reactos/ntoskrnl/ex/event.c
--- trunk/reactos/ntoskrnl/ex/event.c	2005-12-29 17:57:11 UTC (rev 20427)
+++ trunk/reactos/ntoskrnl/ex/event.c	2005-12-29 18:03:24 UTC (rev 20428)
@@ -1,11 +1,10 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/nt/event.c
- * PURPOSE:         Named event support
- *
- * PROGRAMMERS:     Alex Ionescu(alex@relsoft.net) - Fixed bugs/commented
- *                  Philip Susi and David Welch
+ * PROJECT:         ReactOS Kernel
+ * FILE:            ntoskrnl/ex/event.c
+ * PURPOSE:         Event support
+ * PROGRAMMERS:     Alex Ionescu(alex@relsoft.net)
+ *                  Thomas Weidenmueller
  */
 
 /* INCLUDES *****************************************************************/
@@ -22,14 +21,15 @@
 
 POBJECT_TYPE ExEventObjectType = NULL;
 
-static GENERIC_MAPPING ExpEventMapping = {
+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};
 
-static const INFORMATION_CLASS_INFO ExEventInfoClass[] = {
-
+static const INFORMATION_CLASS_INFO ExEventInfoClass[] =
+{
     /* EventBasicInformation */
     ICI_SQ_SAME( sizeof(EVENT_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY),
 };
@@ -38,35 +38,33 @@
 
 VOID
 INIT_FUNCTION
-STDCALL
+NTAPI
 ExpInitializeEventImplementation(VOID)
 {
-  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
-  UNICODE_STRING Name;
+    OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
+    UNICODE_STRING Name;
+    DPRINT("Creating Event Object Type\n");
 
-  DPRINT("Creating Event Object Type\n");
-  
-  /* Create the Event Object Type */
-  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
-  RtlInitUnicodeString(&Name, L"Event");
-  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
-  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT);
-  ObjectTypeInitializer.GenericMapping = ExpEventMapping;
-  ObjectTypeInitializer.PoolType = NonPagedPool;
-  ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
-  ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventObjectType);
+    /* Create the Event Object Type */
+    RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
+    RtlInitUnicodeString(&Name, L"Event");
+    ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
+    ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT);
+    ObjectTypeInitializer.GenericMapping = ExpEventMapping;
+    ObjectTypeInitializer.PoolType = NonPagedPool;
+    ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventObjectType);
 }
 
 /*
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtClearEvent(IN HANDLE EventHandle)
 {
     PKEVENT Event;
     NTSTATUS Status;
-
     PAGED_CODE();
 
     /* Reference the Object */
@@ -78,8 +76,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Clear the Event and Dereference */
         KeClearEvent(Event);
         ObDereferenceObject(Event);
@@ -89,12 +87,11 @@
     return Status;
 }
 
-
 /*
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtCreateEvent(OUT PHANDLE EventHandle,
               IN ACCESS_MASK DesiredAccess,
               IN POBJECT_ATTRIBUTES ObjectAttributes  OPTIONAL,
@@ -105,22 +102,26 @@
     PKEVENT Event;
     HANDLE hEvent;
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
-    DPRINT("NtCreateEvent(0x%p, 0x%x, 0x%p)\n", EventHandle, DesiredAccess, ObjectAttributes);
+    DPRINT("NtCreateEvent(0x%p, 0x%x, 0x%p)\n",
+            EventHandle, DesiredAccess, ObjectAttributes);
 
-    /* Check Output Safety */
-    if(PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if(PreviousMode != KernelMode)
+    {
+        /* Enter SEH Block */
+        _SEH_TRY
+        {
+            /* Check handle pointer */
             ProbeForWriteHandle(EventHandle);
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -136,8 +137,8 @@
                             (PVOID*)&Event);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Initalize the Event */
         KeInitializeEvent(Event,
                           EventType,
@@ -153,17 +154,17 @@
         ObDereferenceObject(Event);
 
         /* Check for success and return handle */
-        if(NT_SUCCESS(Status)) {
-
-            _SEH_TRY {
-
+        if(NT_SUCCESS(Status))
+        {
+            _SEH_TRY
+            {
                 *EventHandle = hEvent;
-
-            } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+            }
+            _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+            {
                 Status = _SEH_GetExceptionCode();
-
-            } _SEH_END;
+            }
+            _SEH_END;
         }
     }
 
@@ -175,7 +176,7 @@
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtOpenEvent(OUT PHANDLE EventHandle,
             IN ACCESS_MASK DesiredAccess,
             IN POBJECT_ATTRIBUTES ObjectAttributes)
@@ -183,22 +184,26 @@
     HANDLE hEvent;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
-    DPRINT("NtOpenEvent(0x%p, 0x%x, 0x%p)\n", EventHandle, DesiredAccess, ObjectAttributes);
+    DPRINT("NtOpenEvent(0x%p, 0x%x, 0x%p)\n",
+            EventHandle, DesiredAccess, ObjectAttributes);
 
-    /* Check Output Safety */
-    if(PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if(PreviousMode != KernelMode)
+    {
+        /* Enter SEH Block */
+        _SEH_TRY
+        {
+            /* Check handle pointer */
             ProbeForWriteHandle(EventHandle);
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -211,18 +216,20 @@
                                 NULL,
                                 &hEvent);
 
-    /* Check for success and return handle */
-    if(NT_SUCCESS(Status)) {
-
-        _SEH_TRY {
-
+    /* Check for success */
+    if(NT_SUCCESS(Status))
+    {
+        /* Enter SEH for return */
+        _SEH_TRY
+        {
+            /* Return the handle to the caller */
             *EventHandle = hEvent;
-
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
-
-        } _SEH_END;
+        }
+        _SEH_END;
     }
 
     /* Return status */
@@ -233,30 +240,33 @@
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtPulseEvent(IN HANDLE EventHandle,
              OUT PLONG PreviousState OPTIONAL)
 {
     PKEVENT Event;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
     DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
             EventHandle, PreviousState);
 
-    /* Check buffer validity */
-    if(PreviousState && PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if((PreviousState) && (PreviousMode != KernelMode))
+    {
+        /* Entry SEH Block */
+        _SEH_TRY
+        {
+            /* Make sure the state pointer is valid */
             ProbeForWriteLong(PreviousState);
-         } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -269,24 +279,26 @@
                                        NULL);
 
     /* Check for success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Pulse the Event */
         LONG Prev = KePulseEvent(Event, EVENT_INCREMENT, FALSE);
         ObDereferenceObject(Event);
 
-        /* Return it */
-        if(PreviousState) {
-
-            _SEH_TRY {
-
+        /* Check if caller wants the old state back */
+        if(PreviousState)
+        {
+            /* Entry SEH Block for return */
+            _SEH_TRY
+            {
+                /* Return previous state */
                 *PreviousState = Prev;
-
-            } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+            }
+            _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+            {
                 Status = _SEH_GetExceptionCode();
-
-            } _SEH_END;
+            }
+            _SEH_END;
         }
    }
 
@@ -294,12 +306,11 @@
    return Status;
 }
 
-
 /*
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtQueryEvent(IN HANDLE EventHandle,
              IN EVENT_INFORMATION_CLASS EventInformationClass,
              OUT PVOID EventInformation,
@@ -310,7 +321,6 @@
     KPROCESSOR_MODE PreviousMode  = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
     PEVENT_BASIC_INFORMATION BasicInfo = (PEVENT_BASIC_INFORMATION)EventInformation;
-
     PAGED_CODE();
     DPRINT("NtQueryEvent(0x%p, 0x%x)\n", EventHandle, EventInformationClass);
 
@@ -322,8 +332,8 @@
                                          EventInformationLength,
                                          ReturnLength,
                                          PreviousMode);
-    if(!NT_SUCCESS(Status)) {
-
+    if(!NT_SUCCESS(Status))
+    {
         /* Invalid buffers */
         DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status);
         return Status;
@@ -338,23 +348,24 @@
                                        NULL);
 
     /* Check for success */
-    if(NT_SUCCESS(Status)) {
-
-        _SEH_TRY {
-
+    if(NT_SUCCESS(Status))
+    {
+        /* Entry SEH Block */
+        _SEH_TRY
+        {
             /* Return Event Type and State */
             BasicInfo->EventType = Event->Header.Type;
             BasicInfo->EventState = KeReadStateEvent(Event);
 
             /* Return length */
             if(ReturnLength) *ReturnLength = sizeof(EVENT_BASIC_INFORMATION);
-
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
         /* Dereference the Object */
         ObDereferenceObject(Event);
    }
@@ -367,30 +378,33 @@
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtResetEvent(IN HANDLE EventHandle,
              OUT PLONG PreviousState OPTIONAL)
 {
     PKEVENT Event;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
     DPRINT("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n",
             EventHandle, PreviousState);
 
-    /* Check buffer validity */
-    if(PreviousState && PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if((PreviousState) && (PreviousMode != KernelMode))
+    {
+        /* Entry SEH Block */
+        _SEH_TRY
+        {
+            /* Make sure the state pointer is valid */
             ProbeForWriteLong(PreviousState);
-         } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -403,24 +417,26 @@
                                        NULL);
 
     /* Check for success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Reset the Event */
         LONG Prev = KeResetEvent(Event);
         ObDereferenceObject(Event);
 
-        /* Return it */
-        if(PreviousState) {
-
-            _SEH_TRY {
-
+        /* Check if caller wants the old state back */
+        if(PreviousState)
+        {
+            /* Entry SEH Block for return */
+            _SEH_TRY
+            {
+                /* Return previous state */
                 *PreviousState = Prev;
-
-            } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+            }
+            _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+            {
                 Status = _SEH_GetExceptionCode();
-
-            } _SEH_END;
+            }
+            _SEH_END;
         }
    }
 
@@ -432,30 +448,33 @@
  * @implemented
  */
 NTSTATUS
-STDCALL
+NTAPI
 NtSetEvent(IN HANDLE EventHandle,
            OUT PLONG PreviousState  OPTIONAL)
 {
     PKEVENT Event;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
     DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
            EventHandle, PreviousState);
 
-    /* Check buffer validity */
-    if(PreviousState != NULL && PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if((PreviousState) && (PreviousMode != KernelMode))
+    {
+        /* Entry SEH Block */
+        _SEH_TRY
+        {
+            /* Make sure the state pointer is valid */
             ProbeForWriteLong(PreviousState);
-         } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -468,24 +487,26 @@
                                        NULL);
 
     /* Check for success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Set the Event */
         LONG Prev = KeSetEvent(Event, EVENT_INCREMENT, FALSE);
         ObDereferenceObject(Event);
 
-        /* Return it */
-        if(PreviousState) {
-
-            _SEH_TRY {
-
+        /* Check if caller wants the old state back */
+        if(PreviousState)
+        {
+            /* Entry SEH Block for return */
+            _SEH_TRY
+            {
+                /* Return previous state */
                 *PreviousState = Prev;
-
-            } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+            }
+            _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+            {
                 Status = _SEH_GetExceptionCode();
-
-            } _SEH_END;
+            }
+            _SEH_END;
         }
    }
 

Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
--- trunk/reactos/ntoskrnl/ex/evtpair.c	2005-12-29 17:57:11 UTC (rev 20427)
+++ trunk/reactos/ntoskrnl/ex/evtpair.c	2005-12-29 18:03:24 UTC (rev 20428)
@@ -1,13 +1,10 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
+ * PROJECT:         ReactOS Kernel
  * FILE:            ntoskrnl/ex/evtpair.c
  * PURPOSE:         Support for event pairs
- *
- * PROGRAMMERS:     Alex Ionescu (Commented, reorganized, removed Thread Pair, used
- *                                KeInitializeEventPair, added SEH)
- *                  David Welch (welch@mcmail.com)
- *                  Skywing (skywing@valhallalegends.com)
+ * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
+ *                  Thomas Weidenmueller
  */
 
 /* INCLUDES *****************************************************************/
@@ -24,39 +21,39 @@
 
 POBJECT_TYPE ExEventPairObjectType = NULL;
 
-static GENERIC_MAPPING ExEventPairMapping = {
+GENERIC_MAPPING ExEventPairMapping =
+{
     STANDARD_RIGHTS_READ,
     STANDARD_RIGHTS_WRITE,
     STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
-    EVENT_PAIR_ALL_ACCESS};
+    EVENT_PAIR_ALL_ACCESS
+};
 
-
 /* FUNCTIONS *****************************************************************/
 
 VOID
 INIT_FUNCTION
-STDCALL
+NTAPI
 ExpInitializeEventPairImplementation(VOID)
 {
-  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
-  UNICODE_STRING Name;
+    OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
+    UNICODE_STRING Name;
+    DPRINT("Creating Event Pair Object Type\n");
 
-  DPRINT("Creating Event Pair Object Type\n");
-  
-  /* Create the Event Pair Object Type */
-  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
-  RtlInitUnicodeString(&Name, L"EventPair");
-  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
-  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
-  ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
-  ObjectTypeInitializer.PoolType = NonPagedPool;
-  ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
-  ObjectTypeInitializer.UseDefaultObject = TRUE;
-  ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventPairObjectType);
+    /* Create the Event Pair Object Type */
+    RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
+    RtlInitUnicodeString(&Name, L"EventPair");
+    ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
+    ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
+    ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
+    ObjectTypeInitializer.PoolType = NonPagedPool;
+    ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
+    ObjectTypeInitializer.UseDefaultObject = TRUE;
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventPairObjectType);
 }
 
 NTSTATUS
-STDCALL
+NTAPI
 NtCreateEventPair(OUT PHANDLE EventPairHandle,
                   IN ACCESS_MASK DesiredAccess,
                   IN POBJECT_ATTRIBUTES ObjectAttributes)
@@ -65,22 +62,25 @@
     HANDLE hEventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
     DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
 
-    /* Check Output Safety */
-    if(PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if(PreviousMode != KernelMode)
+    {
+        /* Enter SEH Block */
+        _SEH_TRY
+        {
+            /* Check handle pointer */
             ProbeForWriteHandle(EventPairHandle);
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -97,8 +97,8 @@
                             (PVOID*)&EventPair);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Initalize the Event */
         DPRINT("Initializing EventPair\n");
         KeInitializeEventPair(EventPair);
@@ -113,17 +113,17 @@
         ObDereferenceObject(EventPair);
 
         /* Check for success and return handle */
-        if(NT_SUCCESS(Status)) {
-
-            _SEH_TRY {
-
+        if(NT_SUCCESS(Status))
+        {
+            _SEH_TRY
+            {
                 *EventPairHandle = hEventPair;
-
-            } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+            }
+            _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+            {
                 Status = _SEH_GetExceptionCode();
-
-            } _SEH_END;
+            }
+            _SEH_END;
         }
     }
 
@@ -132,7 +132,7 @@
 }
 
 NTSTATUS
-STDCALL
+NTAPI
 NtOpenEventPair(OUT PHANDLE EventPairHandle,
                 IN ACCESS_MASK DesiredAccess,
                 IN POBJECT_ATTRIBUTES ObjectAttributes)
@@ -140,21 +140,24 @@
     HANDLE hEventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status = STATUS_SUCCESS;
-
     PAGED_CODE();
 
-    /* Check Output Safety */
-    if(PreviousMode != KernelMode) {
-
-        _SEH_TRY {
-
+    /* Check if we were called from user-mode */
+    if(PreviousMode != KernelMode)
+    {
+        /* Enter SEH Block */
+        _SEH_TRY
+        {
+            /* Check handle pointer */
             ProbeForWriteHandle(EventPairHandle);
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
 
-        } _SEH_END;
-
+        /* Bail out if pointer was invalid */
         if(!NT_SUCCESS(Status)) return Status;
     }
 
@@ -168,32 +171,30 @@
                                 &hEventPair);
 
     /* Check for success and return handle */
-    if(NT_SUCCESS(Status)) {
-
-        _SEH_TRY {
-
+    if(NT_SUCCESS(Status))
+    {
+        _SEH_TRY
+        {
             *EventPairHandle = hEventPair;
-
-        } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
-
+        }
+        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        {
             Status = _SEH_GetExceptionCode();
-
-        } _SEH_END;
+        }
+        _SEH_END;
     }
 
     /* Return status */
     return Status;
 }
 
-
 NTSTATUS
-STDCALL
+NTAPI
 NtSetHighEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status;
-
     PAGED_CODE();
     DPRINT("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
 
@@ -206,8 +207,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Set the Event */
         KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE);
 
@@ -220,15 +221,14 @@
 }
 
 NTSTATUS
-STDCALL
+NTAPI
 NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status;
-
     PAGED_CODE();
-    DPRINT("NtSetHighWaitLowEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
+    DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
 
     /* Open the Object */
     Status = ObReferenceObjectByHandle(EventPairHandle,
@@ -239,8 +239,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Set the Event */
         KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE);
 
@@ -260,17 +260,13 @@
 }
 
 NTSTATUS
-STDCALL
+NTAPI
 NtSetLowEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
-    KPROCESSOR_MODE PreviousMode;
+    KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status;
-
     PAGED_CODE();
-
-    PreviousMode = ExGetPreviousMode();
-
     DPRINT1("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
 
     /* Open the Object */
@@ -282,8 +278,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Set the Event */
         KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE);
 
@@ -295,16 +291,15 @@
     return Status;
 }
 
-
-NTSTATUS STDCALL
+NTSTATUS
+NTAPI
 NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status;
-
     PAGED_CODE();
-    DPRINT("NtSetHighWaitLowEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
+    DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
 
     /* Open the Object */
     Status = ObReferenceObjectByHandle(EventPairHandle,
@@ -315,8 +310,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Set the Event */
         KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE);
 
@@ -337,15 +332,14 @@
 
 
 NTSTATUS
-STDCALL
+NTAPI
 NtWaitLowEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     NTSTATUS Status;
-
     PAGED_CODE();
-    DPRINT("NtSetHighWaitLowEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
+    DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
 
     /* Open the Object */
     Status = ObReferenceObjectByHandle(EventPairHandle,
@@ -356,8 +350,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Wait for the Event */
         KeWaitForSingleObject(&EventPair->LowEvent,
                               WrEventPair,
@@ -374,7 +368,7 @@
 }
 
 NTSTATUS
-STDCALL
+NTAPI
 NtWaitHighEventPair(IN HANDLE EventPairHandle)
 {
     PKEVENT_PAIR EventPair;
@@ -382,7 +376,7 @@
     NTSTATUS Status;
 
     PAGED_CODE();
-    DPRINT("NtSetHighWaitLowEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
+    DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
 
     /* Open the Object */
     Status = ObReferenceObjectByHandle(EventPairHandle,
@@ -393,8 +387,8 @@
                                        NULL);
 
     /* Check for Success */
-    if(NT_SUCCESS(Status)) {
-
+    if(NT_SUCCESS(Status))
+    {
         /* Wait for the Event */
         KeWaitForSingleObject(&EventPair->HighEvent,
                               WrEventPair,