Commit 44158dd6 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- moved event, semaphore, mutex implementation from kernel32 to ntdll

- added mutant implementation in ntdll, and use it for mutex implementation in kernel32 - added access parameter on event, semaphore, timer creation in wineserver (as ntdll interface requires it) - added missing definitions in include/winternl.h
parent 513d5087
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
@ stub NtCreateIoCompletion @ stub NtCreateIoCompletion
@ stdcall NtCreateKey(ptr long ptr long ptr long long) @ stdcall NtCreateKey(ptr long ptr long ptr long long)
@ stdcall NtCreateMailslotFile(long long long long long long long long) @ stdcall NtCreateMailslotFile(long long long long long long long long)
@ stub NtCreateMutant @ stdcall NtCreateMutant(ptr long ptr long)
@ stdcall NtCreateNamedPipeFile(ptr long ptr ptr long long long long long long long long long ptr) @ stdcall NtCreateNamedPipeFile(ptr long ptr ptr long long long long long long long long long ptr)
@ stdcall NtCreatePagingFile(long long long long) @ stdcall NtCreatePagingFile(long long long long)
@ stdcall NtCreatePort(ptr ptr long long long) @ stdcall NtCreatePort(ptr ptr long long long)
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
@ stdcall NtOpenFile(ptr long ptr ptr long long) @ stdcall NtOpenFile(ptr long ptr ptr long long)
@ stub NtOpenIoCompletion @ stub NtOpenIoCompletion
@ stdcall NtOpenKey(ptr long ptr) @ stdcall NtOpenKey(ptr long ptr)
@ stub NtOpenMutant @ stdcall NtOpenMutant(ptr long ptr)
@ stub NtOpenObjectAuditAlarm @ stub NtOpenObjectAuditAlarm
@ stub NtOpenProcess @ stub NtOpenProcess
@ stdcall NtOpenProcessToken(long long long) @ stdcall NtOpenProcessToken(long long long)
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
@ stub NtQueryIntervalProfile @ stub NtQueryIntervalProfile
@ stub NtQueryIoCompletion @ stub NtQueryIoCompletion
@ stdcall NtQueryKey (long long ptr long ptr) @ stdcall NtQueryKey (long long ptr long ptr)
@ stub NtQueryMutant @ stdcall NtQueryMutant(long long ptr long ptr)
@ stdcall NtQueryObject(long long long long long) @ stdcall NtQueryObject(long long long long long)
@ stub NtQueryOpenSubKeys @ stub NtQueryOpenSubKeys
@ stdcall NtQueryPerformanceCounter (long long) @ stdcall NtQueryPerformanceCounter (long long)
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
@ stdcall NtReadVirtualMemory(long ptr ptr long ptr) @ stdcall NtReadVirtualMemory(long ptr ptr long ptr)
@ stub NtRegisterNewDevice @ stub NtRegisterNewDevice
@ stdcall NtRegisterThreadTerminatePort(ptr) @ stdcall NtRegisterThreadTerminatePort(ptr)
@ stub NtReleaseMutant @ stdcall NtReleaseMutant(long ptr)
@ stub NtReleaseProcessMutant @ stub NtReleaseProcessMutant
@ stdcall NtReleaseSemaphore(long long ptr) @ stdcall NtReleaseSemaphore(long long ptr)
@ stub NtRemoveIoCompletion @ stub NtRemoveIoCompletion
...@@ -674,8 +674,8 @@ ...@@ -674,8 +674,8 @@
@ stub ZwCreateIoCompletion @ stub ZwCreateIoCompletion
@ stdcall ZwCreateKey(ptr long ptr long ptr long long) NtCreateKey @ stdcall ZwCreateKey(ptr long ptr long ptr long long) NtCreateKey
@ stdcall ZwCreateMailslotFile(long long long long long long long long) NtCreateMailslotFile @ stdcall ZwCreateMailslotFile(long long long long long long long long) NtCreateMailslotFile
@ stub ZwCreateMutant @ stdcall ZwCreateMutant(ptr long ptr long) NtCreateMutant
@ stub ZwCreateNamedPipeFile @ stdcall ZwCreateNamedPipeFile(ptr long ptr ptr long long long long long long long long long ptr) NtCreateNamedPipeFile
@ stdcall ZwCreatePagingFile(long long long long) NtCreatePagingFile @ stdcall ZwCreatePagingFile(long long long long) NtCreatePagingFile
@ stdcall ZwCreatePort(ptr ptr long long long) NtCreatePort @ stdcall ZwCreatePort(ptr ptr long long long) NtCreatePort
@ stub ZwCreateProcess @ stub ZwCreateProcess
...@@ -726,7 +726,7 @@ ...@@ -726,7 +726,7 @@
@ stdcall ZwOpenFile(ptr long ptr ptr long long) NtOpenFile @ stdcall ZwOpenFile(ptr long ptr ptr long long) NtOpenFile
@ stub ZwOpenIoCompletion @ stub ZwOpenIoCompletion
@ stdcall ZwOpenKey(ptr long ptr) NtOpenKey @ stdcall ZwOpenKey(ptr long ptr) NtOpenKey
@ stub ZwOpenMutant @ stdcall ZwOpenMutant(ptr long ptr) NtOpenMutant
@ stub ZwOpenObjectAuditAlarm @ stub ZwOpenObjectAuditAlarm
@ stub ZwOpenProcess @ stub ZwOpenProcess
@ stdcall ZwOpenProcessToken(long long long) NtOpenProcessToken @ stdcall ZwOpenProcessToken(long long long) NtOpenProcessToken
...@@ -758,7 +758,7 @@ ...@@ -758,7 +758,7 @@
@ stub ZwQueryIntervalProfile @ stub ZwQueryIntervalProfile
@ stub ZwQueryIoCompletion @ stub ZwQueryIoCompletion
@ stdcall ZwQueryKey(long long ptr long ptr) NtQueryKey @ stdcall ZwQueryKey(long long ptr long ptr) NtQueryKey
@ stub ZwQueryMutant @ stdcall ZwQueryMutant(long long ptr long ptr) NtQueryMutant
@ stdcall ZwQueryObject(long long long long long) NtQueryObject @ stdcall ZwQueryObject(long long long long long) NtQueryObject
@ stub ZwQueryOpenSubKeys @ stub ZwQueryOpenSubKeys
@ stdcall ZwQueryPerformanceCounter (long long) NtQueryPerformanceCounter @ stdcall ZwQueryPerformanceCounter (long long) NtQueryPerformanceCounter
...@@ -781,7 +781,7 @@ ...@@ -781,7 +781,7 @@
@ stdcall ZwReadVirtualMemory(long ptr ptr long ptr) NtReadVirtualMemory @ stdcall ZwReadVirtualMemory(long ptr ptr long ptr) NtReadVirtualMemory
@ stub ZwRegisterNewDevice @ stub ZwRegisterNewDevice
@ stdcall ZwRegisterThreadTerminatePort(ptr) NtRegisterThreadTerminatePort @ stdcall ZwRegisterThreadTerminatePort(ptr) NtRegisterThreadTerminatePort
@ stub ZwReleaseMutant @ stdcall ZwReleaseMutant(long ptr) NtReleaseMutant
@ stub ZwReleaseProcessMutant @ stub ZwReleaseProcessMutant
@ stdcall ZwReleaseSemaphore(long long ptr) NtReleaseSemaphore @ stdcall ZwReleaseSemaphore(long long ptr) NtReleaseSemaphore
@ stub ZwRemoveIoCompletion @ stub ZwRemoveIoCompletion
......
...@@ -71,17 +71,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll); ...@@ -71,17 +71,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
IN ACCESS_MASK access, IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES *attr OPTIONAL, IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
IN ULONG InitialCount, IN LONG InitialCount,
IN ULONG MaximumCount ) IN LONG MaximumCount )
{ {
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if ((MaximumCount <= 0) || (InitialCount > MaximumCount)) if (MaximumCount <= 0 || InitialCount < 0 || InitialCount > MaximumCount)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( create_semaphore ) SERVER_START_REQ( create_semaphore )
{ {
req->access = access;
req->initial = InitialCount; req->initial = InitialCount;
req->max = MaximumCount; req->max = MaximumCount;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
...@@ -103,6 +105,8 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle, ...@@ -103,6 +105,8 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( open_semaphore ) SERVER_START_REQ( open_semaphore )
{ {
req->access = access; req->access = access;
...@@ -167,8 +171,11 @@ NTSTATUS WINAPI NtCreateEvent( ...@@ -167,8 +171,11 @@ NTSTATUS WINAPI NtCreateEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( create_event ) SERVER_START_REQ( create_event )
{ {
req->access = DesiredAccess;
req->manual_reset = ManualReset; req->manual_reset = ManualReset;
req->initial_state = InitialState; req->initial_state = InitialState;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
...@@ -192,6 +199,8 @@ NTSTATUS WINAPI NtOpenEvent( ...@@ -192,6 +199,8 @@ NTSTATUS WINAPI NtOpenEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( open_event ) SERVER_START_REQ( open_event )
{ {
req->access = DesiredAccess; req->access = DesiredAccess;
...@@ -293,6 +302,94 @@ NTSTATUS WINAPI NtQueryEvent ( ...@@ -293,6 +302,94 @@ NTSTATUS WINAPI NtQueryEvent (
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/*
* Mutants (known as Mutexes in Kernel32)
*/
/******************************************************************************
* NtCreateMutant [NTDLL.@]
* ZwCreateMutant [NTDLL.@]
*/
NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle,
IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES* attr OPTIONAL,
IN BOOLEAN InitialOwner)
{
NTSTATUS status;
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( create_mutex )
{
req->access = access;
req->owned = InitialOwner;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req );
*MutantHandle = reply->handle;
}
SERVER_END_REQ;
return status;
}
/**************************************************************************
* NtOpenMutant [NTDLL.@]
* ZwOpenMutant [NTDLL.@]
*/
NTSTATUS WINAPI NtOpenMutant(OUT HANDLE* MutantHandle,
IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES* attr )
{
NTSTATUS status;
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( open_mutex )
{
req->access = access;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req );
*MutantHandle = reply->handle;
}
SERVER_END_REQ;
return status;
}
/**************************************************************************
* NtReleaseMutant [NTDLL.@]
* ZwReleaseMutant [NTDLL.@]
*/
NTSTATUS WINAPI NtReleaseMutant( IN HANDLE handle, OUT PLONG prev_count OPTIONAL)
{
NTSTATUS status;
SERVER_START_REQ( release_mutex )
{
req->handle = handle;
status = wine_server_call( req );
if (prev_count) *prev_count = reply->prev_count;
}
SERVER_END_REQ;
return status;
}
/******************************************************************
* NtQueryMutant [NTDLL.@]
* ZwQueryMutant [NTDLL.@]
*/
NTSTATUS WINAPI NtQueryMutant(IN HANDLE handle,
IN MUTANT_INFORMATION_CLASS MutantInformationClass,
OUT PVOID MutantInformation,
IN ULONG MutantInformationLength,
OUT PULONG ResultLength OPTIONAL )
{
FIXME("(%p %u %p %lu %p): stub!\n",
handle, MutantInformationClass, MutantInformation, MutantInformationLength, ResultLength);
return STATUS_NOT_IMPLEMENTED;
}
/* /*
* Timers * Timers
...@@ -304,20 +401,23 @@ NTSTATUS WINAPI NtQueryEvent ( ...@@ -304,20 +401,23 @@ NTSTATUS WINAPI NtQueryEvent (
*/ */
NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle, NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle,
IN ACCESS_MASK access, IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES *oa OPTIONAL, IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
IN TIMER_TYPE timer_type) IN TIMER_TYPE timer_type)
{ {
DWORD len = (oa && oa->ObjectName) ? oa->ObjectName->Length : 0; DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
NTSTATUS status; NTSTATUS status;
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
if (timer_type != NotificationTimer && timer_type != SynchronizationTimer) if (timer_type != NotificationTimer && timer_type != SynchronizationTimer)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( create_timer ) SERVER_START_REQ( create_timer )
{ {
req->access = access;
req->manual = (timer_type == NotificationTimer) ? TRUE : FALSE; req->manual = (timer_type == NotificationTimer) ? TRUE : FALSE;
req->inherit = oa && (oa->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) wine_server_add_data( req, oa->ObjectName->Buffer, len ); if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req ); status = wine_server_call( req );
*handle = reply->handle; *handle = reply->handle;
} }
...@@ -332,19 +432,18 @@ NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle, ...@@ -332,19 +432,18 @@ NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle,
*/ */
NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE handle, NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE handle,
IN ACCESS_MASK access, IN ACCESS_MASK access,
IN const OBJECT_ATTRIBUTES* oa ) IN const OBJECT_ATTRIBUTES* attr )
{ {
DWORD len = (oa && oa->ObjectName) ? oa->ObjectName->Length : 0; DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
NTSTATUS status; NTSTATUS status;
if (oa && oa->Length >= MAX_PATH * sizeof(WCHAR)) if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
return STATUS_NAME_TOO_LONG;
SERVER_START_REQ( open_timer ) SERVER_START_REQ( open_timer )
{ {
req->access = access; req->access = access;
req->inherit = oa && (oa->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) wine_server_add_data( req, oa->ObjectName->Buffer, len ); if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req ); status = wine_server_call( req );
*handle = reply->handle; *handle = reply->handle;
} }
......
...@@ -620,6 +620,7 @@ struct select_reply ...@@ -620,6 +620,7 @@ struct select_reply
struct create_event_request struct create_event_request
{ {
struct request_header __header; struct request_header __header;
unsigned int access;
int manual_reset; int manual_reset;
int initial_state; int initial_state;
int inherit; int inherit;
...@@ -664,6 +665,7 @@ struct open_event_reply ...@@ -664,6 +665,7 @@ struct open_event_reply
struct create_mutex_request struct create_mutex_request
{ {
struct request_header __header; struct request_header __header;
unsigned int access;
int owned; int owned;
int inherit; int inherit;
/* VARARG(name,unicode_str); */ /* VARARG(name,unicode_str); */
...@@ -684,6 +686,7 @@ struct release_mutex_request ...@@ -684,6 +686,7 @@ struct release_mutex_request
struct release_mutex_reply struct release_mutex_reply
{ {
struct reply_header __header; struct reply_header __header;
unsigned int prev_count;
}; };
...@@ -706,6 +709,7 @@ struct open_mutex_reply ...@@ -706,6 +709,7 @@ struct open_mutex_reply
struct create_semaphore_request struct create_semaphore_request
{ {
struct request_header __header; struct request_header __header;
unsigned int access;
unsigned int initial; unsigned int initial;
unsigned int max; unsigned int max;
int inherit; int inherit;
...@@ -1869,6 +1873,7 @@ struct set_registry_notification_reply ...@@ -1869,6 +1873,7 @@ struct set_registry_notification_reply
struct create_timer_request struct create_timer_request
{ {
struct request_header __header; struct request_header __header;
unsigned int access;
int inherit; int inherit;
int manual; int manual;
/* VARARG(name,unicode_str); */ /* VARARG(name,unicode_str); */
...@@ -3643,6 +3648,6 @@ union generic_reply ...@@ -3643,6 +3648,6 @@ union generic_reply
struct set_global_windows_reply set_global_windows_reply; struct set_global_windows_reply set_global_windows_reply;
}; };
#define SERVER_PROTOCOL_VERSION 150 #define SERVER_PROTOCOL_VERSION 151
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -621,6 +621,19 @@ typedef enum ...@@ -621,6 +621,19 @@ typedef enum
MemoryBasicInformation = 0 MemoryBasicInformation = 0
} MEMORY_INFORMATION_CLASS; } MEMORY_INFORMATION_CLASS;
typedef enum _MUTANT_INFORMATION_CLASS
{
MutantBasicInformation
} MUTANT_INFORMATION_CLASS, *PMUTANT_INFORMATION_CLASS;
typedef struct _MUTANT_BASIC_INFORMATION {
LONG CurrentCount;
BOOLEAN OwnedByCaller;
BOOLEAN AbandonedState;
} MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION;
/* return type of RtlDetermineDosPathNameType_U (FIXME: not the correct names) */ /* return type of RtlDetermineDosPathNameType_U (FIXME: not the correct names) */
typedef enum typedef enum
{ {
...@@ -1312,9 +1325,10 @@ NTSTATUS WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOO ...@@ -1312,9 +1325,10 @@ NTSTATUS WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOO
NTSTATUS WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG); NTSTATUS WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
NTSTATUS WINAPI NtCreateIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,ULONG); NTSTATUS WINAPI NtCreateIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,ULONG);
NTSTATUS WINAPI NtCreateKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG); NTSTATUS WINAPI NtCreateKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
NTSTATUS WINAPI NtCreateMutant(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,BOOLEAN);
NTSTATUS WINAPI NtCreateNamedPipeFile(PHANDLE,ULONG,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,PLARGE_INTEGER); NTSTATUS WINAPI NtCreateNamedPipeFile(PHANDLE,ULONG,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,PLARGE_INTEGER);
NTSTATUS WINAPI NtCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE); NTSTATUS WINAPI NtCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
NTSTATUS WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG); NTSTATUS WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,LONG,LONG);
NTSTATUS WINAPI NtCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE); NTSTATUS WINAPI NtCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE);
NTSTATUS WINAPI NtDelayExecution(BOOLEAN,const LARGE_INTEGER*); NTSTATUS WINAPI NtDelayExecution(BOOLEAN,const LARGE_INTEGER*);
NTSTATUS WINAPI NtDeleteFile(POBJECT_ATTRIBUTES); NTSTATUS WINAPI NtDeleteFile(POBJECT_ATTRIBUTES);
...@@ -1342,8 +1356,10 @@ NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *); ...@@ -1342,8 +1356,10 @@ NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG); NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
NTSTATUS WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSTATUS WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
NTSTATUS WINAPI NtOpenKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES *); NTSTATUS WINAPI NtOpenKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
NTSTATUS WINAPI NtOpenMutant(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSTATUS WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *); NTSTATUS WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *);
NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSTATUS WINAPI NtOpenSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
NTSTATUS WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*); NTSTATUS WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
NTSTATUS WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *); NTSTATUS WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
NTSTATUS WINAPI NtOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*); NTSTATUS WINAPI NtOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*);
...@@ -1373,6 +1389,7 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULON ...@@ -1373,6 +1389,7 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULON
void WINAPI NtRaiseException(PEXCEPTION_RECORD,PCONTEXT,BOOL); void WINAPI NtRaiseException(PEXCEPTION_RECORD,PCONTEXT,BOOL);
NTSTATUS WINAPI NtReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG); NTSTATUS WINAPI NtReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
NTSTATUS WINAPI NtReadVirtualMemory(HANDLE,const void*,void*,SIZE_T,SIZE_T*); NTSTATUS WINAPI NtReadVirtualMemory(HANDLE,const void*,void*,SIZE_T,SIZE_T*);
NTSTATUS WINAPI NtReleaseMutant(HANDLE,PLONG);
NTSTATUS WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG); NTSTATUS WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG);
NTSTATUS WINAPI NtRemoveIoCompletion(HANDLE,PULONG,PULONG,PIO_STATUS_BLOCK,PLARGE_INTEGER); NTSTATUS WINAPI NtRemoveIoCompletion(HANDLE,PULONG,PULONG,PIO_STATUS_BLOCK,PLARGE_INTEGER);
NTSTATUS WINAPI NtReplaceKey(POBJECT_ATTRIBUTES,HKEY,POBJECT_ATTRIBUTES); NTSTATUS WINAPI NtReplaceKey(POBJECT_ATTRIBUTES,HKEY,POBJECT_ATTRIBUTES);
......
...@@ -132,7 +132,7 @@ DECL_HANDLER(create_event) ...@@ -132,7 +132,7 @@ DECL_HANDLER(create_event)
if ((event = create_event( get_req_data(), get_req_data_size(), if ((event = create_event( get_req_data(), get_req_data_size(),
req->manual_reset, req->initial_state ))) req->manual_reset, req->initial_state )))
{ {
reply->handle = alloc_handle( current->process, event, EVENT_ALL_ACCESS, req->inherit ); reply->handle = alloc_handle( current->process, event, req->access, req->inherit );
release_object( event ); release_object( event );
} }
} }
......
...@@ -156,7 +156,7 @@ DECL_HANDLER(create_mutex) ...@@ -156,7 +156,7 @@ DECL_HANDLER(create_mutex)
reply->handle = 0; reply->handle = 0;
if ((mutex = create_mutex( get_req_data(), get_req_data_size(), req->owned ))) if ((mutex = create_mutex( get_req_data(), get_req_data_size(), req->owned )))
{ {
reply->handle = alloc_handle( current->process, mutex, MUTEX_ALL_ACCESS, req->inherit ); reply->handle = alloc_handle( current->process, mutex, req->access, req->inherit );
release_object( mutex ); release_object( mutex );
} }
} }
...@@ -177,7 +177,11 @@ DECL_HANDLER(release_mutex) ...@@ -177,7 +177,11 @@ DECL_HANDLER(release_mutex)
MUTEX_MODIFY_STATE, &mutex_ops ))) MUTEX_MODIFY_STATE, &mutex_ops )))
{ {
if (!mutex->count || (mutex->owner != current)) set_error( STATUS_MUTANT_NOT_OWNED ); if (!mutex->count || (mutex->owner != current)) set_error( STATUS_MUTANT_NOT_OWNED );
else if (!--mutex->count) do_release( mutex ); else
{
reply->prev_count = mutex->count;
if (!--mutex->count) do_release( mutex );
}
release_object( mutex ); release_object( mutex );
} }
} }
...@@ -491,6 +491,7 @@ enum apc_type { APC_NONE, APC_USER, APC_TIMER, APC_ASYNC, APC_ASYNC_IO }; ...@@ -491,6 +491,7 @@ enum apc_type { APC_NONE, APC_USER, APC_TIMER, APC_ASYNC, APC_ASYNC_IO };
/* Create an event */ /* Create an event */
@REQ(create_event) @REQ(create_event)
unsigned int access; /* wanted access rights */
int manual_reset; /* manual reset event */ int manual_reset; /* manual reset event */
int initial_state; /* initial state of the event */ int initial_state; /* initial state of the event */
int inherit; /* inherit flag */ int inherit; /* inherit flag */
...@@ -519,6 +520,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; ...@@ -519,6 +520,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
/* Create a mutex */ /* Create a mutex */
@REQ(create_mutex) @REQ(create_mutex)
unsigned int access; /* wanted access rights */
int owned; /* initially owned? */ int owned; /* initially owned? */
int inherit; /* inherit flag */ int inherit; /* inherit flag */
VARARG(name,unicode_str); /* object name */ VARARG(name,unicode_str); /* object name */
...@@ -530,6 +532,8 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; ...@@ -530,6 +532,8 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
/* Release a mutex */ /* Release a mutex */
@REQ(release_mutex) @REQ(release_mutex)
obj_handle_t handle; /* handle to the mutex */ obj_handle_t handle; /* handle to the mutex */
@REPLY
unsigned int prev_count; /* value of internal counter, before release */
@END @END
...@@ -545,6 +549,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; ...@@ -545,6 +549,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
/* Create a semaphore */ /* Create a semaphore */
@REQ(create_semaphore) @REQ(create_semaphore)
unsigned int access; /* wanted access rights */
unsigned int initial; /* initial count */ unsigned int initial; /* initial count */
unsigned int max; /* maximum count */ unsigned int max; /* maximum count */
int inherit; /* inherit flag */ int inherit; /* inherit flag */
...@@ -1337,6 +1342,7 @@ enum char_info_mode ...@@ -1337,6 +1342,7 @@ enum char_info_mode
/* Create a waitable timer */ /* Create a waitable timer */
@REQ(create_timer) @REQ(create_timer)
unsigned int access; /* wanted access rights */
int inherit; /* inherit flag */ int inherit; /* inherit flag */
int manual; /* manual reset */ int manual; /* manual reset */
VARARG(name,unicode_str); /* object name */ VARARG(name,unicode_str); /* object name */
......
...@@ -139,7 +139,7 @@ DECL_HANDLER(create_semaphore) ...@@ -139,7 +139,7 @@ DECL_HANDLER(create_semaphore)
if ((sem = create_semaphore( get_req_data(), get_req_data_size(), if ((sem = create_semaphore( get_req_data(), get_req_data_size(),
req->initial, req->max ))) req->initial, req->max )))
{ {
reply->handle = alloc_handle( current->process, sem, SEMAPHORE_ALL_ACCESS, req->inherit ); reply->handle = alloc_handle( current->process, sem, req->access, req->inherit );
release_object( sem ); release_object( sem );
} }
} }
......
...@@ -204,7 +204,7 @@ DECL_HANDLER(create_timer) ...@@ -204,7 +204,7 @@ DECL_HANDLER(create_timer)
reply->handle = 0; reply->handle = 0;
if ((timer = create_timer( get_req_data(), get_req_data_size(), req->manual ))) if ((timer = create_timer( get_req_data(), get_req_data_size(), req->manual )))
{ {
reply->handle = alloc_handle( current->process, timer, TIMER_ALL_ACCESS, req->inherit ); reply->handle = alloc_handle( current->process, timer, req->access, req->inherit );
release_object( timer ); release_object( timer );
} }
} }
......
...@@ -752,6 +752,7 @@ static void dump_select_request( const struct select_request *req ) ...@@ -752,6 +752,7 @@ static void dump_select_request( const struct select_request *req )
static void dump_create_event_request( const struct create_event_request *req ) static void dump_create_event_request( const struct create_event_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " manual_reset=%d,", req->manual_reset ); fprintf( stderr, " manual_reset=%d,", req->manual_reset );
fprintf( stderr, " initial_state=%d,", req->initial_state ); fprintf( stderr, " initial_state=%d,", req->initial_state );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
...@@ -785,6 +786,7 @@ static void dump_open_event_reply( const struct open_event_reply *req ) ...@@ -785,6 +786,7 @@ static void dump_open_event_reply( const struct open_event_reply *req )
static void dump_create_mutex_request( const struct create_mutex_request *req ) static void dump_create_mutex_request( const struct create_mutex_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " owned=%d,", req->owned ); fprintf( stderr, " owned=%d,", req->owned );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
...@@ -801,6 +803,11 @@ static void dump_release_mutex_request( const struct release_mutex_request *req ...@@ -801,6 +803,11 @@ static void dump_release_mutex_request( const struct release_mutex_request *req
fprintf( stderr, " handle=%p", req->handle ); fprintf( stderr, " handle=%p", req->handle );
} }
static void dump_release_mutex_reply( const struct release_mutex_reply *req )
{
fprintf( stderr, " prev_count=%08x", req->prev_count );
}
static void dump_open_mutex_request( const struct open_mutex_request *req ) static void dump_open_mutex_request( const struct open_mutex_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
...@@ -816,6 +823,7 @@ static void dump_open_mutex_reply( const struct open_mutex_reply *req ) ...@@ -816,6 +823,7 @@ static void dump_open_mutex_reply( const struct open_mutex_reply *req )
static void dump_create_semaphore_request( const struct create_semaphore_request *req ) static void dump_create_semaphore_request( const struct create_semaphore_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " initial=%08x,", req->initial ); fprintf( stderr, " initial=%08x,", req->initial );
fprintf( stderr, " max=%08x,", req->max ); fprintf( stderr, " max=%08x,", req->max );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
...@@ -1633,6 +1641,7 @@ static void dump_set_registry_notification_request( const struct set_registry_no ...@@ -1633,6 +1641,7 @@ static void dump_set_registry_notification_request( const struct set_registry_no
static void dump_create_timer_request( const struct create_timer_request *req ) static void dump_create_timer_request( const struct create_timer_request *req )
{ {
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " manual=%d,", req->manual ); fprintf( stderr, " manual=%d,", req->manual );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
...@@ -2765,7 +2774,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { ...@@ -2765,7 +2774,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)0, (dump_func)0,
(dump_func)dump_open_event_reply, (dump_func)dump_open_event_reply,
(dump_func)dump_create_mutex_reply, (dump_func)dump_create_mutex_reply,
(dump_func)0, (dump_func)dump_release_mutex_reply,
(dump_func)dump_open_mutex_reply, (dump_func)dump_open_mutex_reply,
(dump_func)dump_create_semaphore_reply, (dump_func)dump_create_semaphore_reply,
(dump_func)dump_release_semaphore_reply, (dump_func)dump_release_semaphore_reply,
......
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