From 7c5cb7a229a9058bdee08c40d20401670e2f05f8 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Fri, 2 Dec 2005 16:05:54 +0100 Subject: [PATCH] Move timer objects into directory name space. --- dlls/kernel/sync.c | 2 ++ dlls/ntdll/sync.c | 2 ++ include/wine/server_protocol.h | 4 +++- server/protocol.def | 2 ++ server/timer.c | 22 +++++++++++++++++----- server/trace.c | 2 ++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c index 54f95a7a73d..0c340984b4d 100644 --- a/dlls/kernel/sync.c +++ b/dlls/kernel/sync.c @@ -927,6 +927,7 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST { RtlInitUnicodeString( &nameW, name ); attr.ObjectName = &nameW; + attr.RootDirectory = get_BaseNamedObjects_handle(); } status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &attr, @@ -979,6 +980,7 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name ) { RtlInitUnicodeString( &nameW, name ); attr.ObjectName = &nameW; + attr.RootDirectory = get_BaseNamedObjects_handle(); } status = NtOpenTimer(&handle, access, &attr); diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index 675b9b71373..3cf448fc176 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -422,6 +422,7 @@ NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *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 handle, { 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/include/wine/server_protocol.h b/include/wine/server_protocol.h index c144f246523..982d8407043 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -1885,6 +1885,7 @@ struct create_timer_request struct request_header __header; unsigned int access; unsigned int attributes; + obj_handle_t rootdir; int manual; /* VARARG(name,unicode_str); */ }; @@ -1901,6 +1902,7 @@ struct open_timer_request struct request_header __header; unsigned int access; unsigned int attributes; + obj_handle_t rootdir; /* VARARG(name,unicode_str); */ }; struct open_timer_reply @@ -4308,6 +4310,6 @@ union generic_reply struct query_symlink_reply query_symlink_reply; }; -#define SERVER_PROTOCOL_VERSION 203 +#define SERVER_PROTOCOL_VERSION 204 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/protocol.def b/server/protocol.def index a691e90d53a..42282581692 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1360,6 +1360,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 @@ -1371,6 +1372,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 2576dcd8e09..74419e5ad37 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 */ diff --git a/server/trace.c b/server/trace.c index e50e71ab2e8..3d4983ac435 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1798,6 +1798,7 @@ static void dump_create_timer_request( const struct create_timer_request *req ) { fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " attributes=%08x,", req->attributes ); + fprintf( stderr, " rootdir=%p,", req->rootdir ); fprintf( stderr, " manual=%d,", req->manual ); fprintf( stderr, " name=" ); dump_varargs_unicode_str( cur_size ); @@ -1812,6 +1813,7 @@ static void dump_open_timer_request( const struct open_timer_request *req ) { fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " attributes=%08x,", req->attributes ); + fprintf( stderr, " rootdir=%p,", req->rootdir ); fprintf( stderr, " name=" ); dump_varargs_unicode_str( cur_size ); }