ReactOS  0.4.14-dev-41-g31d7680
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 }
#define TRUE
Definition: types.h:120
ULONG fFlags
Definition: ntddvdeo.h:554
unsigned char BOOLEAN
_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:426
void DPRINT(...)
Definition: polytest.cpp:61
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define GDITAG_ENG_EVENT
Definition: tags.h:58
PVOID pKEvent
Definition: ntddvdeo.h:553

◆ 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 TRUE
Definition: types.h:120
void DPRINT(...)
Definition: polytest.cpp:61
#define GDITAG_ENG_EVENT
Definition: tags.h:58
#define DPRINT1
Definition: precomp.h:8
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ 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 }
ULONG fFlags
Definition: ntddvdeo.h:554
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
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:496
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
LONG NTAPI KePulseEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
#define EVENT_INCREMENT
Definition: iotypes.h:565
#define GDITAG_ENG_EVENT
Definition: tags.h:58
Definition: bcd.h:201
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PVOID pKEvent
Definition: ntddvdeo.h:553

◆ 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 }
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define IO_NO_INCREMENT
Definition: iotypes.h:566

◆ 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 TRUE
Definition: types.h:120
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define GDITAG_ENG_EVENT
Definition: tags.h:58
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ 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,
200  KernelMode,
201  FALSE,
202  TimeOut);
203 
204  /* Check if there is a failure or a timeout */
205  return NT_SUCCESS(Status);
206 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8