ReactOS 0.4.16-dev-306-g647d351
keyedevt.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for keyedevt.c:

Go to the source code of this file.

Classes

struct  _EX_KEYED_EVENT
 

Macros

#define NDEBUG
 
#define NUM_KEY_HASH_BUCKETS   23
 

Typedefs

typedef struct _EX_KEYED_EVENT EX_KEYED_EVENT
 
typedef struct _EX_KEYED_EVENTPEX_KEYED_EVENT
 

Functions

 _IRQL_requires_max_ (APC_LEVEL)
 
VOID NTAPI ExpInitializeKeyedEvent (_Out_ PEX_KEYED_EVENT KeyedEvent)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL)
 

Variables

PEX_KEYED_EVENT ExpCritSecOutOfMemoryEvent
 
POBJECT_TYPE ExKeyedEventObjectType
 
static GENERIC_MAPPING ExpKeyedEventMapping
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file keyedevt.c.

◆ NUM_KEY_HASH_BUCKETS

#define NUM_KEY_HASH_BUCKETS   23

Definition at line 17 of file keyedevt.c.

Typedef Documentation

◆ EX_KEYED_EVENT

◆ PEX_KEYED_EVENT

Function Documentation

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 44 of file keyedevt.c.

49{
50 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer = {0};
51 UNICODE_STRING TypeName = RTL_CONSTANT_STRING(L"KeyedEvent");
52 UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\KernelObjects\\CritSecOutOfMemoryEvent");
56
57 /* Set up the object type initializer */
58 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
59 ObjectTypeInitializer.GenericMapping = ExpKeyedEventMapping;
60 ObjectTypeInitializer.PoolType = PagedPool;
61 ObjectTypeInitializer.ValidAccessMask = KEYEDEVENT_ALL_ACCESS;
62 ObjectTypeInitializer.UseDefaultObject = TRUE;
63
64 /* Create the keyed event object type */
65 Status = ObCreateObjectType(&TypeName,
66 &ObjectTypeInitializer,
67 NULL,
69 if (!NT_SUCCESS(Status)) return FALSE;
70
71 /* Create the out of memory event for critical sections */
73 Status = ZwCreateKeyedEvent(&EventHandle,
76 0);
77 if (NT_SUCCESS(Status))
78 {
79 /* Take a reference so we can get rid of the handle */
85 NULL);
87 return TRUE;
88 }
89
90 return FALSE;
91}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#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:33
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
#define OBJ_PERMANENT
Definition: winternl.h:226
static GENERIC_MAPPING ExpKeyedEventMapping
Definition: keyedevt.c:34
PEX_KEYED_EVENT ExpCritSecOutOfMemoryEvent
Definition: keyedevt.c:30
POBJECT_TYPE ExKeyedEventObjectType
Definition: keyedevt.c:31
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#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
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 KEYEDEVENT_ALL_ACCESS
Definition: om.c:76
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 272 of file keyedevt.c.

280{
282 PEX_KEYED_EVENT KeyedEvent;
283 HANDLE KeyedEventHandle;
285
286 /* Check flags */
287 if (Flags != 0)
288 {
289 /* We don't support any flags yet */
291 }
292
293 /* Create the object */
298 NULL,
299 sizeof(EX_KEYED_EVENT),
300 0,
301 0,
302 (PVOID*)&KeyedEvent);
303
304 /* Check for success */
305 if (!NT_SUCCESS(Status)) return Status;
306
307 /* Initialize the keyed event */
308 ExpInitializeKeyedEvent(KeyedEvent);
309
310 /* Insert it */
311 Status = ObInsertObject(KeyedEvent,
312 NULL,
314 0,
315 NULL,
316 &KeyedEventHandle);
317
318 /* Check for success (ObInsertObject dereferences!) */
319 if (!NT_SUCCESS(Status)) return Status;
320
322 {
323 /* Enter SEH for return */
325 {
326 /* Return the handle to the caller */
327 ProbeForWrite(OutHandle, sizeof(HANDLE), sizeof(HANDLE));
328 *OutHandle = KeyedEventHandle;
329 }
331 {
332 /* Get the exception code */
334
335 /* Cleanup */
336 ObCloseHandle(KeyedEventHandle, PreviousMode);
337 }
338 _SEH2_END;
339 }
340 else
341 {
342 *OutHandle = KeyedEventHandle;
343 }
344
345 /* Return Status */
346 return Status;
347}
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:349
VOID NTAPI ExpInitializeKeyedEvent(_Out_ PEX_KEYED_EVENT KeyedEvent)
Definition: keyedevt.c:95
#define KeGetPreviousMode()
Definition: ketypes.h:1115
_In_ ACCESS_MASK AccessMask
Definition: exfuncs.h:186
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
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:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103

◆ ExpInitializeKeyedEvent()

VOID NTAPI ExpInitializeKeyedEvent ( _Out_ PEX_KEYED_EVENT  KeyedEvent)

Definition at line 95 of file keyedevt.c.

97{
98 ULONG i;
99
100 /* Loop all hash buckets */
101 for (i = 0; i < NUM_KEY_HASH_BUCKETS; i++)
102 {
103 /* Initialize the mutex and the wait lists */
104 ExInitializePushLock(&KeyedEvent->HashTable[i].Lock);
105 InitializeListHead(&KeyedEvent->HashTable[i].WaitListHead);
106 InitializeListHead(&KeyedEvent->HashTable[i].ReleaseListHead);
107 }
108}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ExInitializePushLock
Definition: ex.h:1013
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NUM_KEY_HASH_BUCKETS
Definition: keyedevt.c:17
uint32_t ULONG
Definition: typedefs.h:59

Referenced by _IRQL_requires_max_().

Variable Documentation

◆ ExKeyedEventObjectType

POBJECT_TYPE ExKeyedEventObjectType

Definition at line 31 of file keyedevt.c.

Referenced by _IRQL_requires_max_().

◆ ExpCritSecOutOfMemoryEvent

PEX_KEYED_EVENT ExpCritSecOutOfMemoryEvent

Definition at line 30 of file keyedevt.c.

Referenced by _IRQL_requires_max_().

◆ ExpKeyedEventMapping

GENERIC_MAPPING ExpKeyedEventMapping
static
Initial value:
=
{
}
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
#define STANDARD_RIGHTS_WRITE
Definition: nt_native.h:66
#define STANDARD_RIGHTS_EXECUTE
Definition: nt_native.h:67
#define KEYEDEVENT_WAIT
Definition: om.c:74
#define KEYEDEVENT_WAKE
Definition: om.c:75

Definition at line 34 of file keyedevt.c.

Referenced by _IRQL_requires_max_().