Alexandre Julliard : ntdll: Use the fileio structure and callback also for ioctl calls.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 2 08:51:51 CST 2015


Module: wine
Branch: master
Commit: 4f43d743e07ab1b809de70d10972d6f97ba1f3fd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4f43d743e07ab1b809de70d10972d6f97ba1f3fd

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Mar  2 16:56:47 2015 +0900

ntdll: Use the fileio structure and callback also for ioctl calls.

---

 dlls/ntdll/file.c | 44 +++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 5232027..6e3825f 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -336,22 +336,22 @@ struct async_fileio
     void               *apc_arg;
 };
 
-typedef struct
+struct async_fileio_read
 {
     struct async_fileio io;
     char*               buffer;
     unsigned int        already;
     unsigned int        count;
     BOOL                avail_mode;
-} async_fileio_read;
+};
 
-typedef struct
+struct async_fileio_write
 {
     struct async_fileio io;
     const char         *buffer;
     unsigned int        already;
     unsigned int        count;
-} async_fileio_write;
+};
 
 
 /* callback for file I/O user APC */
@@ -416,7 +416,7 @@ NTSTATUS FILE_GetNtStatus(void)
  */
 static NTSTATUS FILE_AsyncReadService(void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, void **apc)
 {
-    async_fileio_read *fileio = user;
+    struct async_fileio_read *fileio = user;
     int fd, needs_close, result;
 
     switch (status)
@@ -730,7 +730,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
 
         if (async_read)
         {
-            async_fileio_read *fileio;
+            struct async_fileio_read *fileio;
             BOOL avail_mode;
 
             if ((status = get_io_avail_mode( hFile, type, &avail_mode )))
@@ -923,7 +923,7 @@ NTSTATUS WINAPI NtReadFileScatter( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap
  */
 static NTSTATUS FILE_AsyncWriteService(void *user, IO_STATUS_BLOCK *iosb, NTSTATUS status, void **apc)
 {
-    async_fileio_write *fileio = user;
+    struct async_fileio_write *fileio = user;
     int result, fd, needs_close;
     enum server_fd_type type;
 
@@ -1140,7 +1140,7 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
 
         if (async_write)
         {
-            async_fileio_write *fileio;
+            struct async_fileio_write *fileio;
 
             if (!(fileio = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(*fileio))))
             {
@@ -1327,22 +1327,12 @@ NTSTATUS WINAPI NtWriteFileGather( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap
 
 struct async_ioctl
 {
-    HANDLE          handle;   /* handle to the device */
-    HANDLE          event;    /* async event */
-    void           *buffer;   /* buffer for output */
-    ULONG           size;     /* size of buffer */
-    PIO_APC_ROUTINE apc;      /* user apc params */
-    void           *apc_arg;
+    struct async_fileio io;
+    HANDLE              event;    /* async event */
+    void               *buffer;   /* buffer for output */
+    ULONG               size;     /* size of buffer */
 };
 
-/* callback for ioctl user APC */
-static void WINAPI ioctl_apc( void *arg, IO_STATUS_BLOCK *io, ULONG reserved )
-{
-    struct async_ioctl *async = arg;
-    if (async->apc) async->apc( async->apc_arg, io, reserved );
-    RtlFreeHeap( GetProcessHeap(), 0, async );
-}
-
 /* callback for ioctl async I/O completion */
 static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS status, void **apc )
 {
@@ -1352,7 +1342,7 @@ static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS statu
     {
         SERVER_START_REQ( get_ioctl_result )
         {
-            req->handle   = wine_server_obj_handle( async->handle );
+            req->handle   = wine_server_obj_handle( async->io.handle );
             req->user_arg = wine_server_client_ptr( async );
             wine_server_set_reply( req, async->buffer, async->size );
             status = wine_server_call( req );
@@ -1363,7 +1353,7 @@ static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS statu
     if (status != STATUS_PENDING)
     {
         io->u.Status = status;
-        if (async->apc || async->event) *apc = ioctl_apc;
+        if (async->io.apc || async->event) *apc = fileio_apc;
     }
     return status;
 }
@@ -1383,12 +1373,12 @@ static NTSTATUS server_ioctl_file( HANDLE handle, HANDLE event,
 
     if (!(async = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*async) )))
         return STATUS_NO_MEMORY;
-    async->handle  = handle;
+    async->io.handle  = handle;
+    async->io.apc     = apc;
+    async->io.apc_arg = apc_context;
     async->event   = event;
     async->buffer  = out_buffer;
     async->size    = out_size;
-    async->apc     = apc;
-    async->apc_arg = apc_context;
 
     SERVER_START_REQ( ioctl )
     {




More information about the wine-cvs mailing list