branch update for HEAD-2003021201
[reactos.git] / ntoskrnl / io / event.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            ntoskrnl/io/event.c
6  * PURPOSE:         Implements named events
7  * PROGRAMMER:      David Welch (welch@mcmail.com)
8  * UPDATE HISTORY:
9  *                  Created 22/05/98
10  */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <ntos.h>
16
17 #include <internal/debug.h>
18
19 /* FUNCTIONS *****************************************************************/
20
21 PKEVENT STDCALL
22 IoCreateNotificationEvent(PUNICODE_STRING EventName,
23                           PHANDLE EventHandle)
24 {
25    OBJECT_ATTRIBUTES ObjectAttributes;
26    PKEVENT Event;
27    HANDLE Handle;
28    NTSTATUS Status;
29
30    InitializeObjectAttributes(&ObjectAttributes,
31                               EventName,
32                               OBJ_OPENIF,
33                               NULL,
34                               NULL);
35
36    Status = NtCreateEvent(&Handle,
37                           EVENT_ALL_ACCESS,
38                           &ObjectAttributes,
39                           FALSE,
40                           TRUE);
41    if (!NT_SUCCESS(Status))
42      {
43         return NULL;
44      }
45
46    ObReferenceObjectByHandle(Handle,
47                              0,
48                              ExEventObjectType,
49                              KernelMode,
50                              (PVOID*)&Event,
51                              NULL);
52    ObDereferenceObject(Event);
53
54    *EventHandle = Handle;
55
56    return Event;
57 }
58
59 PKEVENT STDCALL
60 IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
61                              PHANDLE EventHandle)
62 {
63    OBJECT_ATTRIBUTES ObjectAttributes;
64    PKEVENT Event;
65    HANDLE Handle;
66    NTSTATUS Status;
67
68    InitializeObjectAttributes(&ObjectAttributes,
69                               EventName,
70                               OBJ_OPENIF,
71                               NULL,
72                               NULL);
73
74    Status = NtCreateEvent(&Handle,
75                           EVENT_ALL_ACCESS,
76                           &ObjectAttributes,
77                           TRUE,
78                           TRUE);
79    if (!NT_SUCCESS(Status))
80      {
81         return NULL;
82      }
83
84    ObReferenceObjectByHandle(Handle,
85                              0,
86                              ExEventObjectType,
87                              KernelMode,
88                              (PVOID*)&Event,
89                              NULL);
90    ObDereferenceObject(Event);
91
92    *EventHandle = Handle;
93
94    return Event;
95 }
96
97 /* EOF */