Move timer objects into directory name space.

Vitaliy Margolen wine-patch at kievinfo.com
Thu Dec 1 17:31:00 CST 2005


ChangeLog:
Move timer objects into directory name space.

 dlls/kernel/sync.c  |    4 ++--
 dlls/ntdll/sync.c   |    2 ++
 server/protocol.def |    2 ++
 server/timer.c      |   22 +++++++++++++++++-----
 4 files changed, 23 insertions(+), 7 deletions(-)
-------------- next part --------------
81735878ea1b8c2bd1ecc5a085c1701310992778
diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c
index d8284be..1e839fc 100644
--- a/dlls/kernel/sync.c
+++ b/dlls/kernel/sync.c
@@ -911,7 +911,7 @@ HANDLE WINAPI CreateWaitableTimerW( SECU
     OBJECT_ATTRIBUTES attr;
 
     attr.Length                   = sizeof(attr);
-    attr.RootDirectory            = 0;
+    attr.RootDirectory            = get_BaseNamedObjects_handle();
     attr.ObjectName               = NULL;
     attr.Attributes               = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
                                     ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
@@ -964,7 +964,7 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD 
     if (!is_version_nt()) access = TIMER_ALL_ACCESS;
 
     attr.Length                   = sizeof(attr);
-    attr.RootDirectory            = 0;
+    attr.RootDirectory            = get_BaseNamedObjects_handle();
     attr.ObjectName               = NULL;
     attr.Attributes               = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
     attr.SecurityDescriptor       = NULL;
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index fd8898f..e7e64dd 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -422,6 +422,7 @@ NTSTATUS WINAPI NtCreateTimer(OUT HANDLE
     {
         req->access  = access;
         req->attributes = (attr) ? attr->Attributes : 0;
+        req->rootdir = (attr) ? attr->RootDirectory : 0;
         req->manual  = (timer_type == NotificationTimer) ? TRUE : FALSE;
         if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
         status = wine_server_call( req );
@@ -449,6 +450,7 @@ NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE 
     {
         req->access  = access;
         req->attributes = (attr) ? attr->Attributes : 0;
+        req->rootdir = (attr) ? attr->RootDirectory : 0;
         if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
         status = wine_server_call( req );
         *handle = reply->handle;
diff --git a/server/protocol.def b/server/protocol.def
index 1cdb246..297313c 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1362,6 +1362,7 @@ enum char_info_mode
 @REQ(create_timer)
     unsigned int access;        /* wanted access rights */
     unsigned int attributes;    /* object attributes */
+    obj_handle_t rootdir;       /* root directory */
     int          manual;        /* manual reset */
     VARARG(name,unicode_str);   /* object name */
 @REPLY
@@ -1373,6 +1374,7 @@ enum char_info_mode
 @REQ(open_timer)
     unsigned int access;        /* wanted access rights */
     unsigned int attributes;    /* object attributes */
+    obj_handle_t rootdir;       /* root directory */
     VARARG(name,unicode_str);   /* object name */
 @REPLY
     obj_handle_t handle;        /* handle to the timer */
diff --git a/server/timer.c b/server/timer.c
index 2576dcd..74419e5 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -72,12 +72,12 @@ static const struct object_ops timer_ops
 
 
 /* create a timer object */
-static struct timer *create_timer( const struct unicode_str *name, unsigned int attr,
-                                   int manual )
+static struct timer *create_timer( struct directory *root, const struct unicode_str *name,
+                                   unsigned int attr, int manual )
 {
     struct timer *timer;
 
-    if ((timer = create_named_object( sync_namespace, &timer_ops, name, attr )))
+    if ((timer = create_named_object_dir( root, name, attr, &timer_ops )))
     {
         if (get_error() != STATUS_OBJECT_NAME_EXISTS)
         {
@@ -209,24 +209,36 @@ DECL_HANDLER(create_timer)
 {
     struct timer *timer;
     struct unicode_str name;
+    struct directory *root = NULL;
 
     reply->handle = 0;
     get_req_unicode_str( &name );
-    if ((timer = create_timer( &name, req->attributes, req->manual )))
+    if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
+        return;
+
+    if ((timer = create_timer( root, &name, req->attributes, req->manual )))
     {
         reply->handle = alloc_handle( current->process, timer, req->access,
                                       req->attributes & OBJ_INHERIT );
         release_object( timer );
     }
+
+    if (root) release_object( root );
 }
 
 /* open a handle to a timer */
 DECL_HANDLER(open_timer)
 {
     struct unicode_str name;
+    struct directory *root = NULL;
 
     get_req_unicode_str( &name );
-    reply->handle = open_object( sync_namespace, &name, &timer_ops, req->access, req->attributes );
+    if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
+        return;
+
+    reply->handle = open_object_dir( root, &name, req->attributes, &timer_ops, req->access );
+
+    if (root) release_object( root );
 }
 
 /* set a waitable timer */


More information about the wine-patches mailing list