Commit 484b78bd authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl: Report the initial status of an IRP separately from the IOSB status.

Based on a patch by Chip Davis. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30155Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 69ea35a9
......@@ -492,6 +492,7 @@ static NTSTATUS dispatch_irp( DEVICE_OBJECT *device, IRP *irp, struct dispatch_c
{
struct irp_data *irp_data;
LARGE_INTEGER count;
NTSTATUS status;
if (!(irp_data = malloc( sizeof(*irp_data) )))
return STATUS_NO_MEMORY;
......@@ -508,11 +509,14 @@ static NTSTATUS dispatch_irp( DEVICE_OBJECT *device, IRP *irp, struct dispatch_c
device->CurrentIrp = irp;
KeEnterCriticalRegion();
IoCallDriver( device, irp );
status = IoCallDriver( device, irp );
KeLeaveCriticalRegion();
device->CurrentIrp = NULL;
return STATUS_SUCCESS;
if (status != STATUS_PENDING && !irp_data->complete)
ERR( "dispatch routine returned %#x but didn't complete the IRP\n", status );
return status;
}
/* process a create request for a given file */
......@@ -934,6 +938,7 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
IRP *irp = context.irp_data->irp;
req->user_ptr = wine_server_client_ptr( irp );
req->status = status;
if (context.irp_data->complete)
{
......@@ -943,19 +948,12 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
if (irp->Flags & IRP_WRITE_OPERATION)
out_buff = NULL; /* do not transfer back input buffer */
req->prev = wine_server_obj_handle( context.irp_data->handle );
req->status = irp->IoStatus.u.Status;
req->result = irp->IoStatus.Information;
req->prev = wine_server_obj_handle( context.irp_data->handle );
req->iosb_status = irp->IoStatus.u.Status;
req->result = irp->IoStatus.Information;
if (!NT_ERROR(irp->IoStatus.u.Status) && out_buff)
wine_server_add_data( req, out_buff, irp->IoStatus.Information );
}
else
{
if (status == STATUS_SUCCESS)
status = STATUS_PENDING;
req->status = status;
}
}
else
{
......
......@@ -663,19 +663,16 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
size = 0xdeadf00d;
SetLastError(0xdeadf00d);
ret = DeviceIoControl(device, ioctl, params, sizeof(*params), buffer, sizeof(buffer), &size, NULL);
todo_wine_if ((params->iosb_status != STATUS_PENDING && NT_SUCCESS(expect_status) != NT_SUCCESS(params->iosb_status))
|| (params->iosb_status == STATUS_PENDING && NT_SUCCESS(expect_status)))
todo_wine_if (params->ret_status == STATUS_PENDING && params->iosb_status == STATUS_PENDING)
ok(ret == NT_SUCCESS(expect_status), "got %d\n", ret);
if (NT_SUCCESS(expect_status))
{
todo_wine_if (!NT_SUCCESS(params->iosb_status) || params->iosb_status == STATUS_PENDING)
todo_wine_if (params->ret_status == STATUS_PENDING && params->iosb_status == STATUS_PENDING)
ok(GetLastError() == 0xdeadf00d, "got error %u\n", GetLastError());
}
else
{
todo_wine_if (RtlNtStatusToDosError(expect_status) != RtlNtStatusToDosError(params->iosb_status)
|| NT_SUCCESS(params->iosb_status))
ok(GetLastError() == RtlNtStatusToDosError(expect_status), "got error %u\n", GetLastError());
ok(GetLastError() == RtlNtStatusToDosError(expect_status), "got error %u\n", GetLastError());
}
if (NT_ERROR(expect_status))
todo_wine ok(size == 0xdeadf00d, "got size %u\n", size);
......@@ -690,8 +687,7 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(device, NULL, NULL, NULL, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status && params->ret_status != STATUS_PENDING)
ok(ret == expect_status, "got %#x\n", ret);
ok(ret == expect_status, "got %#x\n", ret);
if (NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......@@ -725,10 +721,9 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(file, event, NULL, (void *)456, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status)
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
if (!params->pending && NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......@@ -778,10 +773,9 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(file, event, NULL, NULL, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status)
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
if (!params->pending && NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......@@ -811,10 +805,9 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(file, NULL, NULL, NULL, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status)
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
if (!params->pending && NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......@@ -848,10 +841,9 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(file, event, NULL, (void *)456, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status)
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
ok(ret == params->ret_status
|| broken(NT_WARNING(params->ret_status) && ret == STATUS_PENDING), /* win10 */
"got %#x\n", ret);
if (!params->pending && NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......@@ -890,14 +882,16 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
}
else
{
todo_wine ok(!ret, "got %#x\n", ret);
todo_wine_if (params->ret_status != STATUS_PENDING)
ok(!ret, "got %#x\n", ret);
}
if (!ret)
{
ok(key == 123, "got key %Iu\n", key);
ok(value == 456, "got value %Iu\n", value);
ok(io.Status == params->iosb_status, "got iosb status %#x\n", io.Status);
ok(io.Information == 3, "got information %Iu\n", io.Information);
todo_wine_if (params->iosb_status == STATUS_PENDING)
ok(io.Information == 3, "got information %Iu\n", io.Information);
}
}
......@@ -919,8 +913,7 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
io.Information = 0xdeadf00d;
ret = NtDeviceIoControlFile(file, NULL, return_status_apc, (void *)456, &io,
ioctl, params, sizeof(*params), buffer, sizeof(buffer));
todo_wine_if (params->ret_status != params->iosb_status)
ok(ret == params->ret_status, "got %#x\n", ret);
ok(ret == params->ret_status, "got %#x\n", ret);
if (!params->pending && NT_ERROR(params->iosb_status))
{
todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
......
......@@ -4801,9 +4801,9 @@ struct get_next_device_request_request
obj_handle_t prev;
unsigned int status;
client_ptr_t user_ptr;
unsigned int iosb_status;
data_size_t result;
/* VARARG(data,bytes); */
char __pad_36[4];
};
struct get_next_device_request_reply
{
......@@ -6255,7 +6255,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 727
#define SERVER_PROTOCOL_VERSION 728
/* ### protocol_version end ### */
......
......@@ -48,6 +48,7 @@ struct async
async_data_t data; /* data for async I/O call */
struct iosb *iosb; /* I/O status block */
obj_handle_t wait_handle; /* pre-allocated wait handle */
unsigned int initial_status; /* status returned from initial request */
unsigned int signaled :1;
unsigned int pending :1; /* request successfully queued, but pending */
unsigned int direct_result :1;/* a flag if we're passing result directly from request instead of APC */
......@@ -125,7 +126,10 @@ static void async_satisfied( struct object *obj, struct wait_queue_entry *entry
async->direct_result = 0;
}
set_wait_status( entry, async->iosb->status );
if (async->initial_status == STATUS_PENDING && async->blocking)
set_wait_status( entry, async->iosb->status );
else
set_wait_status( entry, async->initial_status );
/* close wait handle here to avoid extra server round trip */
if (async->wait_handle)
......@@ -255,6 +259,7 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da
async->timeout = NULL;
async->queue = NULL;
async->fd = (struct fd *)grab_object( fd );
async->initial_status = STATUS_PENDING;
async->signaled = 0;
async->pending = 1;
async->wait_handle = 0;
......@@ -285,17 +290,31 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da
return async;
}
void set_async_pending( struct async *async )
/* set the initial status of an async whose status was previously unknown
* the initial status may be STATUS_PENDING */
void async_set_initial_status( struct async *async, unsigned int status )
{
assert( async->unknown_status );
if (!async->terminated)
{
async->pending = 1;
async->initial_status = status;
async->unknown_status = 0;
if (!async->blocking && !async->signaled)
{
async->signaled = 1;
wake_up( &async->obj, 0 );
}
}
}
void set_async_pending( struct async *async )
{
if (!async->terminated)
async->pending = 1;
}
void async_wake_obj( struct async *async )
{
assert( !async->unknown_status );
if (!async->blocking)
{
async->signaled = 1;
wake_up( &async->obj, 0 );
}
}
......@@ -311,6 +330,8 @@ obj_handle_t async_handoff( struct async *async, data_size_t *result, int force_
return async->wait_handle;
}
async->initial_status = get_error();
if (!async->pending && NT_ERROR( get_error() ))
{
close_handle( async->thread->process, async->wait_handle );
......@@ -348,6 +369,7 @@ obj_handle_t async_handoff( struct async *async, data_size_t *result, int force_
async->wait_handle = 0;
}
}
async->initial_status = async->iosb->status;
set_error( async->iosb->status );
return async->wait_handle;
}
......
......@@ -952,18 +952,31 @@ DECL_HANDLER(get_next_device_request)
irp = manager->current_call;
irp->user_ptr = req->user_ptr;
if (req->prev)
if (irp->async)
{
set_irp_result( irp, req->status, get_req_data(), get_req_data_size(), req->result );
close_handle( current->process, req->prev ); /* avoid an extra round-trip for close */
if (req->status == STATUS_PENDING)
set_async_pending( irp->async );
async_set_initial_status( irp->async, req->status );
if (req->prev)
{
set_irp_result( irp, req->iosb_status, get_req_data(), get_req_data_size(), req->result );
close_handle( current->process, req->prev ); /* avoid an extra round-trip for close */
}
else
{
async_wake_obj( irp->async );
if (irp->canceled)
{
/* if it was canceled during dispatch, we couldn't queue cancel
* call without client pointer, so we need to do it now */
cancel_irp_call( irp );
}
}
}
else if (irp->async)
else
{
set_async_pending( irp->async );
if (irp->canceled)
/* if it was canceled during dispatch, we couldn't queue cancel call without client pointer,
* so we need to do it now */
cancel_irp_call( irp );
set_irp_result( irp, req->status, NULL, 0, 0 );
}
free_irp_params( irp );
......
......@@ -230,6 +230,8 @@ extern void async_set_result( struct object *obj, unsigned int status, apc_param
extern void async_set_completion_callback( struct async *async, async_completion_callback func, void *private );
extern void async_set_unknown_status( struct async *async );
extern void set_async_pending( struct async *async );
extern void async_set_initial_status( struct async *async, unsigned int status );
extern void async_wake_obj( struct async *async );
extern int async_waiting( struct async_queue *queue );
extern void async_terminate( struct async *async, unsigned int status );
extern void async_request_complete( struct async *async, unsigned int status, data_size_t result,
......
......@@ -3368,6 +3368,7 @@ struct handle_info
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 */
unsigned int iosb_status; /* IOSB status of the previous irp */
data_size_t result; /* IOSB result of the previous irp */
VARARG(data,bytes); /* output data of the previous irp */
@REPLY
......
......@@ -2053,7 +2053,8 @@ 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( FIELD_OFFSET(struct get_next_device_request_request, user_ptr) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, result) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, iosb_status) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_next_device_request_request, result) == 36 );
C_ASSERT( sizeof(struct get_next_device_request_request) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, params) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_next_device_request_reply, next) == 40 );
......
......@@ -4177,6 +4177,7 @@ static void dump_get_next_device_request_request( const struct get_next_device_r
fprintf( stderr, ", prev=%04x", req->prev );
fprintf( stderr, ", status=%08x", req->status );
dump_uint64( ", user_ptr=", &req->user_ptr );
fprintf( stderr, ", iosb_status=%08x", req->iosb_status );
fprintf( stderr, ", result=%u", req->result );
dump_varargs_bytes( ", data=", cur_size );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment