ReactOS 0.4.16-dev-250-g3ecd236
engevent.c File Reference
#include <win32k.h>
#include <ntddvdeo.h>
#include <debug.h>
Include dependency graph for engevent.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

_Must_inspect_result_ _Success_ (return !=FALSE)
 
BOOL APIENTRY EngDeleteEvent (_In_ _Post_ptr_invalid_ PEVENT Event)
 
VOID APIENTRY EngClearEvent (_In_ PEVENT Event)
 
LONG APIENTRY EngSetEvent (_In_ PEVENT Event)
 
LONG APIENTRY EngReadStateEvent (_In_ PEVENT Event)
 
PEVENT APIENTRY EngMapEvent (_In_ HDEV hDev, _In_ HANDLE hUserObject, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3)
 
BOOL APIENTRY EngUnmapEvent (_In_ PEVENT Event)
 
BOOL APIENTRY EngWaitForSingleObject (_In_ PEVENT Event, _In_opt_ PLARGE_INTEGER TimeOut)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file engevent.c.

Function Documentation

◆ _Success_()

_Must_inspect_result_ _Success_ ( return = FALSE)

Definition at line 22 of file engevent.c.

27{
29 PENG_EVENT EngEvent;
30
31 /* Allocate memory for the event structure */
33 sizeof(ENG_EVENT) + sizeof(KEVENT),
35 if (EngEvent)
36 {
37 /* Set KEVENT pointer */
38 EngEvent->fFlags = 0;
39 EngEvent->pKEvent = EngEvent + 1;
40
41 /* Initialize the kernel event */
42 KeInitializeEvent(EngEvent->pKEvent,
44 FALSE);
45
46 /* Pass pointer to our structure to the caller */
47 *ppEvent = EngEvent;
48 DPRINT("EngCreateEvent() created %p\n", EngEvent);
49 }
50 else
51 {
52 /* Out of memory */
53 DPRINT("EngCreateEvent() failed\n");
54 Result = FALSE;
55 }
56
57 /* Return result */
58 return Result;
59}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NonPagedPool
Definition: env_spec_w32.h:307
@ SynchronizationEvent
#define DPRINT
Definition: sndvol32.h:73
ULONG fFlags
Definition: ntddvdeo.h:624
PVOID pKEvent
Definition: ntddvdeo.h:623
#define GDITAG_ENG_EVENT
Definition: tags.h:58
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ EngClearEvent()

VOID APIENTRY EngClearEvent ( _In_ PEVENT  Event)

Definition at line 85 of file engevent.c.

87{
88 /* Clear the event */
89 KeClearEvent(Event->pKEvent);
90}
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22

◆ EngDeleteEvent()

BOOL APIENTRY EngDeleteEvent ( _In_ _Post_ptr_invalid_ PEVENT  Event)

Definition at line 63 of file engevent.c.

65{
66 DPRINT("EngDeleteEvent(%p)\n", Event);
67
68 /* Check if it's a usermapped event */
69 if (Event->fFlags & ENG_EVENT_USERMAPPED)
70 {
71 /* Disallow deletion of usermapped events */
72 DPRINT1("Driver attempted to delete a usermapped event!\n");
73 return FALSE;
74 }
75
76 /* Free the allocated memory */
78
79 /* Return success */
80 return TRUE;
81}
#define DPRINT1
Definition: precomp.h:8
@ ENG_EVENT_USERMAPPED
Definition: engevent.h:8
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

◆ EngMapEvent()

PEVENT APIENTRY EngMapEvent ( _In_ HDEV  hDev,
_In_ HANDLE  hUserObject,
_Reserved_ PVOID  Reserved1,
_Reserved_ PVOID  Reserved2,
_Reserved_ PVOID  Reserved3 
)

Definition at line 114 of file engevent.c.

120{
121 PENG_EVENT EngEvent;
122 PVOID pvEvent;
124
125 /* Allocate memory for the event structure */
127 sizeof(ENG_EVENT),
129 if (!EngEvent) return NULL;
130
131 /* Zero it out */
132 EngEvent->fFlags = 0;
133 EngEvent->pKEvent = NULL;
134
135 /* Create a handle, and have Ob fill out the pKEvent field */
136 Status = ObReferenceObjectByHandle(hUserObject,
139 UserMode,
140 &pvEvent,
141 NULL);
142 if (NT_SUCCESS(Status))
143 {
144 /* Pulse the event and set that it's mapped by user */
146 EngEvent->pKEvent = pvEvent;
147 EngEvent->fFlags |= ENG_EVENT_USERMAPPED;
148 }
149 else
150 {
151 /* Free the allocation */
153 EngEvent = NULL;
154 }
155
156 /* Support legacy interface */
157 if (Reserved1) *(PVOID*)Reserved1 = EngEvent;
158 return EngEvent;
159}
LONG NTSTATUS
Definition: precomp.h:26
@ Reserved1
Definition: bcd.h:201
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
LONG NTAPI KePulseEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:68
Status
Definition: gdiplustypes.h:25
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define UserMode
Definition: asm.h:35
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
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
#define EVENT_INCREMENT
Definition: iotypes.h:597

◆ EngReadStateEvent()

LONG APIENTRY EngReadStateEvent ( _In_ PEVENT  Event)

Definition at line 105 of file engevent.c.

107{
108 /* Read the event state */
109 return KeReadStateEvent(Event->pKEvent);
110}
LONG NTAPI KeReadStateEvent(IN PKEVENT Event)
Definition: eventobj.c:120

◆ EngSetEvent()

LONG APIENTRY EngSetEvent ( _In_ PEVENT  Event)

Definition at line 94 of file engevent.c.

96{
97 /* Set the event */
98 return KeSetEvent(Event->pKEvent,
100 FALSE);
101}
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ EngUnmapEvent()

BOOL APIENTRY EngUnmapEvent ( _In_ PEVENT  Event)

Definition at line 163 of file engevent.c.

165{
166 /* Must be a usermapped event */
167 if (!(Event->fFlags & ENG_EVENT_USERMAPPED)) return FALSE;
168
169 /* Dereference the object, destroying it */
170 ObDereferenceObject(Event->pKEvent);
171
172 /* Free the Eng object */
174 return TRUE;
175}
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ EngWaitForSingleObject()

BOOL APIENTRY EngWaitForSingleObject ( _In_ PEVENT  Event,
_In_opt_ PLARGE_INTEGER  TimeOut 
)

Definition at line 179 of file engevent.c.

182{
184 DPRINT("EngWaitForSingleObject(%p %I64d)\n", Event, TimeOut->QuadPart);
185
186 /* Validate parameters */
187 if (!Event) return FALSE;
188
189 /* Check if it's a usermapped event and fail in that case */
190 if (Event->fFlags & ENG_EVENT_USERMAPPED)
191 {
192 /* Disallow deletion of usermapped events */
193 DPRINT1("Driver attempted to wait on a usermapped event!\n");
194 return FALSE;
195 }
196
197 /* Wait for the event */
199 Executive,
201 FALSE,
202 TimeOut);
203
204 /* Check if there is a failure or a timeout */
205 return NT_SUCCESS(Status);
206}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KernelMode
Definition: asm.h:34
@ Executive
Definition: ketypes.h:415