1*c2c66affSColin Finck /*
2*c2c66affSColin Finck * PROJECT: ReactOS Kernel
3*c2c66affSColin Finck * LICENSE: GPL - See COPYING in the top level directory
4*c2c66affSColin Finck * FILE: ntoskrnl/io/iomgr/ioevent.c
5*c2c66affSColin Finck * PURPOSE: I/O Wrappers for the Executive Event Functions
6*c2c66affSColin Finck * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7*c2c66affSColin Finck * Eric Kohl
8*c2c66affSColin Finck */
9*c2c66affSColin Finck
10*c2c66affSColin Finck /* INCLUDES *****************************************************************/
11*c2c66affSColin Finck
12*c2c66affSColin Finck #include <ntoskrnl.h>
13*c2c66affSColin Finck #include <debug.h>
14*c2c66affSColin Finck
15*c2c66affSColin Finck /* PRIVATE FUNCTIONS *********************************************************/
16*c2c66affSColin Finck
17*c2c66affSColin Finck PKEVENT
18*c2c66affSColin Finck NTAPI
IopCreateEvent(IN PUNICODE_STRING EventName,IN PHANDLE EventHandle,IN EVENT_TYPE Type)19*c2c66affSColin Finck IopCreateEvent(IN PUNICODE_STRING EventName,
20*c2c66affSColin Finck IN PHANDLE EventHandle,
21*c2c66affSColin Finck IN EVENT_TYPE Type)
22*c2c66affSColin Finck {
23*c2c66affSColin Finck OBJECT_ATTRIBUTES ObjectAttributes;
24*c2c66affSColin Finck PKEVENT Event;
25*c2c66affSColin Finck HANDLE Handle;
26*c2c66affSColin Finck NTSTATUS Status;
27*c2c66affSColin Finck PAGED_CODE();
28*c2c66affSColin Finck
29*c2c66affSColin Finck /* Initialize the object attributes */
30*c2c66affSColin Finck InitializeObjectAttributes(&ObjectAttributes,
31*c2c66affSColin Finck EventName,
32*c2c66affSColin Finck OBJ_OPENIF | OBJ_KERNEL_HANDLE,
33*c2c66affSColin Finck NULL,
34*c2c66affSColin Finck NULL);
35*c2c66affSColin Finck
36*c2c66affSColin Finck /* Create the event */
37*c2c66affSColin Finck Status = ZwCreateEvent(&Handle,
38*c2c66affSColin Finck EVENT_ALL_ACCESS,
39*c2c66affSColin Finck &ObjectAttributes,
40*c2c66affSColin Finck Type,
41*c2c66affSColin Finck TRUE);
42*c2c66affSColin Finck if (!NT_SUCCESS(Status)) return NULL;
43*c2c66affSColin Finck
44*c2c66affSColin Finck /* Get a handle to it */
45*c2c66affSColin Finck Status = ObReferenceObjectByHandle(Handle,
46*c2c66affSColin Finck 0,
47*c2c66affSColin Finck ExEventObjectType,
48*c2c66affSColin Finck KernelMode,
49*c2c66affSColin Finck (PVOID*)&Event,
50*c2c66affSColin Finck NULL);
51*c2c66affSColin Finck if (!NT_SUCCESS(Status))
52*c2c66affSColin Finck {
53*c2c66affSColin Finck ZwClose(Handle);
54*c2c66affSColin Finck return NULL;
55*c2c66affSColin Finck }
56*c2c66affSColin Finck
57*c2c66affSColin Finck /* Dereference the extra count, and return the handle */
58*c2c66affSColin Finck ObDereferenceObject(Event);
59*c2c66affSColin Finck *EventHandle = Handle;
60*c2c66affSColin Finck return Event;
61*c2c66affSColin Finck }
62*c2c66affSColin Finck
63*c2c66affSColin Finck /* PUBLIC FUNCTIONS **********************************************************/
64*c2c66affSColin Finck
65*c2c66affSColin Finck /*
66*c2c66affSColin Finck * @implemented
67*c2c66affSColin Finck */
68*c2c66affSColin Finck PKEVENT
69*c2c66affSColin Finck NTAPI
IoCreateNotificationEvent(IN PUNICODE_STRING EventName,IN PHANDLE EventHandle)70*c2c66affSColin Finck IoCreateNotificationEvent(IN PUNICODE_STRING EventName,
71*c2c66affSColin Finck IN PHANDLE EventHandle)
72*c2c66affSColin Finck {
73*c2c66affSColin Finck /* Call the internal API */
74*c2c66affSColin Finck return IopCreateEvent(EventName, EventHandle, NotificationEvent);
75*c2c66affSColin Finck }
76*c2c66affSColin Finck
77*c2c66affSColin Finck /*
78*c2c66affSColin Finck * @implemented
79*c2c66affSColin Finck */
80*c2c66affSColin Finck PKEVENT
81*c2c66affSColin Finck NTAPI
IoCreateSynchronizationEvent(IN PUNICODE_STRING EventName,IN PHANDLE EventHandle)82*c2c66affSColin Finck IoCreateSynchronizationEvent(IN PUNICODE_STRING EventName,
83*c2c66affSColin Finck IN PHANDLE EventHandle)
84*c2c66affSColin Finck {
85*c2c66affSColin Finck /* Call the internal API */
86*c2c66affSColin Finck return IopCreateEvent(EventName, EventHandle, SynchronizationEvent);
87*c2c66affSColin Finck }
88*c2c66affSColin Finck
89*c2c66affSColin Finck /* EOF */
90