Alexandre Julliard : server: Add a function to open a named object inside any parent, not only directories.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 8 10:09:20 CST 2016
Module: wine
Branch: master
Commit: 7a5b14d456d8b86265bbc823048952da3f3dc2ae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7a5b14d456d8b86265bbc823048952da3f3dc2ae
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Feb 8 16:53:31 2016 +0900
server: Add a function to open a named object inside any parent, not only directories.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/tests/winstation.c | 2 --
server/directory.c | 16 +---------------
server/object.c | 21 +++++++++++++++++++++
server/object.h | 2 ++
server/winstation.c | 4 +---
5 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/dlls/user32/tests/winstation.c b/dlls/user32/tests/winstation.c
index 7f87eb5..20d68b2 100644
--- a/dlls/user32/tests/winstation.c
+++ b/dlls/user32/tests/winstation.c
@@ -278,7 +278,6 @@ static void test_handles(void)
SetLastError( 0xdeadbeef );
d2 = OpenDesktopA( "", 0, TRUE, DESKTOP_ALL_ACCESS );
ok( !d2, "open mepty desktop succeeded\n" );
- todo_wine
ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
@@ -289,7 +288,6 @@ static void test_handles(void)
SetLastError( 0xdeadbeef );
d2 = OpenDesktopA( "foo\\bar", 0, TRUE, DESKTOP_ALL_ACCESS );
ok( !d2, "open desktop succeeded\n" );
- todo_wine
ok( GetLastError() == ERROR_BAD_PATHNAME, "wrong error %u\n", GetLastError() );
d2 = CreateDesktopA( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
diff --git a/server/directory.c b/server/directory.c
index 9b85ac7..15ace1e 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -261,21 +261,7 @@ void *create_named_object_dir( struct directory *root, const struct unicode_str
void *open_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops )
{
- struct unicode_str name_left;
- struct object *obj;
-
- if ((obj = find_object_dir( root, name, attr, &name_left )))
- {
- if (name_left.len) /* not fully parsed */
- set_error( STATUS_OBJECT_NAME_NOT_FOUND );
- else if (ops && obj->ops != ops)
- set_error( STATUS_OBJECT_TYPE_MISMATCH );
- else
- return obj;
-
- release_object( obj );
- }
- return NULL;
+ return open_named_object( &root->obj, ops, name, attr );
}
/* retrieve an object type, creating it if needed */
diff --git a/server/object.c b/server/object.c
index c8e799b..6137c7a 100644
--- a/server/object.c
+++ b/server/object.c
@@ -316,6 +316,27 @@ void *create_named_object( struct object *parent, const struct object_ops *ops,
return new_obj;
}
+/* open a object by name under the specified parent */
+void *open_named_object( struct object *parent, const struct object_ops *ops,
+ const struct unicode_str *name, unsigned int attributes )
+{
+ struct unicode_str name_left;
+ struct object *obj;
+
+ if ((obj = lookup_named_object( parent, name, attributes, &name_left )))
+ {
+ if (name_left.len) /* not fully parsed */
+ set_error( STATUS_OBJECT_NAME_NOT_FOUND );
+ else if (ops && obj->ops != ops)
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ else
+ return obj;
+
+ release_object( obj );
+ }
+ return NULL;
+}
+
/* recursive helper for dump_object_name */
static void dump_name( struct object *obj )
{
diff --git a/server/object.h b/server/object.h
index 287015e..f51fc71 100644
--- a/server/object.h
+++ b/server/object.h
@@ -138,6 +138,8 @@ extern void *create_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name );
extern void *create_named_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name, unsigned int attributes );
+extern void *open_named_object( struct object *parent, const struct object_ops *ops,
+ const struct unicode_str *name, unsigned int attributes );
extern void unlink_named_object( struct object *obj );
extern void make_object_static( struct object *obj );
extern struct namespace *create_namespace( unsigned int hash_size );
diff --git a/server/winstation.c b/server/winstation.c
index 4131a82..6cfbf1d 100644
--- a/server/winstation.c
+++ b/server/winstation.c
@@ -534,13 +534,11 @@ DECL_HANDLER(open_desktop)
if (!winstation) return;
- if ((obj = find_object( winstation->desktop_names, &name, req->attributes )))
+ if ((obj = open_named_object( &winstation->obj, &desktop_ops, &name, req->attributes )))
{
- assert( obj->ops == &desktop_ops );
reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
release_object( obj );
}
- else set_error( STATUS_OBJECT_NAME_NOT_FOUND );
release_object( winstation );
}
More information about the wine-cvs
mailing list