- 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
diff --git a/server/event.c b/server/event.c
index bc1b5a4..e1487d3 100644
--- a/server/event.c
+++ b/server/event.c
@@ -132,7 +132,7 @@
if ((event = create_event( get_req_data(), get_req_data_size(),
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 );
}
}
diff --git a/server/mutex.c b/server/mutex.c
index 1bb07eb..af13dd9 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -156,7 +156,7 @@
reply->handle = 0;
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 );
}
}
@@ -177,7 +177,11 @@
MUTEX_MODIFY_STATE, &mutex_ops )))
{
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 );
}
}
diff --git a/server/protocol.def b/server/protocol.def
index e4b8e98..7f21d4b 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -491,6 +491,7 @@
/* Create an event */
@REQ(create_event)
+ unsigned int access; /* wanted access rights */
int manual_reset; /* manual reset event */
int initial_state; /* initial state of the event */
int inherit; /* inherit flag */
@@ -519,6 +520,7 @@
/* Create a mutex */
@REQ(create_mutex)
+ unsigned int access; /* wanted access rights */
int owned; /* initially owned? */
int inherit; /* inherit flag */
VARARG(name,unicode_str); /* object name */
@@ -530,6 +532,8 @@
/* Release a mutex */
@REQ(release_mutex)
obj_handle_t handle; /* handle to the mutex */
+@REPLY
+ unsigned int prev_count; /* value of internal counter, before release */
@END
@@ -545,6 +549,7 @@
/* Create a semaphore */
@REQ(create_semaphore)
+ unsigned int access; /* wanted access rights */
unsigned int initial; /* initial count */
unsigned int max; /* maximum count */
int inherit; /* inherit flag */
@@ -1337,6 +1342,7 @@
/* Create a waitable timer */
@REQ(create_timer)
+ unsigned int access; /* wanted access rights */
int inherit; /* inherit flag */
int manual; /* manual reset */
VARARG(name,unicode_str); /* object name */
diff --git a/server/semaphore.c b/server/semaphore.c
index 599ce68..27aba0d 100644
--- a/server/semaphore.c
+++ b/server/semaphore.c
@@ -139,7 +139,7 @@
if ((sem = create_semaphore( get_req_data(), get_req_data_size(),
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 );
}
}
diff --git a/server/timer.c b/server/timer.c
index bc7eb45..ef07f2a 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -204,7 +204,7 @@
reply->handle = 0;
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 );
}
}
diff --git a/server/trace.c b/server/trace.c
index 99c20f5..8e458b2 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -752,6 +752,7 @@
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, " initial_state=%d,", req->initial_state );
fprintf( stderr, " inherit=%d,", req->inherit );
@@ -785,6 +786,7 @@
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, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" );
@@ -801,6 +803,11 @@
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 )
{
fprintf( stderr, " access=%08x,", req->access );
@@ -816,6 +823,7 @@
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, " max=%08x,", req->max );
fprintf( stderr, " inherit=%d,", req->inherit );
@@ -1633,6 +1641,7 @@
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, " manual=%d,", req->manual );
fprintf( stderr, " name=" );
@@ -2765,7 +2774,7 @@
(dump_func)0,
(dump_func)dump_open_event_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_create_semaphore_reply,
(dump_func)dump_release_semaphore_reply,