Fix splitting of cells (noticed by Hartmut).
[reactos.git] / reactos / 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 *
8 * PROGRAMMERS: David Welch (welch@mcmail.com)
9 */
10
11 /* INCLUDES *****************************************************************/
12
13 #include <ntoskrnl.h>
14 #include <internal/debug.h>
15
16 /* FUNCTIONS *****************************************************************/
17
18 /*
19 * @implemented
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 = ZwCreateEvent(&Handle,
37 EVENT_ALL_ACCESS,
38 &ObjectAttributes,
39 NotificationEvent,
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 /*
60 * @implemented
61 */
62 PKEVENT STDCALL
63 IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
64 PHANDLE EventHandle)
65 {
66 OBJECT_ATTRIBUTES ObjectAttributes;
67 KPROCESSOR_MODE PreviousMode;
68 PKEVENT Event;
69 HANDLE Handle;
70 NTSTATUS Status;
71
72 PreviousMode = ExGetPreviousMode();
73
74 InitializeObjectAttributes(&ObjectAttributes,
75 EventName,
76 OBJ_OPENIF,
77 NULL,
78 NULL);
79
80 Status = ZwCreateEvent(&Handle,
81 EVENT_ALL_ACCESS,
82 &ObjectAttributes,
83 SynchronizationEvent,
84 TRUE);
85
86 if (!NT_SUCCESS(Status))
87 {
88 return NULL;
89 }
90
91 ObReferenceObjectByHandle(Handle,
92 0,
93 ExEventObjectType,
94 KernelMode,
95 (PVOID*)&Event,
96 NULL);
97 ObDereferenceObject(Event);
98
99 *EventHandle = Handle;
100
101 return Event;
102 }
103
104 /* EOF */