ntdll: Set the I/O status block through the 32-bit pointer for Wow64 processes.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-08-05 19:36:28 +02:00
parent 28754a04ef
commit 61b123fae9
5 changed files with 45 additions and 21 deletions

View File

@ -1966,7 +1966,7 @@ static NTSTATUS get_mountmgr_fs_info( HANDLE handle, int fd, struct mountmgr_uni
OBJECT_ATTRIBUTES attr;
UNICODE_STRING string;
char *unix_name;
IO_STATUS_BLOCK io;
IO_STATUS_BLOCK io = {0};
HANDLE mountmgr;
NTSTATUS status;
int letter;
@ -4937,7 +4937,7 @@ static NTSTATUS get_io_timeouts( HANDLE handle, enum server_fd_type type, ULONG
{
/* GetCommTimeouts */
SERIAL_TIMEOUTS st;
IO_STATUS_BLOCK io;
IO_STATUS_BLOCK io = {0};
status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io,
IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, &st, sizeof(st) );
@ -5024,7 +5024,7 @@ static NTSTATUS get_io_avail_mode( HANDLE handle, enum server_fd_type type, BOOL
{
/* GetCommTimeouts */
SERIAL_TIMEOUTS st;
IO_STATUS_BLOCK io;
IO_STATUS_BLOCK io = {0};
status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io,
IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, &st, sizeof(st) );

View File

@ -407,7 +407,7 @@ static void set_stdio_fd( int stdin_fd, int stdout_fd )
*/
static BOOL is_unix_console_handle( HANDLE handle )
{
IO_STATUS_BLOCK io;
IO_STATUS_BLOCK io = {0};
return !NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, IOCTL_CONDRV_IS_UNIX,
NULL, 0, NULL, 0 );
}

View File

@ -841,7 +841,7 @@ typedef struct async_commio
{
HANDLE hDevice;
DWORD* events;
IO_STATUS_BLOCK* iosb;
client_ptr_t iosb;
HANDLE hEvent;
DWORD evtmask;
DWORD cookie;
@ -995,23 +995,15 @@ static void CALLBACK wait_for_event(LPVOID arg)
}
if (needs_close) close( fd );
}
if (commio->iosb)
{
if (*commio->events)
{
commio->iosb->u.Status = STATUS_SUCCESS;
commio->iosb->Information = sizeof(DWORD);
}
else
commio->iosb->u.Status = STATUS_CANCELLED;
}
if (*commio->events) set_async_iosb( commio->iosb, STATUS_SUCCESS, sizeof(DWORD) );
else set_async_iosb( commio->iosb, STATUS_CANCELLED, 0 );
stop_waiting(commio->hDevice);
if (commio->hEvent) NtSetEvent(commio->hEvent, NULL);
free( commio );
NtTerminateThread( GetCurrentThread(), 0 );
}
static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, PIO_STATUS_BLOCK piosb, DWORD* events)
static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, client_ptr_t iosb_ptr, DWORD* events)
{
async_commio* commio;
NTSTATUS status;
@ -1025,7 +1017,7 @@ static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, PIO_STATUS_BLOCK
commio->hDevice = hDevice;
commio->events = events;
commio->iosb = piosb;
commio->iosb = iosb_ptr;
commio->hEvent = hEvent;
commio->pending_write = 0;
status = get_wait_mask(commio->hDevice, &commio->evtmask, &commio->cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL, TRUE);
@ -1315,7 +1307,7 @@ static NTSTATUS io_control( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, vo
case IOCTL_SERIAL_WAIT_ON_MASK:
if (out_buffer && out_size == sizeof(DWORD))
{
if (!(status = wait_on(device, fd, event, io, out_buffer)))
if (!(status = wait_on(device, fd, event, iosb_client_ptr(io), out_buffer)))
sz = sizeof(DWORD);
}
else

View File

@ -377,7 +377,6 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
break;
case APC_ASYNC_IO:
{
IO_STATUS_BLOCK *iosb = wine_server_get_ptr( call->async_io.sb );
struct async_fileio *user = wine_server_get_ptr( call->async_io.user );
ULONG_PTR info = 0;
@ -386,8 +385,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
if (result->async_io.status != STATUS_PENDING)
{
result->async_io.total = info;
iosb->Status = result->async_io.status;
iosb->Information = info;
set_async_iosb( call->async_io.sb, result->async_io.status, info );
}
break;
}

View File

@ -354,8 +354,42 @@ static inline NTSTATUS wait_async( HANDLE handle, BOOL alertable )
return NtWaitForSingleObject( handle, alertable, NULL );
}
static inline void set_async_iosb( client_ptr_t iosb, NTSTATUS status, ULONG_PTR info )
{
if (!iosb) return;
#ifdef _WIN64
if (NtCurrentTeb()->WowTebOffset)
{
struct iosb32
{
NTSTATUS Status;
ULONG Information;
} *io = wine_server_get_ptr( iosb );
io->Status = status;
io->Information = info;
}
else
#endif
{
IO_STATUS_BLOCK *io = wine_server_get_ptr( iosb );
#ifdef NONAMELESSUNION
io->u.Status = status;
#else
io->Status = status;
#endif
io->Information = info;
}
}
static inline client_ptr_t iosb_client_ptr( IO_STATUS_BLOCK *io )
{
#ifdef _WIN64
#ifdef NONAMELESSUNION
if (io && NtCurrentTeb()->WowTebOffset) return wine_server_client_ptr( io->u.Pointer );
#else
if (io && NtCurrentTeb()->WowTebOffset) return wine_server_client_ptr( io->Pointer );
#endif
#endif
return wine_server_client_ptr( io );
}