From 165dd1ff361817f1ba744eba2af786cc5ee2b602 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 5 May 2015 11:34:15 +0900 Subject: [PATCH] server: Rename ioctl to irp to allow supporting various types of I/O requests. --- dlls/ntdll/file.c | 2 +- dlls/ntoskrnl.exe/ntoskrnl.c | 34 ++++-- include/wine/server_protocol.h | 27 ++--- server/device.c | 258 +++++++++++++++++++++-------------------- server/protocol.def | 34 +++--- server/request.h | 37 +++--- server/trace.c | 20 ++-- 7 files changed, 214 insertions(+), 198 deletions(-) diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 0dc5c131065..041720a4d23 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -1368,7 +1368,7 @@ static NTSTATUS ioctl_completion( void *user, IO_STATUS_BLOCK *io, if (status == STATUS_ALERTED) { - SERVER_START_REQ( get_ioctl_result ) + SERVER_START_REQ( get_irp_result ) { req->handle = wine_server_obj_handle( async->io.handle ); req->user_arg = wine_server_client_ptr( async ); diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index bb26424f963..fbea0f4a1d3 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -186,9 +186,9 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff, NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event ) { HANDLE manager = get_device_manager(); - HANDLE ioctl = 0; + HANDLE irp = 0; NTSTATUS status = STATUS_SUCCESS; - ULONG code = 0; + ULONG type, code; void *in_buff; DEVICE_OBJECT *device = NULL; ULONG in_size = 4096, out_size = 0; @@ -210,13 +210,14 @@ 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( ioctl ); + req->prev = wine_server_obj_handle( irp ); req->status = status; wine_server_set_reply( req, in_buff, in_size ); if (!(status = wine_server_call( req ))) { + type = reply->type; code = reply->code; - ioctl = wine_server_ptr_handle( reply->next ); + irp = wine_server_ptr_handle( reply->next ); device = wine_server_get_ptr( reply->user_ptr ); client_tid = reply->client_tid; client_pid = reply->client_pid; @@ -225,7 +226,7 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event ) } else { - ioctl = 0; /* no previous ioctl */ + irp = 0; /* no previous irp */ out_size = 0; in_size = reply->in_size; } @@ -235,8 +236,17 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event ) switch(status) { case STATUS_SUCCESS: - status = process_ioctl( device, code, in_buff, in_size, out_size, ioctl ); - if (status == STATUS_SUCCESS) ioctl = 0; /* status reported by IoCompleteRequest */ + switch (type) + { + case IRP_MJ_DEVICE_CONTROL: + status = process_ioctl( device, code, in_buff, in_size, out_size, irp ); + break; + default: + FIXME( "unsupported request %u\n", type ); + status = STATUS_NOT_SUPPORTED; + break; + } + if (status == STATUS_SUCCESS) irp = 0; /* status reported by IoCompleteRequest */ break; case STATUS_BUFFER_OVERFLOW: HeapFree( GetProcessHeap(), 0, in_buff ); @@ -975,7 +985,7 @@ VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost ) IO_STACK_LOCATION *irpsp; PIO_COMPLETION_ROUTINE routine; NTSTATUS status, stat; - HANDLE ioctl; + HANDLE handle; int call_flag = 0; TRACE( "%p %u\n", irp, priority_boost ); @@ -1007,16 +1017,16 @@ VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost ) } } - ioctl = (HANDLE)irp->UserIosb; - if (ioctl) + handle = (HANDLE)irp->UserIosb; + if (handle) { HANDLE manager = get_device_manager(); void *out_buff = irp->UserBuffer; - SERVER_START_REQ( set_ioctl_result ) + SERVER_START_REQ( set_irp_result ) { req->manager = wine_server_obj_handle( manager ); - req->handle = wine_server_obj_handle( ioctl ); + req->handle = wine_server_obj_handle( handle ); req->status = irp->IoStatus.u.Status; if (irp->IoStatus.u.Status >= 0 && out_buff) wine_server_add_data( req, out_buff, irp->IoStatus.Information ); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 2d99ff233ff..b09ca138ebe 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -3128,7 +3128,7 @@ struct ioctl_reply -struct set_ioctl_result_request +struct set_irp_result_request { struct request_header __header; obj_handle_t manager; @@ -3136,20 +3136,20 @@ struct set_ioctl_result_request unsigned int status; /* VARARG(data,bytes); */ }; -struct set_ioctl_result_reply +struct set_irp_result_reply { struct reply_header __header; }; -struct get_ioctl_result_request +struct get_irp_result_request { struct request_header __header; obj_handle_t handle; client_ptr_t user_arg; }; -struct get_ioctl_result_reply +struct get_irp_result_reply { struct reply_header __header; /* VARARG(out_data,bytes); */ @@ -4789,19 +4789,20 @@ struct get_next_device_request_request obj_handle_t manager; obj_handle_t prev; unsigned int status; - /* VARARG(prev_data,bytes); */ }; struct get_next_device_request_reply { struct reply_header __header; obj_handle_t next; - ioctl_code_t code; + unsigned int type; client_ptr_t user_ptr; + ioctl_code_t code; process_id_t client_pid; thread_id_t client_tid; data_size_t in_size; data_size_t out_size; /* VARARG(next_data,bytes); */ + char __pad_44[4]; }; @@ -5314,8 +5315,8 @@ enum request REQ_register_async, REQ_cancel_async, REQ_ioctl, - REQ_set_ioctl_result, - REQ_get_ioctl_result, + REQ_set_irp_result, + REQ_get_irp_result, REQ_create_named_pipe, REQ_get_named_pipe_info, REQ_set_named_pipe_info, @@ -5583,8 +5584,8 @@ union generic_request struct register_async_request register_async_request; struct cancel_async_request cancel_async_request; struct ioctl_request ioctl_request; - struct set_ioctl_result_request set_ioctl_result_request; - struct get_ioctl_result_request get_ioctl_result_request; + struct set_irp_result_request set_irp_result_request; + struct get_irp_result_request get_irp_result_request; struct create_named_pipe_request create_named_pipe_request; struct get_named_pipe_info_request get_named_pipe_info_request; struct set_named_pipe_info_request set_named_pipe_info_request; @@ -5850,8 +5851,8 @@ union generic_reply struct register_async_reply register_async_reply; struct cancel_async_reply cancel_async_reply; struct ioctl_reply ioctl_reply; - struct set_ioctl_result_reply set_ioctl_result_reply; - struct get_ioctl_result_reply get_ioctl_result_reply; + struct set_irp_result_reply set_irp_result_reply; + struct get_irp_result_reply get_irp_result_reply; struct create_named_pipe_reply create_named_pipe_reply; struct get_named_pipe_info_reply get_named_pipe_info_reply; struct set_named_pipe_info_reply set_named_pipe_info_reply; @@ -5972,6 +5973,6 @@ union generic_reply struct terminate_job_reply terminate_job_reply; }; -#define SERVER_PROTOCOL_VERSION 469 +#define SERVER_PROTOCOL_VERSION 470 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/device.c b/server/device.c index 9d1bf3578c7..7ca5ba558cb 100644 --- a/server/device.c +++ b/server/device.c @@ -27,6 +27,7 @@ #define WIN32_NO_STATUS #include "windef.h" #include "winternl.h" +#include "ddk/wdm.h" #include "object.h" #include "file.h" @@ -34,35 +35,36 @@ #include "request.h" #include "process.h" -struct ioctl_call +struct irp_call { struct object obj; /* object header */ struct list dev_entry; /* entry in device queue */ struct list mgr_entry; /* entry in manager queue */ - struct device *device; /* device containing this ioctl */ - struct thread *thread; /* thread that queued the ioctl */ + struct device *device; /* device containing this irp */ + struct thread *thread; /* thread that queued the irp */ client_ptr_t user_arg; /* user arg used to identify the request */ struct async *async; /* pending async op */ - ioctl_code_t code; /* ioctl code */ + unsigned int type; /* request type (IRP_MJ_*) */ unsigned int status; /* resulting status (or STATUS_PENDING) */ + ioctl_code_t code; /* ioctl code */ data_size_t in_size; /* size of input data */ void *in_data; /* input data */ data_size_t out_size; /* size of output data */ void *out_data; /* output data */ }; -static void ioctl_call_dump( struct object *obj, int verbose ); -static int ioctl_call_signaled( struct object *obj, struct wait_queue_entry *entry ); -static void ioctl_call_destroy( struct object *obj ); +static void irp_call_dump( struct object *obj, int verbose ); +static int irp_call_signaled( struct object *obj, struct wait_queue_entry *entry ); +static void irp_call_destroy( struct object *obj ); -static const struct object_ops ioctl_call_ops = +static const struct object_ops irp_call_ops = { - sizeof(struct ioctl_call), /* size */ - ioctl_call_dump, /* dump */ + sizeof(struct irp_call), /* size */ + irp_call_dump, /* dump */ no_get_type, /* get_type */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ - ioctl_call_signaled, /* signaled */ + irp_call_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ no_get_fd, /* get_fd */ @@ -72,7 +74,7 @@ static const struct object_ops ioctl_call_ops = no_lookup_name, /* lookup_name */ no_open_file, /* open_file */ no_close_handle, /* close_handle */ - ioctl_call_destroy /* destroy */ + irp_call_destroy /* destroy */ }; @@ -80,7 +82,7 @@ struct device_manager { struct object obj; /* object header */ struct list devices; /* list of devices */ - struct list requests; /* list of pending ioctls across all devices */ + struct list requests; /* list of pending irps across all devices */ }; static void device_manager_dump( struct object *obj, int verbose ); @@ -112,10 +114,10 @@ struct device { struct object obj; /* object header */ struct device_manager *manager; /* manager for this device (or NULL if deleted) */ - struct fd *fd; /* file descriptor for ioctl */ + struct fd *fd; /* file descriptor for irp */ client_ptr_t user_ptr; /* opaque ptr for client side */ struct list entry; /* entry in device manager list */ - struct list requests; /* list of pending ioctl requests */ + struct list requests; /* list of pending irp requests */ }; static void device_dump( struct object *obj, int verbose ); @@ -161,89 +163,89 @@ static const struct fd_ops device_fd_ops = }; -static void ioctl_call_dump( struct object *obj, int verbose ) +static void irp_call_dump( struct object *obj, int verbose ) { - struct ioctl_call *ioctl = (struct ioctl_call *)obj; - fprintf( stderr, "Ioctl call code=%08x device=%p\n", ioctl->code, ioctl->device ); + struct irp_call *irp = (struct irp_call *)obj; + fprintf( stderr, "IRP call device=%p\n", irp->device ); } -static int ioctl_call_signaled( struct object *obj, struct wait_queue_entry *entry ) +static int irp_call_signaled( struct object *obj, struct wait_queue_entry *entry ) { - struct ioctl_call *ioctl = (struct ioctl_call *)obj; + struct irp_call *irp = (struct irp_call *)obj; - return !ioctl->device; /* device is cleared once the ioctl has completed */ + return !irp->device; /* device is cleared once the irp has completed */ } -static void ioctl_call_destroy( struct object *obj ) +static void irp_call_destroy( struct object *obj ) { - struct ioctl_call *ioctl = (struct ioctl_call *)obj; + struct irp_call *irp = (struct irp_call *)obj; - free( ioctl->in_data ); - free( ioctl->out_data ); - if (ioctl->async) + free( irp->in_data ); + free( irp->out_data ); + if (irp->async) { - async_terminate( ioctl->async, STATUS_CANCELLED ); - release_object( ioctl->async ); + async_terminate( irp->async, STATUS_CANCELLED ); + release_object( irp->async ); } - if (ioctl->device) release_object( ioctl->device ); - release_object( ioctl->thread ); + if (irp->device) release_object( irp->device ); + release_object( irp->thread ); } -static struct ioctl_call *create_ioctl( struct device *device, ioctl_code_t code, - const void *in_data, data_size_t in_size, - data_size_t out_size ) +static struct irp_call *create_irp( struct device *device, unsigned int type, const void *in_data, + data_size_t in_size, data_size_t out_size ) { - struct ioctl_call *ioctl; + struct irp_call *irp; - if ((ioctl = alloc_object( &ioctl_call_ops ))) + if ((irp = alloc_object( &irp_call_ops ))) { - ioctl->device = (struct device *)grab_object( device ); - ioctl->code = code; - ioctl->async = NULL; - ioctl->status = STATUS_PENDING; - ioctl->in_size = in_size; - ioctl->in_data = NULL; - ioctl->out_size = out_size; - ioctl->out_data = NULL; - - if (ioctl->in_size && !(ioctl->in_data = memdup( in_data, in_size ))) + irp->device = (struct device *)grab_object( device ); + irp->async = NULL; + irp->type = type; + irp->code = 0; + irp->status = STATUS_PENDING; + irp->in_size = in_size; + irp->in_data = NULL; + irp->out_size = out_size; + irp->out_data = NULL; + + if (irp->in_size && !(irp->in_data = memdup( in_data, in_size ))) { - release_object( ioctl ); - ioctl = NULL; + release_object( irp ); + irp = NULL; } } - return ioctl; + return irp; } -static void set_ioctl_result( struct ioctl_call *ioctl, unsigned int status, - const void *out_data, data_size_t out_size ) +static void set_irp_result( struct irp_call *irp, unsigned int status, + const void *out_data, data_size_t out_size ) { - struct device *device = ioctl->device; + struct device *device = irp->device; if (!device) return; /* already finished */ /* FIXME: handle the STATUS_PENDING case */ - ioctl->status = status; - ioctl->out_size = min( ioctl->out_size, out_size ); - if (ioctl->out_size && !(ioctl->out_data = memdup( out_data, ioctl->out_size ))) - ioctl->out_size = 0; + irp->status = status; + irp->out_size = min( irp->out_size, out_size ); + if (irp->out_size && !(irp->out_data = memdup( out_data, irp->out_size ))) + irp->out_size = 0; release_object( device ); - ioctl->device = NULL; - if (ioctl->async) + irp->device = NULL; + if (irp->async) { - if (ioctl->out_size) status = STATUS_ALERTED; - async_terminate( ioctl->async, status ); - release_object( ioctl->async ); - ioctl->async = NULL; + if (irp->out_size) status = STATUS_ALERTED; + async_terminate( irp->async, status ); + release_object( irp->async ); + irp->async = NULL; } - wake_up( &ioctl->obj, 0 ); + wake_up( &irp->obj, 0 ); if (status != STATUS_ALERTED) { /* remove it from the device queue */ - /* (for STATUS_ALERTED this will be done in get_ioctl_result) */ - list_remove( &ioctl->dev_entry ); - release_object( ioctl ); /* no longer on the device queue */ + /* (for STATUS_ALERTED this will be done in get_irp_result) */ + list_remove( &irp->dev_entry ); + release_object( irp ); /* no longer on the device queue */ } } @@ -274,12 +276,12 @@ static struct fd *device_get_fd( struct object *obj ) static void device_destroy( struct object *obj ) { struct device *device = (struct device *)obj; - struct ioctl_call *ioctl, *next; + struct irp_call *irp, *next; - LIST_FOR_EACH_ENTRY_SAFE( ioctl, next, &device->requests, struct ioctl_call, dev_entry ) + LIST_FOR_EACH_ENTRY_SAFE( irp, next, &device->requests, struct irp_call, dev_entry ) { - list_remove( &ioctl->dev_entry ); - release_object( ioctl ); /* no longer on the device queue */ + list_remove( &irp->dev_entry ); + release_object( irp ); /* no longer on the device queue */ } if (device->fd) release_object( device->fd ); if (device->manager) list_remove( &device->entry ); @@ -296,13 +298,13 @@ static enum server_fd_type device_get_fd_type( struct fd *fd ) return FD_TYPE_DEVICE; } -static struct ioctl_call *find_ioctl_call( struct device *device, struct thread *thread, - client_ptr_t user_arg ) +static struct irp_call *find_irp_call( struct device *device, struct thread *thread, + client_ptr_t user_arg ) { - struct ioctl_call *ioctl; + struct irp_call *irp; - LIST_FOR_EACH_ENTRY( ioctl, &device->requests, struct ioctl_call, dev_entry ) - if (ioctl->thread == thread && ioctl->user_arg == user_arg) return ioctl; + LIST_FOR_EACH_ENTRY( irp, &device->requests, struct irp_call, dev_entry ) + if (irp->thread == thread && irp->user_arg == user_arg) return irp; set_error( STATUS_INVALID_PARAMETER ); return NULL; @@ -312,7 +314,7 @@ static obj_handle_t device_ioctl( struct fd *fd, ioctl_code_t code, const async_ int blocking, const void *data, data_size_t size ) { struct device *device = get_fd_user( fd ); - struct ioctl_call *ioctl; + struct irp_call *irp; obj_handle_t handle = 0; if (!device->manager) /* it has been deleted */ @@ -321,29 +323,30 @@ static obj_handle_t device_ioctl( struct fd *fd, ioctl_code_t code, const async_ return 0; } - if (!(ioctl = create_ioctl( device, code, data, size, get_reply_max_size() ))) + if (!(irp = create_irp( device, IRP_MJ_DEVICE_CONTROL, data, size, get_reply_max_size() ))) return 0; - ioctl->thread = (struct thread *)grab_object( current ); - ioctl->user_arg = async_data->arg; + irp->code = code; + irp->thread = (struct thread *)grab_object( current ); + irp->user_arg = async_data->arg; - if (blocking && !(handle = alloc_handle( current->process, ioctl, SYNCHRONIZE, 0 ))) + if (blocking && !(handle = alloc_handle( current->process, irp, SYNCHRONIZE, 0 ))) { - release_object( ioctl ); + release_object( irp ); return 0; } - if (!(ioctl->async = fd_queue_async( device->fd, async_data, ASYNC_TYPE_WAIT ))) + if (!(irp->async = fd_queue_async( device->fd, async_data, ASYNC_TYPE_WAIT ))) { if (handle) close_handle( current->process, handle ); - release_object( ioctl ); + release_object( irp ); return 0; } - list_add_tail( &device->requests, &ioctl->dev_entry ); - list_add_tail( &device->manager->requests, &ioctl->mgr_entry ); - if (list_head( &device->manager->requests ) == &ioctl->mgr_entry) /* first one */ + list_add_tail( &device->requests, &irp->dev_entry ); + list_add_tail( &device->manager->requests, &irp->mgr_entry ); + if (list_head( &device->manager->requests ) == &irp->mgr_entry) /* first one */ wake_up( &device->manager->obj, 0 ); - /* don't release ioctl since it is now queued in the device */ + /* don't release irp since it is now queued in the device */ set_error( STATUS_PENDING ); return handle; } @@ -373,15 +376,15 @@ static struct device *create_device( struct directory *root, const struct unicod static void delete_device( struct device *device ) { - struct ioctl_call *ioctl, *next; + struct irp_call *irp, *next; if (!device->manager) return; /* already deleted */ /* terminate all pending requests */ - LIST_FOR_EACH_ENTRY_SAFE( ioctl, next, &device->requests, struct ioctl_call, dev_entry ) + LIST_FOR_EACH_ENTRY_SAFE( irp, next, &device->requests, struct irp_call, dev_entry ) { - list_remove( &ioctl->mgr_entry ); - set_ioctl_result( ioctl, STATUS_FILE_DELETED, NULL, 0 ); + list_remove( &irp->mgr_entry ); + set_irp_result( irp, STATUS_FILE_DELETED, NULL, 0 ); } unlink_named_object( &device->obj ); list_remove( &device->entry ); @@ -483,10 +486,10 @@ DECL_HANDLER(delete_device) } -/* retrieve the next pending device ioctl request */ +/* retrieve the next pending device irp request */ DECL_HANDLER(get_next_device_request) { - struct ioctl_call *ioctl; + struct irp_call *irp; struct device_manager *manager; struct list *ptr; @@ -496,33 +499,34 @@ DECL_HANDLER(get_next_device_request) if (req->prev) { - if ((ioctl = (struct ioctl_call *)get_handle_obj( current->process, req->prev, - 0, &ioctl_call_ops ))) + if ((irp = (struct irp_call *)get_handle_obj( current->process, req->prev, + 0, &irp_call_ops ))) { - set_ioctl_result( ioctl, req->status, get_req_data(), get_req_data_size() ); + set_irp_result( irp, req->status, NULL, 0 ); close_handle( current->process, req->prev ); /* avoid an extra round-trip for close */ - release_object( ioctl ); + release_object( irp ); } clear_error(); } if ((ptr = list_head( &manager->requests ))) { - ioctl = LIST_ENTRY( ptr, struct ioctl_call, mgr_entry ); - reply->code = ioctl->code; - reply->user_ptr = ioctl->device->user_ptr; - reply->client_pid = get_process_id( ioctl->thread->process ); - reply->client_tid = get_thread_id( ioctl->thread ); - reply->in_size = ioctl->in_size; - reply->out_size = ioctl->out_size; - if (ioctl->in_size > get_reply_max_size()) set_error( STATUS_BUFFER_OVERFLOW ); - else if ((reply->next = alloc_handle( current->process, ioctl, 0, 0 ))) + irp = LIST_ENTRY( ptr, struct irp_call, mgr_entry ); + reply->type = irp->type; + reply->code = irp->code; + reply->user_ptr = irp->device->user_ptr; + reply->client_pid = get_process_id( irp->thread->process ); + reply->client_tid = get_thread_id( irp->thread ); + reply->in_size = irp->in_size; + reply->out_size = irp->out_size; + if (irp->in_size > get_reply_max_size()) set_error( STATUS_BUFFER_OVERFLOW ); + else if ((reply->next = alloc_handle( current->process, irp, 0, 0 ))) { - set_reply_data_ptr( ioctl->in_data, ioctl->in_size ); - ioctl->in_data = NULL; - ioctl->in_size = 0; - list_remove( &ioctl->mgr_entry ); - list_init( &ioctl->mgr_entry ); + set_reply_data_ptr( irp->in_data, irp->in_size ); + irp->in_data = NULL; + irp->in_size = 0; + list_remove( &irp->mgr_entry ); + list_init( &irp->mgr_entry ); } } else set_error( STATUS_PENDING ); @@ -531,49 +535,49 @@ DECL_HANDLER(get_next_device_request) } -/* store results of an async ioctl */ -DECL_HANDLER(set_ioctl_result) +/* store results of an async irp */ +DECL_HANDLER(set_irp_result) { - struct ioctl_call *ioctl; + struct irp_call *irp; struct device_manager *manager; if (!(manager = (struct device_manager *)get_handle_obj( current->process, req->manager, 0, &device_manager_ops ))) return; - if ((ioctl = (struct ioctl_call *)get_handle_obj( current->process, req->handle, 0, &ioctl_call_ops ))) + if ((irp = (struct irp_call *)get_handle_obj( current->process, req->handle, 0, &irp_call_ops ))) { - set_ioctl_result( ioctl, req->status, get_req_data(), get_req_data_size() ); + set_irp_result( irp, req->status, get_req_data(), get_req_data_size() ); close_handle( current->process, req->handle ); /* avoid an extra round-trip for close */ - release_object( ioctl ); + release_object( irp ); } release_object( manager ); } -/* retrieve results of an async ioctl */ -DECL_HANDLER(get_ioctl_result) +/* retrieve results of an async irp */ +DECL_HANDLER(get_irp_result) { struct device *device; - struct ioctl_call *ioctl; + struct irp_call *irp; if (!(device = (struct device *)get_handle_obj( current->process, req->handle, 0, &device_ops ))) return; - if ((ioctl = find_ioctl_call( device, current, req->user_arg ))) + if ((irp = find_irp_call( device, current, req->user_arg ))) { - if (ioctl->out_data) + if (irp->out_data) { - data_size_t size = min( ioctl->out_size, get_reply_max_size() ); + data_size_t size = min( irp->out_size, get_reply_max_size() ); if (size) { - set_reply_data_ptr( ioctl->out_data, size ); - ioctl->out_data = NULL; + set_reply_data_ptr( irp->out_data, size ); + irp->out_data = NULL; } } - set_error( ioctl->status ); - list_remove( &ioctl->dev_entry ); - release_object( ioctl ); /* no longer on the device queue */ + set_error( irp->status ); + list_remove( &irp->dev_entry ); + release_object( irp ); /* no longer on the device queue */ } release_object( device ); } diff --git a/server/protocol.def b/server/protocol.def index 45ab7894fd7..7e4737a2a3d 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2262,21 +2262,21 @@ enum message_type @END -/* Store results of an async ioctl */ -@REQ(set_ioctl_result) +/* Store results of an async irp */ +@REQ(set_irp_result) obj_handle_t manager; /* handle to the device manager */ - obj_handle_t handle; /* handle to the ioctl */ - unsigned int status; /* status of the ioctl */ - VARARG(data,bytes); /* output data of the ioctl */ + obj_handle_t handle; /* handle to the irp */ + unsigned int status; /* status of the irp */ + VARARG(data,bytes); /* output data of the irp */ @END -/* Retrieve results of an async ioctl */ -@REQ(get_ioctl_result) +/* Retrieve results of an async irp */ +@REQ(get_irp_result) obj_handle_t handle; /* handle to the device */ client_ptr_t user_arg; /* user arg used to identify the request */ @REPLY - VARARG(out_data,bytes); /* ioctl output data */ + VARARG(out_data,bytes); /* irp output data */ @END @@ -3323,21 +3323,21 @@ enum coords_relative @END -/* Retrieve the next pending device ioctl request */ +/* Retrieve the next pending device irp request */ @REQ(get_next_device_request) obj_handle_t manager; /* handle to the device manager */ - obj_handle_t prev; /* handle to the previous ioctl */ - unsigned int status; /* status of the previous ioctl */ - VARARG(prev_data,bytes); /* output data of the previous ioctl */ + obj_handle_t prev; /* handle to the previous irp */ + unsigned int status; /* status of the previous irp */ @REPLY - obj_handle_t next; /* handle to the next ioctl */ - ioctl_code_t code; /* ioctl code */ + obj_handle_t next; /* handle to the next irp */ + unsigned int type; /* irp type (IRP_MJ_*) */ client_ptr_t user_ptr; /* opaque ptr for the device */ - process_id_t client_pid; /* pid of process calling ioctl */ - thread_id_t client_tid; /* tid of thread calling ioctl */ + ioctl_code_t code; /* ioctl code */ + process_id_t client_pid; /* pid of process calling irp */ + thread_id_t client_tid; /* tid of thread calling irp */ data_size_t in_size; /* total needed input size */ data_size_t out_size; /* needed output size */ - VARARG(next_data,bytes); /* input data of the next ioctl */ + VARARG(next_data,bytes); /* input data of the next irp */ @END diff --git a/server/request.h b/server/request.h index fa0e33f37ea..bce80a14df3 100644 --- a/server/request.h +++ b/server/request.h @@ -248,8 +248,8 @@ DECL_HANDLER(set_serial_info); DECL_HANDLER(register_async); DECL_HANDLER(cancel_async); DECL_HANDLER(ioctl); -DECL_HANDLER(set_ioctl_result); -DECL_HANDLER(get_ioctl_result); +DECL_HANDLER(set_irp_result); +DECL_HANDLER(get_irp_result); DECL_HANDLER(create_named_pipe); DECL_HANDLER(get_named_pipe_info); DECL_HANDLER(set_named_pipe_info); @@ -516,8 +516,8 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] = (req_handler)req_register_async, (req_handler)req_cancel_async, (req_handler)req_ioctl, - (req_handler)req_set_ioctl_result, - (req_handler)req_get_ioctl_result, + (req_handler)req_set_irp_result, + (req_handler)req_get_irp_result, (req_handler)req_create_named_pipe, (req_handler)req_get_named_pipe_info, (req_handler)req_set_named_pipe_info, @@ -1527,14 +1527,14 @@ C_ASSERT( sizeof(struct ioctl_request) == 64 ); C_ASSERT( FIELD_OFFSET(struct ioctl_reply, wait) == 8 ); C_ASSERT( FIELD_OFFSET(struct ioctl_reply, options) == 12 ); C_ASSERT( sizeof(struct ioctl_reply) == 16 ); -C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, manager) == 12 ); -C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, handle) == 16 ); -C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, status) == 20 ); -C_ASSERT( sizeof(struct set_ioctl_result_request) == 24 ); -C_ASSERT( FIELD_OFFSET(struct get_ioctl_result_request, handle) == 12 ); -C_ASSERT( FIELD_OFFSET(struct get_ioctl_result_request, user_arg) == 16 ); -C_ASSERT( sizeof(struct get_ioctl_result_request) == 24 ); -C_ASSERT( sizeof(struct get_ioctl_result_reply) == 8 ); +C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, manager) == 12 ); +C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, handle) == 16 ); +C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, status) == 20 ); +C_ASSERT( sizeof(struct set_irp_result_request) == 24 ); +C_ASSERT( FIELD_OFFSET(struct get_irp_result_request, handle) == 12 ); +C_ASSERT( FIELD_OFFSET(struct get_irp_result_request, user_arg) == 16 ); +C_ASSERT( sizeof(struct get_irp_result_request) == 24 ); +C_ASSERT( sizeof(struct get_irp_result_reply) == 8 ); C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, access) == 12 ); C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, attributes) == 16 ); C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, options) == 20 ); @@ -2124,13 +2124,14 @@ 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_reply, next) == 8 ); -C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, code) == 12 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, type) == 12 ); C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, user_ptr) == 16 ); -C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, client_pid) == 24 ); -C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, client_tid) == 28 ); -C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, in_size) == 32 ); -C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, out_size) == 36 ); -C_ASSERT( sizeof(struct get_next_device_request_reply) == 40 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, code) == 24 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, client_pid) == 28 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, client_tid) == 32 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, in_size) == 36 ); +C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, out_size) == 40 ); +C_ASSERT( sizeof(struct get_next_device_request_reply) == 48 ); C_ASSERT( sizeof(struct make_process_system_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct make_process_system_reply, event) == 8 ); C_ASSERT( sizeof(struct make_process_system_reply) == 16 ); diff --git a/server/trace.c b/server/trace.c index e184e98645d..e9127b4850f 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2740,7 +2740,7 @@ static void dump_ioctl_reply( const struct ioctl_reply *req ) dump_varargs_bytes( ", out_data=", cur_size ); } -static void dump_set_ioctl_result_request( const struct set_ioctl_result_request *req ) +static void dump_set_irp_result_request( const struct set_irp_result_request *req ) { fprintf( stderr, " manager=%04x", req->manager ); fprintf( stderr, ", handle=%04x", req->handle ); @@ -2748,13 +2748,13 @@ static void dump_set_ioctl_result_request( const struct set_ioctl_result_request dump_varargs_bytes( ", data=", cur_size ); } -static void dump_get_ioctl_result_request( const struct get_ioctl_result_request *req ) +static void dump_get_irp_result_request( const struct get_irp_result_request *req ) { fprintf( stderr, " handle=%04x", req->handle ); dump_uint64( ", user_arg=", &req->user_arg ); } -static void dump_get_ioctl_result_reply( const struct get_ioctl_result_reply *req ) +static void dump_get_irp_result_reply( const struct get_irp_result_reply *req ) { dump_varargs_bytes( " out_data=", cur_size ); } @@ -3915,14 +3915,14 @@ 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_varargs_bytes( ", prev_data=", cur_size ); } static void dump_get_next_device_request_reply( const struct get_next_device_request_reply *req ) { fprintf( stderr, " next=%04x", req->next ); - dump_ioctl_code( ", code=", &req->code ); + fprintf( stderr, ", type=%08x", req->type ); dump_uint64( ", user_ptr=", &req->user_ptr ); + dump_ioctl_code( ", code=", &req->code ); fprintf( stderr, ", client_pid=%04x", req->client_pid ); fprintf( stderr, ", client_tid=%04x", req->client_tid ); fprintf( stderr, ", in_size=%u", req->in_size ); @@ -4290,8 +4290,8 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_register_async_request, (dump_func)dump_cancel_async_request, (dump_func)dump_ioctl_request, - (dump_func)dump_set_ioctl_result_request, - (dump_func)dump_get_ioctl_result_request, + (dump_func)dump_set_irp_result_request, + (dump_func)dump_get_irp_result_request, (dump_func)dump_create_named_pipe_request, (dump_func)dump_get_named_pipe_info_request, (dump_func)dump_set_named_pipe_info_request, @@ -4556,7 +4556,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { NULL, (dump_func)dump_ioctl_reply, NULL, - (dump_func)dump_get_ioctl_result_reply, + (dump_func)dump_get_irp_result_reply, (dump_func)dump_create_named_pipe_reply, (dump_func)dump_get_named_pipe_info_reply, NULL, @@ -4820,8 +4820,8 @@ static const char * const req_names[REQ_NB_REQUESTS] = { "register_async", "cancel_async", "ioctl", - "set_ioctl_result", - "get_ioctl_result", + "set_irp_result", + "get_irp_result", "create_named_pipe", "get_named_pipe_info", "set_named_pipe_info", -- 2.11.4.GIT