[PATCH 2/3] server: Create pipe ends as named objects under the named pipe device.

Zebediah Figura z.figura12 at gmail.com
Sun Aug 16 19:36:04 CDT 2020


Based on a patch by Sebastian Lackner.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/tests/om.c |  3 ++-
 server/named_pipe.c   | 27 +++++++++++++++++++++------
 server/object.c       |  6 +++---
 server/object.h       |  3 +++
 4 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 916ac8cbe76..ef050b062b2 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -1443,7 +1443,7 @@ static void test_query_object(void)
                                1, 1000, 1000, 1000, NULL );
     ok( handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed err %u\n", GetLastError() );
 
-    test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe", TRUE );
+    test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe", FALSE );
     test_object_type( handle, L"File" );
     test_file_info( handle );
 
@@ -1451,6 +1451,7 @@ static void test_query_object(void)
                           0, NULL, OPEN_EXISTING, 0, 0 );
     ok( client != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError() );
 
+    test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe", FALSE );
     test_object_type( client, L"File" );
     test_file_info( client );
 
diff --git a/server/named_pipe.c b/server/named_pipe.c
index e7e5436c0e5..2c7c45c2336 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -140,6 +140,8 @@ static struct fd *pipe_end_get_fd( struct object *obj );
 static struct security_descriptor *pipe_end_get_sd( struct object *obj );
 static int pipe_end_set_sd( struct object *obj, const struct security_descriptor *sd,
                             unsigned int set_info );
+static int pipe_end_link_name( struct object *obj, struct object_name *name, struct object *parent );
+static void pipe_end_unlink_name( struct object *obj, struct object_name *name );
 static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos );
 static int pipe_end_write( struct fd *fd, struct async *async_data, file_pos_t pos );
 static int pipe_end_flush( struct fd *fd, struct async *async );
@@ -167,8 +169,8 @@ static const struct object_ops pipe_server_ops =
     pipe_end_get_sd,              /* get_sd */
     pipe_end_set_sd,              /* set_sd */
     no_lookup_name,               /* lookup_name */
-    no_link_name,                 /* link_name */
-    NULL,                         /* unlink_name */
+    pipe_end_link_name,           /* link_name */
+    pipe_end_unlink_name,         /* unlink_name */
     no_open_file,                 /* open_file */
     no_kernel_obj_list,           /* get_kernel_obj_list */
     fd_close_handle,              /* close_handle */
@@ -209,8 +211,8 @@ static const struct object_ops pipe_client_ops =
     pipe_end_get_sd,              /* get_sd */
     pipe_end_set_sd,              /* set_sd */
     no_lookup_name,               /* lookup_name */
-    no_link_name,                 /* link_name */
-    NULL,                         /* unlink_name */
+    pipe_end_link_name,           /* link_name */
+    pipe_end_unlink_name,         /* unlink_name */
     no_open_file,                 /* open_file */
     no_kernel_obj_list,           /* get_kernel_obj_list */
     fd_close_handle,              /* close_handle */
@@ -699,6 +701,17 @@ static int pipe_end_set_sd( struct object *obj, const struct security_descriptor
     return 0;
 }
 
+static int pipe_end_link_name( struct object *obj, struct object_name *name, struct object *parent )
+{
+    assert( parent->ops == &named_pipe_device_ops );
+    name->parent = grab_object( parent );
+    return 1;
+}
+
+static void pipe_end_unlink_name( struct object *obj, struct object_name *name )
+{
+}
+
 static void pipe_end_get_volume_info( struct fd *fd, unsigned int info_class )
 {
     switch (info_class)
@@ -1185,9 +1198,10 @@ static void init_pipe_end( struct pipe_end *pipe_end, struct named_pipe *pipe,
 static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned int options,
                                                unsigned int pipe_flags )
 {
+    struct unicode_str name = { pipe->obj.name->name, pipe->obj.name->len };
     struct pipe_server *server;
 
-    server = alloc_object( &pipe_server_ops );
+    server = create_object( pipe->obj.name->parent, &pipe_server_ops, &name, 0, NULL );
     if (!server)
         return NULL;
 
@@ -1211,9 +1225,10 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned
 
 static struct pipe_end *create_pipe_client( struct named_pipe *pipe, data_size_t buffer_size, unsigned int options )
 {
+    struct unicode_str name = { pipe->obj.name->name, pipe->obj.name->len };
     struct pipe_end *client;
 
-    client = alloc_object( &pipe_client_ops );
+    client = create_object( pipe->obj.name->parent, &pipe_client_ops, &name, 0, NULL );
     if (!client)
         return NULL;
 
diff --git a/server/object.c b/server/object.c
index 8ec6609f69d..165e215be2b 100644
--- a/server/object.c
+++ b/server/object.c
@@ -277,9 +277,9 @@ data_size_t get_path_element( const WCHAR *name, data_size_t len )
     return i * sizeof(WCHAR);
 }
 
-static struct object *create_object( struct object *parent, const struct object_ops *ops,
-                                     const struct unicode_str *name, unsigned int attributes,
-                                     const struct security_descriptor *sd )
+void *create_object( struct object *parent, const struct object_ops *ops,
+                     const struct unicode_str *name, unsigned int attributes,
+                     const struct security_descriptor *sd )
 {
     struct object *obj;
     struct object_name *name_ptr;
diff --git a/server/object.h b/server/object.h
index 1f5c4a5f061..a6a5e2c5f8f 100644
--- a/server/object.h
+++ b/server/object.h
@@ -137,6 +137,9 @@ extern void dump_object_name( struct object *obj );
 extern struct object *lookup_named_object( struct object *root, const struct unicode_str *name,
                                            unsigned int attr, struct unicode_str *name_left );
 extern data_size_t get_path_element( const WCHAR *name, data_size_t len );
+extern void *create_object( struct object *parent, const struct object_ops *ops,
+                            const struct unicode_str *name, unsigned int attributes,
+                            const struct security_descriptor *sd );
 extern void *create_named_object( struct object *parent, const struct object_ops *ops,
                                   const struct unicode_str *name, unsigned int attributes,
                                   const struct security_descriptor *sd );
-- 
2.27.0




More information about the wine-devel mailing list