Commit fd8bc0c1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntoskrnl.exe: Implement IoCreateSynchronizationEvent.

parent b4f78d68
......@@ -402,7 +402,7 @@ static CRITICAL_SECTION_DEBUG handle_map_critsect_debug =
};
static CRITICAL_SECTION handle_map_cs = { &handle_map_critsect_debug, -1, 0, 0, 0, 0 };
static NTSTATUS kernel_object_from_handle( HANDLE handle, POBJECT_TYPE type, void **ret )
NTSTATUS kernel_object_from_handle( HANDLE handle, POBJECT_TYPE type, void **ret )
{
struct object_header *header;
void *obj;
......@@ -3291,15 +3291,6 @@ BOOLEAN WINAPI Ke386SetIoAccessMap(ULONG flag, PVOID buffer)
}
/*****************************************************
* IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
*/
PKEVENT WINAPI IoCreateSynchronizationEvent(PUNICODE_STRING name, PHANDLE handle)
{
FIXME("(%p %p) stub\n", name, handle);
return (KEVENT *)0xdeadbeaf;
}
/*****************************************************
* IoStartNextPacket (NTOSKRNL.EXE.@)
*/
VOID WINAPI IoStartNextPacket(PDEVICE_OBJECT deviceobject, BOOLEAN cancelable)
......
......@@ -1395,7 +1395,7 @@
@ stdcall -private ZwSetDefaultLocale(long long) NtSetDefaultLocale
@ stdcall -private ZwSetDefaultUILanguage(long) NtSetDefaultUILanguage
@ stdcall -private ZwSetEaFile(long ptr ptr long) NtSetEaFile
@ stdcall -private ZwSetEvent(long ptr) NtSetEvent
@ stdcall ZwSetEvent(long ptr) NtSetEvent
@ stdcall -private ZwSetInformationFile(long ptr ptr long long) NtSetInformationFile
@ stdcall -private ZwSetInformationJobObject(long long ptr long) NtSetInformationJobObject
@ stdcall -private ZwSetInformationObject(long long ptr long) NtSetInformationObject
......
......@@ -29,6 +29,7 @@ struct _OBJECT_TYPE {
void *alloc_kernel_object( POBJECT_TYPE type, HANDLE handle, SIZE_T size, LONG ref ) DECLSPEC_HIDDEN;
HANDLE kernel_object_handle( void *obj, unsigned int access ) DECLSPEC_HIDDEN;
NTSTATUS kernel_object_from_handle( HANDLE handle, POBJECT_TYPE type, void **ret ) DECLSPEC_HIDDEN;
extern POBJECT_TYPE ExEventObjectType;
extern POBJECT_TYPE ExSemaphoreObjectType;
......
......@@ -219,6 +219,32 @@ static struct _OBJECT_TYPE event_type = {
POBJECT_TYPE ExEventObjectType = &event_type;
/***********************************************************************
* IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
*/
PKEVENT WINAPI IoCreateSynchronizationEvent( UNICODE_STRING *name, HANDLE *ret_handle )
{
OBJECT_ATTRIBUTES attr;
HANDLE handle;
KEVENT *event;
NTSTATUS ret;
TRACE( "(%p %p)\n", name, ret_handle );
InitializeObjectAttributes( &attr, name, 0, 0, NULL );
ret = NtCreateEvent( &handle, EVENT_ALL_ACCESS, &attr, SynchronizationEvent, TRUE );
if (ret) return NULL;
if (kernel_object_from_handle( handle, ExEventObjectType, (void**)&event ))
{
NtClose( handle);
return NULL;
}
*ret_handle = handle;
return event;
}
/***********************************************************************
* KeSetEvent (NTOSKRNL.EXE.@)
*/
LONG WINAPI KeSetEvent( PRKEVENT event, KPRIORITY increment, BOOLEAN wait )
......
......@@ -474,6 +474,33 @@ static void test_sync(void)
ZwClose(handle);
ObDereferenceObject(event);
event = IoCreateSynchronizationEvent(NULL, &handle);
ok(event != NULL, "IoCreateSynchronizationEvent failed\n");
ret = wait_single(event, 0);
ok(ret == 0, "got %#x\n", ret);
KeResetEvent(event);
ret = wait_single(event, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
ret = wait_single_handle(handle, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
ret = ZwSetEvent(handle, NULL);
ok(!ret, "NtSetEvent returned %#x\n", ret);
ret = wait_single(event, 0);
ok(ret == 0, "got %#x\n", ret);
ret = wait_single_handle(handle, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
KeSetEvent(event, 0, FALSE);
ret = wait_single_handle(handle, 0);
ok(!ret, "got %#x\n", ret);
ret = wait_single(event, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
ret = ZwClose(handle);
ok(!ret, "ZwClose returned %#x\n", ret);
/* test semaphores */
KeInitializeSemaphore(&semaphore, 0, 5);
......
......@@ -1488,6 +1488,7 @@ VOID WINAPI IoCompleteRequest(IRP*,UCHAR);
NTSTATUS WINAPI IoCreateDevice(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,DEVICE_OBJECT**);
NTSTATUS WINAPI IoCreateDriver(UNICODE_STRING*,PDRIVER_INITIALIZE);
NTSTATUS WINAPI IoCreateSymbolicLink(UNICODE_STRING*,UNICODE_STRING*);
PKEVENT WINAPI IoCreateSynchronizationEvent(UNICODE_STRING*,HANDLE*);
void WINAPI IoDeleteDevice(DEVICE_OBJECT*);
void WINAPI IoDeleteDriver(DRIVER_OBJECT*);
NTSTATUS WINAPI IoDeleteSymbolicLink(UNICODE_STRING*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment