[NTOSKRNL]: Fixed keyed event initialization.

svn path=/trunk/; revision=57226
This commit is contained in:
Alex Ionescu 2012-09-03 00:33:05 +00:00
parent fdf0f24838
commit 80829aac14

View file

@ -25,11 +25,14 @@ typedef struct _EX_KEYED_EVENT
} HashTable[NUM_KEY_HASH_BUCKETS]; } HashTable[NUM_KEY_HASH_BUCKETS];
} EX_KEYED_EVENT, *PEX_KEYED_EVENT; } EX_KEYED_EVENT, *PEX_KEYED_EVENT;
VOID NTSTATUS
NTAPI NTAPI
ExpInitializeKeyedEvent( ZwCreateKeyedEvent(
_Out_ PEX_KEYED_EVENT KeyedEvent); _Out_ PHANDLE OutHandle,
_In_ ACCESS_MASK AccessMask,
_In_ POBJECT_ATTRIBUTES ObjectAttributes,
_In_ ULONG Flags);
#define KeGetCurrentProcess() ((PKPROCESS)PsGetCurrentProcess()) #define KeGetCurrentProcess() ((PKPROCESS)PsGetCurrentProcess())
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
@ -46,7 +49,6 @@ GENERIC_MAPPING ExpKeyedEventMapping =
EVENT_ALL_ACCESS EVENT_ALL_ACCESS
}; };
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
@ -55,49 +57,46 @@ ExpInitializeKeyedEventImplementation(VOID)
{ {
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer = {0}; OBJECT_TYPE_INITIALIZER ObjectTypeInitializer = {0};
UNICODE_STRING TypeName = RTL_CONSTANT_STRING(L"KeyedEvent"); UNICODE_STRING TypeName = RTL_CONSTANT_STRING(L"KeyedEvent");
UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\KernelObjects\\CritSecOutOfMemoryEvent");
NTSTATUS Status; NTSTATUS Status;
HANDLE EventHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
/* Set up the object type initializer */ /* Set up the object type initializer */
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.GenericMapping = ExpKeyedEventMapping; ObjectTypeInitializer.GenericMapping = ExpKeyedEventMapping;
ObjectTypeInitializer.PoolType = PagedPool; ObjectTypeInitializer.PoolType = PagedPool;
ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS; ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
//ObjectTypeInitializer.DeleteProcedure = ???; ObjectTypeInitializer.UseDefaultObject = TRUE;
//ObjectTypeInitializer.OkayToCloseProcedure = ???;
/* Create the keyed event object type */ /* Create the keyed event object type */
Status = ObCreateObjectType(&TypeName, Status = ObCreateObjectType(&TypeName,
&ObjectTypeInitializer, &ObjectTypeInitializer,
NULL, NULL,
&ExKeyedEventObjectType); &ExKeyedEventObjectType);
if (!NT_SUCCESS(Status)) return;
/* Check for success */ /* Create the out of memory event for critical sections */
if (!NT_SUCCESS(Status)) InitializeObjectAttributes(&ObjectAttributes, &Name, OBJ_PERMANENT, NULL, NULL);
Status = ZwCreateKeyedEvent(&EventHandle,
EVENT_ALL_ACCESS,
&ObjectAttributes,
0);
if (NT_SUCCESS(Status))
{ {
// FIXME /* Take a reference so we can get rid of the handle */
KeBugCheck(0); Status = ObReferenceObjectByHandle(EventHandle,
EVENT_ALL_ACCESS,
ExKeyedEventObjectType,
KernelMode,
(PVOID*)&ExpCritSecOutOfMemoryEvent,
NULL);
ZwClose(EventHandle);
} }
else
/* Create the global keyed event for critical sections on low memory */
Status = ObCreateObject(KernelMode,
ExKeyedEventObjectType,
NULL,
UserMode,
NULL,
sizeof(EX_KEYED_EVENT),
0,
0,
(PVOID*)&ExpCritSecOutOfMemoryEvent);
/* Check for success */
if (!NT_SUCCESS(Status))
{ {
// FIXME DPRINT1("Failed to create keyed event: %lx\n", Status);
KeBugCheck(0);
} }
/* Initalize the keyed event */
ExpInitializeKeyedEvent(ExpCritSecOutOfMemoryEvent);
} }
VOID VOID