Commit f1276b25 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the keyed event functions to the Unix library.

parent 65edacf9
......@@ -775,23 +775,7 @@ NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeou
NTSTATUS WINAPI NtCreateKeyedEvent( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, ULONG flags )
{
NTSTATUS ret;
data_size_t len;
struct object_attributes *objattr;
if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;
SERVER_START_REQ( create_keyed_event )
{
req->access = access;
wine_server_add_data( req, objattr, len );
ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
RtlFreeHeap( GetProcessHeap(), 0, objattr );
return ret;
return unix_funcs->NtCreateKeyedEvent( handle, access, attr, flags );
}
/******************************************************************************
......@@ -799,22 +783,7 @@ NTSTATUS WINAPI NtCreateKeyedEvent( HANDLE *handle, ACCESS_MASK access,
*/
NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{
NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_keyed_event )
{
req->access = access;
req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
return ret;
return unix_funcs->NtOpenKeyedEvent( handle, access, attr );
}
/******************************************************************************
......@@ -823,16 +792,7 @@ NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJE
NTSTATUS WINAPI NtWaitForKeyedEvent( HANDLE handle, const void *key,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
select_op_t select_op;
UINT flags = SELECT_INTERRUPTIBLE;
if (!handle) handle = keyed_event;
if ((ULONG_PTR)key & 1) return STATUS_INVALID_PARAMETER_1;
if (alertable) flags |= SELECT_ALERTABLE;
select_op.keyed_event.op = SELECT_KEYED_EVENT_WAIT;
select_op.keyed_event.handle = wine_server_obj_handle( handle );
select_op.keyed_event.key = wine_server_client_ptr( key );
return unix_funcs->server_wait( &select_op, sizeof(select_op.keyed_event), flags, timeout );
return unix_funcs->NtWaitForKeyedEvent( handle, key, alertable, timeout );
}
/******************************************************************************
......@@ -841,16 +801,7 @@ NTSTATUS WINAPI NtWaitForKeyedEvent( HANDLE handle, const void *key,
NTSTATUS WINAPI NtReleaseKeyedEvent( HANDLE handle, const void *key,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
select_op_t select_op;
UINT flags = SELECT_INTERRUPTIBLE;
if (!handle) handle = keyed_event;
if ((ULONG_PTR)key & 1) return STATUS_INVALID_PARAMETER_1;
if (alertable) flags |= SELECT_ALERTABLE;
select_op.keyed_event.op = SELECT_KEYED_EVENT_RELEASE;
select_op.keyed_event.handle = wine_server_obj_handle( handle );
select_op.keyed_event.key = wine_server_client_ptr( key );
return unix_funcs->server_wait( &select_op, sizeof(select_op.keyed_event), flags, timeout );
return unix_funcs->NtReleaseKeyedEvent( handle, key, alertable, timeout );
}
/******************************************************************
......
......@@ -989,6 +989,7 @@ static struct unix_funcs unix_funcs =
NtClearEvent,
NtClose,
NtCreateEvent,
NtCreateKeyedEvent,
NtCreateMutant,
NtCreateSemaphore,
NtCreateTimer,
......@@ -1002,6 +1003,7 @@ static struct unix_funcs unix_funcs =
NtLockVirtualMemory,
NtMapViewOfSection,
NtOpenEvent,
NtOpenKeyedEvent,
NtOpenMutant,
NtOpenSemaphore,
NtOpenTimer,
......@@ -1014,6 +1016,7 @@ static struct unix_funcs unix_funcs =
NtQueryTimer,
NtQueryVirtualMemory,
NtReadVirtualMemory,
NtReleaseKeyedEvent,
NtReleaseMutant,
NtReleaseSemaphore,
NtResetEvent,
......@@ -1025,6 +1028,7 @@ static struct unix_funcs unix_funcs =
NtSignalAndWaitForSingleObject,
NtUnlockVirtualMemory,
NtUnmapViewOfSection,
NtWaitForKeyedEvent,
NtWaitForMultipleObjects,
NtWaitForSingleObject,
NtWriteVirtualMemory,
......
......@@ -68,6 +68,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(sync);
HANDLE keyed_event = 0;
/* create a struct security_descriptor and contained information in one contiguous piece of memory */
static NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
data_size_t *ret_len )
......@@ -781,3 +784,90 @@ NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeou
}
return STATUS_SUCCESS;
}
/******************************************************************************
* NtCreateKeyedEvent (NTDLL.@)
*/
NTSTATUS WINAPI NtCreateKeyedEvent( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, ULONG flags )
{
NTSTATUS ret;
data_size_t len;
struct object_attributes *objattr;
if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;
SERVER_START_REQ( create_keyed_event )
{
req->access = access;
wine_server_add_data( req, objattr, len );
ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
RtlFreeHeap( GetProcessHeap(), 0, objattr );
return ret;
}
/******************************************************************************
* NtOpenKeyedEvent (NTDLL.@)
*/
NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{
NTSTATUS ret;
if ((ret = validate_open_object_attributes( attr ))) return ret;
SERVER_START_REQ( open_keyed_event )
{
req->access = access;
req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr->RootDirectory );
if (attr->ObjectName)
wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
ret = wine_server_call( req );
*handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
return ret;
}
/******************************************************************************
* NtWaitForKeyedEvent (NTDLL.@)
*/
NTSTATUS WINAPI NtWaitForKeyedEvent( HANDLE handle, const void *key,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
select_op_t select_op;
UINT flags = SELECT_INTERRUPTIBLE;
if (!handle) handle = keyed_event;
if ((ULONG_PTR)key & 1) return STATUS_INVALID_PARAMETER_1;
if (alertable) flags |= SELECT_ALERTABLE;
select_op.keyed_event.op = SELECT_KEYED_EVENT_WAIT;
select_op.keyed_event.handle = wine_server_obj_handle( handle );
select_op.keyed_event.key = wine_server_client_ptr( key );
return server_wait( &select_op, sizeof(select_op.keyed_event), flags, timeout );
}
/******************************************************************************
* NtReleaseKeyedEvent (NTDLL.@)
*/
NTSTATUS WINAPI NtReleaseKeyedEvent( HANDLE handle, const void *key,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
select_op_t select_op;
UINT flags = SELECT_INTERRUPTIBLE;
if (!handle) handle = keyed_event;
if ((ULONG_PTR)key & 1) return STATUS_INVALID_PARAMETER_1;
if (alertable) flags |= SELECT_ALERTABLE;
select_op.keyed_event.op = SELECT_KEYED_EVENT_RELEASE;
select_op.keyed_event.handle = wine_server_obj_handle( handle );
select_op.keyed_event.key = wine_server_client_ptr( key );
return server_wait( &select_op, sizeof(select_op.keyed_event), flags, timeout );
}
......@@ -108,6 +108,7 @@ TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZ
server_init_process();
info_size = server_init_thread( teb->Peb, suspend );
virtual_map_user_shared_data();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
if (size) *size = info_size;
if (cpus) *cpus = server_cpus;
......
......@@ -112,6 +112,7 @@ extern const char *build_dir DECLSPEC_HIDDEN;
extern const char *config_dir DECLSPEC_HIDDEN;
extern unsigned int server_cpus DECLSPEC_HIDDEN;
extern BOOL is_wow64 DECLSPEC_HIDDEN;
extern HANDLE keyed_event DECLSPEC_HIDDEN;
extern timeout_t server_start_time DECLSPEC_HIDDEN;
extern sigset_t server_block_set DECLSPEC_HIDDEN;
extern SIZE_T signal_stack_size DECLSPEC_HIDDEN;
......
......@@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 25
#define NTDLL_UNIXLIB_VERSION 26
struct unix_funcs
{
......@@ -41,6 +41,8 @@ struct unix_funcs
NTSTATUS (WINAPI *NtClose)( HANDLE handle );
NTSTATUS (WINAPI *NtCreateEvent)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, EVENT_TYPE type, BOOLEAN state );
NTSTATUS (WINAPI *NtCreateKeyedEvent)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, ULONG flags );
NTSTATUS (WINAPI *NtCreateMutant)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, BOOLEAN owned );
NTSTATUS (WINAPI *NtCreateSemaphore)( HANDLE *handle, ACCESS_MASK access,
......@@ -66,6 +68,8 @@ struct unix_funcs
SECTION_INHERIT inherit, ULONG alloc_type, ULONG protect );
NTSTATUS (WINAPI *NtOpenEvent)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr );
NTSTATUS (WINAPI *NtOpenKeyedEvent)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr );
NTSTATUS (WINAPI *NtOpenMutant)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr );
NTSTATUS (WINAPI *NtOpenSemaphore)( HANDLE *handle, ACCESS_MASK access,
......@@ -90,6 +94,8 @@ struct unix_funcs
PVOID buffer, SIZE_T len, SIZE_T *res_len );
NTSTATUS (WINAPI *NtReadVirtualMemory)( HANDLE process, const void *addr, void *buffer,
SIZE_T size, SIZE_T *bytes_read );
NTSTATUS (WINAPI *NtReleaseKeyedEvent)( HANDLE handle, const void *key,
BOOLEAN alertable, const LARGE_INTEGER *timeout );
NTSTATUS (WINAPI *NtReleaseMutant)( HANDLE handle, LONG *prev_count );
NTSTATUS (WINAPI *NtReleaseSemaphore)( HANDLE handle, ULONG count, ULONG *previous );
NTSTATUS (WINAPI *NtResetEvent)( HANDLE handle, LONG *prev_state );
......@@ -105,6 +111,8 @@ struct unix_funcs
NTSTATUS (WINAPI *NtUnlockVirtualMemory)( HANDLE process, PVOID *addr,
SIZE_T *size, ULONG unknown );
NTSTATUS (WINAPI *NtUnmapViewOfSection)( HANDLE process, PVOID addr );
NTSTATUS (WINAPI *NtWaitForKeyedEvent)( HANDLE handle, const void *key, BOOLEAN alertable,
const LARGE_INTEGER *timeout );
NTSTATUS (WINAPI *NtWaitForMultipleObjects)( DWORD count, const HANDLE *handles,
BOOLEAN wait_any, BOOLEAN alertable,
const LARGE_INTEGER *timeout );
......
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