update for HEAD-2003091401
[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 /*
22  * @implemented
23  */
24 PKEVENT STDCALL
25 IoCreateNotificationEvent(PUNICODE_STRING EventName,
26                           PHANDLE EventHandle)
27 {
28    OBJECT_ATTRIBUTES ObjectAttributes;
29    PKEVENT Event;
30    HANDLE Handle;
31    NTSTATUS Status;
32
33    InitializeObjectAttributes(&ObjectAttributes,
34                               EventName,
35                               OBJ_OPENIF,
36                               NULL,
37                               NULL);
38
39    Status = NtCreateEvent(&Handle,
40                           EVENT_ALL_ACCESS,
41                           &ObjectAttributes,
42                           FALSE,
43                           TRUE);
44    if (!NT_SUCCESS(Status))
45      {
46         return NULL;
47      }
48
49    ObReferenceObjectByHandle(Handle,
50                              0,
51                              ExEventObjectType,
52                              KernelMode,
53                              (PVOID*)&Event,
54                              NULL);
55    ObDereferenceObject(Event);
56
57    *EventHandle = Handle;
58
59    return Event;
60 }
61
62 /*
63  * @implemented
64  */
65 PKEVENT STDCALL
66 IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
67                              PHANDLE EventHandle)
68 {
69    OBJECT_ATTRIBUTES ObjectAttributes;
70    PKEVENT Event;
71    HANDLE Handle;
72    NTSTATUS Status;
73
74    InitializeObjectAttributes(&ObjectAttributes,
75                               EventName,
76                               OBJ_OPENIF,
77                               NULL,
78                               NULL);
79
80    Status = NtCreateEvent(&Handle,
81                           EVENT_ALL_ACCESS,
82                           &ObjectAttributes,
83                           TRUE,
84                           TRUE);
85    if (!NT_SUCCESS(Status))
86      {
87         return NULL;
88      }
89
90    ObReferenceObjectByHandle(Handle,
91                              0,
92                              ExEventObjectType,
93                              KernelMode,
94                              (PVOID*)&Event,
95                              NULL);
96    ObDereferenceObject(Event);
97
98    *EventHandle = Handle;
99
100    return Event;
101 }
102
103 /* EOF */