2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Event creation test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
11 #define KERNEL_HANDLE_FLAG 0xFFFFFFFF80000000ULL
13 #define KERNEL_HANDLE_FLAG 0x80000000
16 #define CheckEventObject(Handle, Pointers, Handles) do \
18 PUBLIC_OBJECT_BASIC_INFORMATION ObjectInfo; \
19 Status = ZwQueryObject(Handle, ObjectBasicInformation, \
20 &ObjectInfo, sizeof ObjectInfo, NULL); \
21 ok_eq_hex(Status, STATUS_SUCCESS); \
22 ok_eq_ulong(ObjectInfo.PointerCount, Pointers); \
23 ok_eq_ulong(ObjectInfo.HandleCount, Handles); \
24 ok_eq_ulong(ObjectInfo.Attributes, 0); \
25 ok_eq_ulong(ObjectInfo.GrantedAccess, EVENT_ALL_ACCESS); \
26 ok(((ULONG_PTR)Handle & KERNEL_HANDLE_FLAG) == KERNEL_HANDLE_FLAG, \
27 "Handle %p is not a kernel handle\n", Handle); \
33 PRKEVENT (NTAPI
*CreateEvent
)(PUNICODE_STRING
, PHANDLE
),
34 PUNICODE_STRING EventName
,
38 PKEVENT Event
, Event2
;
39 HANDLE EventHandle
, EventHandle2
;
44 Event
= CreateEvent(NULL
, &EventHandle
);
45 ok(Event
!= NULL
, "Event is NULL\n");
46 ok(EventHandle
!= NULL
, "EventHandle is NULL\n");
47 if (!skip(EventHandle
!= NULL
, "No event\n"))
49 ok_eq_uint(Event
->Header
.Type
, Type
);
50 State
= KeReadStateEvent(Event
);
51 ok_eq_long(State
, 1L);
52 CheckEventObject(EventHandle
, 2UL, 1UL);
53 Status
= ZwClose(EventHandle
);
54 ok_eq_hex(Status
, STATUS_SUCCESS
);
56 KmtEndSeh(STATUS_SUCCESS
);
60 Event
= CreateEvent(EventName
, &EventHandle
);
61 ok(Event
!= NULL
, "Event is NULL\n");
62 ok(EventHandle
!= NULL
, "EventHandle is NULL\n");
63 if (!skip(EventHandle
!= NULL
, "No event\n"))
65 ok_eq_uint(Event
->Header
.Type
, Type
);
66 State
= KeReadStateEvent(Event
);
67 ok_eq_long(State
, 1L);
68 CheckEventObject(EventHandle
, 3UL, 1UL);
70 /* Open the existing one */
72 Event2
= CreateEvent(EventName
, &EventHandle2
);
73 CheckEventObject(EventHandle
, 4UL, 2UL);
74 ok(Event2
!= NULL
, "Event is NULL\n");
75 ok(EventHandle2
!= NULL
, "EventHandle is NULL\n");
76 if (!skip(EventHandle2
!= NULL
, "No event\n"))
78 CheckEventObject(EventHandle2
, 4UL, 2UL);
79 ZwClose(EventHandle2
);
82 CheckEventObject(EventHandle
, 3UL, 1UL);
83 Status
= ZwClose(EventHandle
);
84 ok_eq_hex(Status
, STATUS_SUCCESS
);
90 PKEVENT Event
, Event2
;
91 HANDLE EventHandle
= NULL
, EventHandle2
= NULL
;
92 UNICODE_STRING NotificationEventName
= RTL_CONSTANT_STRING(L
"\\BaseNamedObjects\\KmTestIoEventNotificationEvent");
93 UNICODE_STRING SynchronizationEventName
= RTL_CONSTANT_STRING(L
"\\BaseNamedObjects\\KmTestIoEventSynchronizationEvent");
95 TestCreateEvent(IoCreateNotificationEvent
, &NotificationEventName
, NotificationEvent
);
96 TestCreateEvent(IoCreateSynchronizationEvent
, &SynchronizationEventName
, SynchronizationEvent
);
98 /* Create different types with the same name */
99 Event
= IoCreateNotificationEvent(&NotificationEventName
, &EventHandle
);
100 ok(Event
!= NULL
, "Event is NULL\n");
101 ok(EventHandle
!= NULL
, "EventHandle is NULL\n");
102 if (!skip(EventHandle
!= NULL
, "No event\n"))
104 ok_eq_uint(Event
->Header
.Type
, NotificationEvent
);
105 Event2
= IoCreateSynchronizationEvent(&NotificationEventName
, &EventHandle2
);
106 ok(Event2
!= NULL
, "Event is NULL\n");
107 ok(EventHandle2
!= NULL
, "EventHandle is NULL\n");
108 if (!skip(EventHandle2
!= NULL
, "No event\n"))
110 ok_eq_uint(Event2
->Header
.Type
, NotificationEvent
);
111 ZwClose(EventHandle2
);
113 ZwClose(EventHandle
);