ReactOS 0.4.15-dev-7887-g64a59a1
evtpair.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for evtpair.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI ExpInitializeEventPairImplementation (VOID)
 
NTSTATUS NTAPI NtCreateEventPair (OUT PHANDLE EventPairHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
 
NTSTATUS NTAPI NtOpenEventPair (OUT PHANDLE EventPairHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
 
NTSTATUS NTAPI NtSetHighEventPair (IN HANDLE EventPairHandle)
 
NTSTATUS NTAPI NtSetHighWaitLowEventPair (IN HANDLE EventPairHandle)
 
NTSTATUS NTAPI NtSetLowEventPair (IN HANDLE EventPairHandle)
 
NTSTATUS NTAPI NtSetLowWaitHighEventPair (IN HANDLE EventPairHandle)
 
NTSTATUS NTAPI NtWaitLowEventPair (IN HANDLE EventPairHandle)
 
NTSTATUS NTAPI NtWaitHighEventPair (IN HANDLE EventPairHandle)
 

Variables

POBJECT_TYPE ExEventPairObjectType = NULL
 
GENERIC_MAPPING ExEventPairMapping
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file evtpair.c.

Function Documentation

◆ ExpInitializeEventPairImplementation()

BOOLEAN NTAPI ExpInitializeEventPairImplementation ( VOID  )

Definition at line 33 of file evtpair.c.

34{
35 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
38 DPRINT("Creating Event Pair Object Type\n");
39
40 /* Create the Event Pair Object Type */
41 RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
42 RtlInitUnicodeString(&Name, L"EventPair");
43 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
44 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
45 ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
46 ObjectTypeInitializer.PoolType = NonPagedPool;
47 ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
48 ObjectTypeInitializer.UseDefaultObject = TRUE;
49 ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
50 Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventPairObjectType);
51 if (!NT_SUCCESS(Status)) return FALSE;
52 return TRUE;
53}
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NonPagedPool
Definition: env_spec_w32.h:307
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:18
GENERIC_MAPPING ExEventPairMapping
Definition: evtpair.c:20
Status
Definition: gdiplustypes.h:25
#define OBJ_OPENLINK
Definition: winternl.h:230
#define EVENT_PAIR_ALL_ACCESS
Definition: extypes.h:125
struct _KEVENT_PAIR KEVENT_PAIR
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1136
#define DPRINT
Definition: sndvol32.h:71
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by ExpInitSystemPhase1().

◆ NtCreateEventPair()

NTSTATUS NTAPI NtCreateEventPair ( OUT PHANDLE  EventPairHandle,
IN ACCESS_MASK  DesiredAccess,
IN POBJECT_ATTRIBUTES  ObjectAttributes 
)

Definition at line 57 of file evtpair.c.

60{
61 PKEVENT_PAIR EventPair;
62 HANDLE hEventPair;
65 PAGED_CODE();
66 DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
67
68 /* Check if we were called from user-mode */
70 {
71 /* Enter SEH Block */
73 {
74 /* Check handle pointer */
75 ProbeForWriteHandle(EventPairHandle);
76 }
78 {
79 /* Return the exception code */
81 }
83 }
84
85 /* Create the Object */
86 DPRINT("Creating EventPair\n");
91 NULL,
92 sizeof(KEVENT_PAIR),
93 0,
94 0,
95 (PVOID*)&EventPair);
96
97 /* Check for Success */
98 if (NT_SUCCESS(Status))
99 {
100 /* Initialize the Event */
101 DPRINT("Initializing EventPair\n");
102 KeInitializeEventPair(EventPair);
103
104 /* Insert it */
105 Status = ObInsertObject((PVOID)EventPair,
106 NULL,
108 0,
109 NULL,
110 &hEventPair);
111
112 /* Check for success */
113 if (NT_SUCCESS(Status))
114 {
115 /* Enter SEH */
117 {
118 /* Return the handle */
119 *EventPairHandle = hEventPair;
120 }
122 {
123 /* Get the exception code */
125 }
126 _SEH2_END;
127 }
128 }
129
130 /* Return Status */
131 return Status;
132}
#define PAGED_CODE()
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define ExGetPreviousMode
Definition: ex.h:140
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:349
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define KernelMode
Definition: asm.h:34
VOID NTAPI KeInitializeEventPair(PKEVENT_PAIR EventPair)
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2935
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1039
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define ProbeForWriteHandle(Ptr)
Definition: probe.h:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103

◆ NtOpenEventPair()

NTSTATUS NTAPI NtOpenEventPair ( OUT PHANDLE  EventPairHandle,
IN ACCESS_MASK  DesiredAccess,
IN POBJECT_ATTRIBUTES  ObjectAttributes 
)

Definition at line 136 of file evtpair.c.

139{
140 HANDLE hEventPair;
143 PAGED_CODE();
144
145 /* Check if we were called from user-mode */
147 {
148 /* Enter SEH Block */
150 {
151 /* Check handle pointer */
152 ProbeForWriteHandle(EventPairHandle);
153 }
155 {
156 /* Return the exception code */
158 }
159 _SEH2_END;
160 }
161
162 /* Open the Object */
166 NULL,
168 NULL,
169 &hEventPair);
170
171 /* Check for success */
172 if (NT_SUCCESS(Status))
173 {
174 /* Enter SEH */
176 {
177 /* Return the handle */
178 *EventPairHandle = hEventPair;
179 }
181 {
182 /* Get the exception code */
184 }
185 _SEH2_END;
186 }
187
188 /* Return status */
189 return Status;
190}
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2532

Referenced by NtOpenObject().

◆ NtSetHighEventPair()

NTSTATUS NTAPI NtSetHighEventPair ( IN HANDLE  EventPairHandle)

Definition at line 194 of file evtpair.c.

195{
196 PKEVENT_PAIR EventPair;
199 PAGED_CODE();
200 DPRINT("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
201
202 /* Open the Object */
203 Status = ObReferenceObjectByHandle(EventPairHandle,
207 (PVOID*)&EventPair,
208 NULL);
209
210 /* Check for Success */
211 if(NT_SUCCESS(Status))
212 {
213 /* Set the Event */
215
216 /* Dereference Object */
217 ObDereferenceObject(EventPair);
218 }
219
220 /* Return status */
221 return Status;
222}
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
KEVENT HighEvent
Definition: ketypes.h:979
#define EVENT_INCREMENT
Definition: iotypes.h:597
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ NtSetHighWaitLowEventPair()

NTSTATUS NTAPI NtSetHighWaitLowEventPair ( IN HANDLE  EventPairHandle)

Definition at line 226 of file evtpair.c.

227{
228 PKEVENT_PAIR EventPair;
231 PAGED_CODE();
232 DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
233
234 /* Open the Object */
235 Status = ObReferenceObjectByHandle(EventPairHandle,
239 (PVOID*)&EventPair,
240 NULL);
241
242 /* Check for Success */
243 if(NT_SUCCESS(Status))
244 {
245 /* Set the Event */
247
248 /* Wait for the Other one */
252 FALSE,
253 NULL);
254
255 /* Dereference Object */
256 ObDereferenceObject(EventPair);
257 }
258
259 /* Return status */
260 return Status;
261}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
KEVENT LowEvent
Definition: ketypes.h:978
@ WrEventPair
Definition: ketypes.h:429

◆ NtSetLowEventPair()

NTSTATUS NTAPI NtSetLowEventPair ( IN HANDLE  EventPairHandle)

Definition at line 265 of file evtpair.c.

266{
267 PKEVENT_PAIR EventPair;
270 PAGED_CODE();
271 DPRINT1("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
272
273 /* Open the Object */
274 Status = ObReferenceObjectByHandle(EventPairHandle,
278 (PVOID*)&EventPair,
279 NULL);
280
281 /* Check for Success */
282 if(NT_SUCCESS(Status))
283 {
284 /* Set the Event */
286
287 /* Dereference Object */
288 ObDereferenceObject(EventPair);
289 }
290
291 /* Return status */
292 return Status;
293}
#define DPRINT1
Definition: precomp.h:8

◆ NtSetLowWaitHighEventPair()

NTSTATUS NTAPI NtSetLowWaitHighEventPair ( IN HANDLE  EventPairHandle)

Definition at line 297 of file evtpair.c.

298{
299 PKEVENT_PAIR EventPair;
302 PAGED_CODE();
303 DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
304
305 /* Open the Object */
306 Status = ObReferenceObjectByHandle(EventPairHandle,
310 (PVOID*)&EventPair,
311 NULL);
312
313 /* Check for Success */
314 if(NT_SUCCESS(Status))
315 {
316 /* Set the Event */
318
319 /* Wait for the Other one */
323 FALSE,
324 NULL);
325
326 /* Dereference Object */
327 ObDereferenceObject(EventPair);
328 }
329
330 /* Return status */
331 return Status;
332}

◆ NtWaitHighEventPair()

NTSTATUS NTAPI NtWaitHighEventPair ( IN HANDLE  EventPairHandle)

Definition at line 373 of file evtpair.c.

374{
375 PKEVENT_PAIR EventPair;
378
379 PAGED_CODE();
380 DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
381
382 /* Open the Object */
383 Status = ObReferenceObjectByHandle(EventPairHandle,
387 (PVOID*)&EventPair,
388 NULL);
389
390 /* Check for Success */
391 if(NT_SUCCESS(Status))
392 {
393 /* Wait for the Event */
397 FALSE,
398 NULL);
399
400 /* Dereference Object */
401 ObDereferenceObject(EventPair);
402 }
403
404 /* Return status */
405 return Status;
406}

◆ NtWaitLowEventPair()

NTSTATUS NTAPI NtWaitLowEventPair ( IN HANDLE  EventPairHandle)

Definition at line 337 of file evtpair.c.

338{
339 PKEVENT_PAIR EventPair;
342 PAGED_CODE();
343 DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
344
345 /* Open the Object */
346 Status = ObReferenceObjectByHandle(EventPairHandle,
350 (PVOID*)&EventPair,
351 NULL);
352
353 /* Check for Success */
354 if(NT_SUCCESS(Status))
355 {
356 /* Wait for the Event */
360 FALSE,
361 NULL);
362
363 /* Dereference Object */
364 ObDereferenceObject(EventPair);
365 }
366
367 /* Return status */
368 return Status;
369}

Variable Documentation

◆ ExEventPairMapping

GENERIC_MAPPING ExEventPairMapping
Initial value:

Definition at line 20 of file evtpair.c.

Referenced by ExpInitializeEventPairImplementation().

◆ ExEventPairObjectType