Jacek Caban : server: Store IRP client pointer on server side.

Alexandre Julliard julliard at winehq.org
Tue May 28 15:06:51 CDT 2019


Module: wine
Branch: master
Commit: 101da2b5127ae698e79bca4ac0bfa780c785722b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=101da2b5127ae698e79bca4ac0bfa780c785722b

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 28 14:09:47 2019 +0200

server: Store IRP client pointer on server side.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntoskrnl.exe/ntoskrnl.c   | 10 +++++++---
 include/wine/server_protocol.h |  3 ++-
 server/device.c                |  6 ++++++
 server/protocol.def            |  1 +
 server/request.h               |  3 ++-
 server/trace.c                 |  1 +
 6 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 10cf2e2..1892809 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -557,6 +557,7 @@ struct dispatch_context
 {
     irp_params_t params;
     HANDLE handle;
+    IRP   *irp;
     ULONG  in_size;
     void  *in_buff;
 };
@@ -570,6 +571,7 @@ static void dispatch_irp( DEVICE_OBJECT *device, IRP *irp, struct dispatch_conte
 
     KeQueryTickCount( &count );  /* update the global KeTickCount */
 
+    context->irp = irp;
     device->CurrentIrp = irp;
     IoCallDriver( device, irp );
     device->CurrentIrp = NULL;
@@ -931,9 +933,10 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
 
         SERVER_START_REQ( get_next_device_request )
         {
-            req->manager = wine_server_obj_handle( manager );
-            req->prev = wine_server_obj_handle( context.handle );
-            req->status = status;
+            req->manager  = wine_server_obj_handle( manager );
+            req->prev     = wine_server_obj_handle( context.handle );
+            req->user_ptr = wine_server_client_ptr( context.irp );
+            req->status   = status;
             wine_server_set_reply( req, context.in_buff, context.in_size );
             if (!(status = wine_server_call( req )))
             {
@@ -949,6 +952,7 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
                 if (status == STATUS_BUFFER_OVERFLOW)
                     context.in_size = reply->in_size;
             }
+            context.irp = NULL;
         }
         SERVER_END_REQ;
 
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index a45d092..eab5755 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -5252,6 +5252,7 @@ struct get_next_device_request_request
     obj_handle_t manager;
     obj_handle_t prev;
     unsigned int status;
+    client_ptr_t user_ptr;
 };
 struct get_next_device_request_reply
 {
@@ -6694,6 +6695,6 @@ union generic_reply
     struct resume_process_reply resume_process_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 583
+#define SERVER_PROTOCOL_VERSION 584
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/device.c b/server/device.c
index d6ab1c5..e123583 100644
--- a/server/device.c
+++ b/server/device.c
@@ -52,6 +52,7 @@ struct irp_call
     struct async          *async;         /* pending async op */
     irp_params_t           params;        /* irp parameters */
     struct iosb           *iosb;          /* I/O status block */
+    client_ptr_t           user_ptr;      /* client side pointer */
 };
 
 static void irp_call_dump( struct object *obj, int verbose );
@@ -351,6 +352,7 @@ static struct irp_call *create_irp( struct device_file *file, const irp_params_t
         irp->async    = NULL;
         irp->params   = *params;
         irp->iosb     = NULL;
+        irp->user_ptr = 0;
 
         if (async) irp->iosb = async_get_iosb( async );
         if (!irp->iosb && !(irp->iosb = create_iosb( NULL, 0, 0 )))
@@ -886,13 +888,17 @@ DECL_HANDLER(get_next_device_request)
 
     if (req->prev) close_handle( current->process, req->prev );  /* avoid an extra round-trip for close */
 
+    /* process result of previous call */
     if (manager->current_call)
     {
         irp = manager->current_call;
+        irp->user_ptr = req->user_ptr;
+
         if (req->status)
             set_irp_result( irp, req->status, NULL, 0, 0 );
         else if (irp->async)
             set_async_pending( irp->async, irp->file && is_fd_overlapped( irp->file->fd ) );
+
         free_irp_params( irp );
         release_object( irp );
         manager->current_call = NULL;
diff --git a/server/protocol.def b/server/protocol.def
index 21008d7..6b6e868 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3633,6 +3633,7 @@ struct handle_info
     obj_handle_t manager;         /* handle to the device manager */
     obj_handle_t prev;            /* handle to the previous irp */
     unsigned int status;          /* status of the previous irp */
+    client_ptr_t user_ptr;        /* user pointer of the previous irp */
 @REPLY
     irp_params_t params;          /* irp parameters */
     obj_handle_t next;            /* handle to the next irp */
diff --git a/server/request.h b/server/request.h
index 07918df..1858b41 100644
--- a/server/request.h
+++ b/server/request.h
@@ -2287,7 +2287,8 @@ C_ASSERT( sizeof(struct delete_device_request) == 24 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, manager) == 12 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, prev) == 16 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, status) == 20 );
-C_ASSERT( sizeof(struct get_next_device_request_request) == 24 );
+C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, user_ptr) == 24 );
+C_ASSERT( sizeof(struct get_next_device_request_request) == 32 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, params) == 8 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, next) == 40 );
 C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, client_tid) == 44 );
diff --git a/server/trace.c b/server/trace.c
index 28bf3dd..82ea93f 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -4282,6 +4282,7 @@ static void dump_get_next_device_request_request( const struct get_next_device_r
     fprintf( stderr, " manager=%04x", req->manager );
     fprintf( stderr, ", prev=%04x", req->prev );
     fprintf( stderr, ", status=%08x", req->status );
+    dump_uint64( ", user_ptr=", &req->user_ptr );
 }
 
 static void dump_get_next_device_request_reply( const struct get_next_device_request_reply *req )




More information about the wine-cvs mailing list