Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/tests/driver.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 5617342d803..eb4620ad25d 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -846,6 +846,8 @@ static void test_call_driver(DEVICE_OBJECT *device) KEVENT event; NTSTATUS status;
+ iosb.Status = 0xdeadbeef; + iosb.Information = 0xdeadbeef; irp = IoBuildAsynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS, device, NULL, 0, NULL, &iosb); ok(irp->UserIosb == &iosb, "unexpected UserIosb\n"); ok(!irp->Cancel, "Cancel = %x\n", irp->Cancel); @@ -854,6 +856,10 @@ static void test_call_driver(DEVICE_OBJECT *device) ok(irp->CurrentLocation == 2, "CurrentLocation = %u\n", irp->CurrentLocation); ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(), "IRP thread is not the current thread\n"); + ok(!irp->IoStatus.Status, "got status %#x\n", irp->IoStatus.Status); + ok(!irp->IoStatus.Information, "got information %#x\n", irp->IoStatus.Information); + ok(iosb.Status == 0xdeadbeef, "got status %#x\n", iosb.Status); + ok(iosb.Information == 0xdeadbeef, "got information %#x\n", iosb.Information);
irpsp = IoGetNextIrpStackLocation(irp); ok(irpsp->MajorFunction == IRP_MJ_FLUSH_BUFFERS, "MajorFunction = %u\n", irpsp->MajorFunction); @@ -863,10 +869,16 @@ static void test_call_driver(DEVICE_OBJECT *device)
status = IoCallDriver(device, irp); ok(status == STATUS_PENDING, "IoCallDriver returned %#x\n", status); + ok(!irp->IoStatus.Status, "got status %#x\n", irp->IoStatus.Status); + ok(!irp->IoStatus.Information, "got information %#x\n", irp->IoStatus.Information); + ok(iosb.Status == 0xdeadbeef, "got status %#x\n", iosb.Status); + ok(iosb.Information == 0xdeadbeef, "got information %#x\n", iosb.Information);
irp->IoStatus.Status = STATUS_SUCCESS; - irp->IoStatus.Information = 0; + irp->IoStatus.Information = 123; IoCompleteRequest(irp, IO_NO_INCREMENT); + todo_wine ok(iosb.Status == STATUS_SUCCESS, "got status %#x\n", iosb.Status); + todo_wine ok(iosb.Information == 123, "got information %#x\n", iosb.Information);
KeInitializeEvent(&event, NotificationEvent, FALSE);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 1 + dlls/ntoskrnl.exe/tests/driver.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index e003de33c2d..ee95155f301 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2023,6 +2023,7 @@ VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost )
if (irp->Flags & IRP_DEALLOCATE_BUFFER) HeapFree( GetProcessHeap(), 0, irp->AssociatedIrp.SystemBuffer ); + if (irp->UserIosb) *irp->UserIosb = irp->IoStatus; if (irp->UserEvent) KeSetEvent( irp->UserEvent, IO_NO_INCREMENT, FALSE );
IoFreeIrp( irp ); diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index eb4620ad25d..f9329adfc54 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -877,8 +877,8 @@ static void test_call_driver(DEVICE_OBJECT *device) irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Information = 123; IoCompleteRequest(irp, IO_NO_INCREMENT); - todo_wine ok(iosb.Status == STATUS_SUCCESS, "got status %#x\n", iosb.Status); - todo_wine ok(iosb.Information == 123, "got information %#x\n", iosb.Information); + ok(iosb.Status == STATUS_SUCCESS, "got status %#x\n", iosb.Status); + ok(iosb.Information == 123, "got information %#x\n", iosb.Information);
KeInitializeEvent(&event, NotificationEvent, FALSE);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 713e469ee7e..04e442a8300 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -80,28 +80,20 @@ static NTSTATUS WINAPI internal_complete( DEVICE_OBJECT *device, IRP *irp, void return STATUS_MORE_PROCESSING_REQUIRED; }
-static NTSTATUS send_device_irp( DEVICE_OBJECT *device, IRP *irp, ULONG_PTR *info ) +static void send_device_irp( DEVICE_OBJECT *device, IRP *irp ) { HANDLE event = CreateEventA( NULL, FALSE, FALSE, NULL ); DEVICE_OBJECT *toplevel_device; - NTSTATUS status;
irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; IoSetCompletionRoutine( irp, internal_complete, event, TRUE, TRUE, TRUE );
toplevel_device = IoGetAttachedDeviceReference( device ); - status = IoCallDriver( toplevel_device, irp ); - - if (status == STATUS_PENDING) + if (IoCallDriver( toplevel_device, irp ) == STATUS_PENDING) WaitForSingleObject( event, INFINITE ); - - status = irp->IoStatus.u.Status; - if (info) - *info = irp->IoStatus.Information; IoCompleteRequest( irp, IO_NO_INCREMENT ); ObDereferenceObject( toplevel_device ); CloseHandle( event ); - return status; }
static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCHAR **id ) @@ -119,7 +111,9 @@ static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WC irpsp->MinorFunction = IRP_MN_QUERY_ID; irpsp->Parameters.QueryId.IdType = type;
- return send_device_irp( device, irp, (ULONG_PTR *)id ); + send_device_irp( device, irp ); + *id = (WCHAR *)irp_status.Information; + return irp_status.u.Status; }
static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor ) @@ -139,7 +133,8 @@ static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor ) irpsp->Parameters.StartDevice.AllocatedResources = NULL; irpsp->Parameters.StartDevice.AllocatedResourcesTranslated = NULL;
- return send_device_irp( device, irp, NULL ); + send_device_irp( device, irp ); + return irp_status.u.Status; }
static NTSTATUS get_device_instance_id( DEVICE_OBJECT *device, WCHAR *buffer ) @@ -172,7 +167,7 @@ static NTSTATUS get_device_instance_id( DEVICE_OBJECT *device, WCHAR *buffer ) return STATUS_SUCCESS; }
-static NTSTATUS send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power ) +static void send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power ) { IO_STATUS_BLOCK irp_status; IO_STACK_LOCATION *irpsp; @@ -189,7 +184,7 @@ static NTSTATUS send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power irpsp->Parameters.Power.Type = DevicePowerState; irpsp->Parameters.Power.State.DeviceState = power;
- return send_device_irp( device, irp, NULL ); + send_device_irp( device, irp ); }
static void load_function_driver( DEVICE_OBJECT *device, HDEVINFO set, SP_DEVINFO_DATA *sp_device ) @@ -393,7 +388,6 @@ static void handle_bus_relations( DEVICE_OBJECT *parent ) DEVICE_RELATIONS *relations; IO_STATUS_BLOCK irp_status; IO_STACK_LOCATION *irpsp; - NTSTATUS status; HDEVINFO set; IRP *irp; ULONG i; @@ -413,9 +407,11 @@ static void handle_bus_relations( DEVICE_OBJECT *parent ) irpsp = IoGetNextIrpStackLocation( irp ); irpsp->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; irpsp->Parameters.QueryDeviceRelations.Type = BusRelations; - if ((status = send_device_irp( parent, irp, (ULONG_PTR *)&relations ))) + send_device_irp( parent, irp ); + relations = (DEVICE_RELATIONS *)irp_status.Information; + if (irp_status.u.Status) { - ERR("Failed to enumerate child devices, status %#x.\n", status); + ERR("Failed to enumerate child devices, status %#x.\n", irp_status.u.Status); SetupDiDestroyDeviceInfoList( set ); return; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 59 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 31 deletions(-)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 04e442a8300..4a1fbf001a4 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -73,45 +73,27 @@ static int interface_rb_compare( const void *key, const struct wine_rb_entry *en
static struct wine_rb_tree device_interfaces = { interface_rb_compare };
-static NTSTATUS WINAPI internal_complete( DEVICE_OBJECT *device, IRP *irp, void *context ) -{ - HANDLE event = context; - SetEvent( event ); - return STATUS_MORE_PROCESSING_REQUIRED; -} - -static void send_device_irp( DEVICE_OBJECT *device, IRP *irp ) -{ - HANDLE event = CreateEventA( NULL, FALSE, FALSE, NULL ); - DEVICE_OBJECT *toplevel_device; - - irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; - IoSetCompletionRoutine( irp, internal_complete, event, TRUE, TRUE, TRUE ); - - toplevel_device = IoGetAttachedDeviceReference( device ); - if (IoCallDriver( toplevel_device, irp ) == STATUS_PENDING) - WaitForSingleObject( event, INFINITE ); - IoCompleteRequest( irp, IO_NO_INCREMENT ); - ObDereferenceObject( toplevel_device ); - CloseHandle( event ); -} - static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCHAR **id ) { IO_STACK_LOCATION *irpsp; IO_STATUS_BLOCK irp_status; + KEVENT event; IRP *irp;
device = IoGetAttachedDevice( device );
- if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, NULL, &irp_status ))) + KeInitializeEvent( &event, NotificationEvent, FALSE ); + if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, &event, &irp_status ))) return STATUS_NO_MEMORY;
irpsp = IoGetNextIrpStackLocation( irp ); irpsp->MinorFunction = IRP_MN_QUERY_ID; irpsp->Parameters.QueryId.IdType = type;
- send_device_irp( device, irp ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + if (IoCallDriver( device, irp ) == STATUS_PENDING) + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); + *id = (WCHAR *)irp_status.Information; return irp_status.u.Status; } @@ -120,10 +102,12 @@ static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor ) { IO_STACK_LOCATION *irpsp; IO_STATUS_BLOCK irp_status; + KEVENT event; IRP *irp;
device = IoGetAttachedDevice( device );
+ KeInitializeEvent( &event, NotificationEvent, FALSE ); if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, NULL, &irp_status ))) return STATUS_NO_MEMORY;
@@ -133,7 +117,10 @@ static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor ) irpsp->Parameters.StartDevice.AllocatedResources = NULL; irpsp->Parameters.StartDevice.AllocatedResourcesTranslated = NULL;
- send_device_irp( device, irp ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + if (IoCallDriver( device, irp ) == STATUS_PENDING) + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); + return irp_status.u.Status; }
@@ -171,12 +158,14 @@ static void send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power ) { IO_STATUS_BLOCK irp_status; IO_STACK_LOCATION *irpsp; + KEVENT event; IRP *irp;
device = IoGetAttachedDevice( device );
- if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_POWER, device, NULL, 0, NULL, NULL, &irp_status ))) - return STATUS_NO_MEMORY; + KeInitializeEvent( &event, NotificationEvent, FALSE ); + if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_POWER, device, NULL, 0, NULL, &event, &irp_status ))) + return;
irpsp = IoGetNextIrpStackLocation( irp ); irpsp->MinorFunction = IRP_MN_SET_POWER; @@ -184,7 +173,9 @@ static void send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power ) irpsp->Parameters.Power.Type = DevicePowerState; irpsp->Parameters.Power.State.DeviceState = power;
- send_device_irp( device, irp ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + if (IoCallDriver( device, irp ) == STATUS_PENDING) + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); }
static void load_function_driver( DEVICE_OBJECT *device, HDEVINFO set, SP_DEVINFO_DATA *sp_device ) @@ -389,6 +380,7 @@ static void handle_bus_relations( DEVICE_OBJECT *parent ) IO_STATUS_BLOCK irp_status; IO_STACK_LOCATION *irpsp; HDEVINFO set; + KEVENT event; IRP *irp; ULONG i;
@@ -398,7 +390,8 @@ static void handle_bus_relations( DEVICE_OBJECT *parent )
parent = IoGetAttachedDevice( parent );
- if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, parent, NULL, 0, NULL, NULL, &irp_status ))) + KeInitializeEvent( &event, NotificationEvent, FALSE ); + if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, parent, NULL, 0, NULL, &event, &irp_status ))) { SetupDiDestroyDeviceInfoList( set ); return; @@ -407,7 +400,11 @@ static void handle_bus_relations( DEVICE_OBJECT *parent ) irpsp = IoGetNextIrpStackLocation( irp ); irpsp->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; irpsp->Parameters.QueryDeviceRelations.Type = BusRelations; - send_device_irp( parent, irp ); + + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + if (IoCallDriver( parent, irp ) == STATUS_PENDING) + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); + relations = (DEVICE_RELATIONS *)irp_status.Information; if (irp_status.u.Status) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/hidclass.sys/main.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/dlls/hidclass.sys/main.c b/dlls/hidclass.sys/main.c index 1c7a3ca82af..e169c429efb 100644 --- a/dlls/hidclass.sys/main.c +++ b/dlls/hidclass.sys/main.c @@ -92,34 +92,19 @@ NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration) return STATUS_SUCCESS; }
-static NTSTATUS WINAPI internalComplete(DEVICE_OBJECT *deviceObject, IRP *irp, - void *context) -{ - HANDLE event = context; - SetEvent(event); - return STATUS_MORE_PROCESSING_REQUIRED; -} - NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) { IRP *irp; - IO_STATUS_BLOCK irp_status; - NTSTATUS status; - HANDLE event = CreateEventA(NULL, FALSE, FALSE, NULL); + IO_STATUS_BLOCK io; + KEVENT event;
- irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size, - out_buff, out_size, TRUE, NULL, &irp_status); + KeInitializeEvent(&event, NotificationEvent, FALSE);
- IoSetCompletionRoutine(irp, internalComplete, event, TRUE, TRUE, TRUE); - status = IoCallDriver(device, irp); - - if (status == STATUS_PENDING) - WaitForSingleObject(event, INFINITE); - - status = irp->IoStatus.u.Status; + irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size, + out_buff, out_size, TRUE, &event, &io);
- IoCompleteRequest(irp, IO_NO_INCREMENT ); - CloseHandle(event); + if (IoCallDriver(device, irp) == STATUS_PENDING) + KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
- return status; + return io.u.Status; }